SatyamSinghal commited on
Commit
4751587
·
verified ·
1 Parent(s): 2d842c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -59,7 +59,6 @@ def get_groq_response(message, user_language):
59
  f"4. **Confidentiality**: Ensure that all information and insights provided remain secure and confidential, respecting user privacy.\n"
60
  f"5. **Explainability**: Provide clear, understandable, and actionable explanations for every AI-generated insight, ensuring users can easily follow the rationale behind the analysis.\n\n"
61
  f"Your primary goal is to assist users by providing accurate, personalized, and actionable insights related to private markets. Always maintain professionalism and conciseness. Ensure that responses are easy to interpret, and avoid jargon whenever possible.\n\n"
62
-
63
  )
64
  },
65
  {"role": "user", "content": message}
@@ -69,19 +68,19 @@ def get_groq_response(message, user_language):
69
  except Exception as e:
70
  return f"Oops, looks like something went wrong! Error: {str(e)}"
71
 
72
- # Function to format the response data in a readable and copyable form
73
  def format_response(data):
74
  if not data:
75
  return "No data available for this query."
76
 
77
  if isinstance(data, dict):
78
- formatted_response = "Insights:\n\n"
79
  for key, value in data.items():
80
- formatted_response += f"**{key.capitalize()}**: {value}\n"
81
  elif isinstance(data, list):
82
- formatted_response = "Insights:\n\n" + "\n".join(f"{idx+1}. {item}" for idx, item in enumerate(data))
83
  else:
84
- formatted_response = str(data)
85
 
86
  return formatted_response.strip()
87
 
@@ -119,7 +118,7 @@ def market_analysis_agent(user_input, history=[]):
119
  # Get dynamic AI response if query doesn't match predefined terms
120
  response = get_groq_response(user_input, user_language)
121
 
122
- # Format the response for easy readability and copy-pasting
123
  formatted_response = format_response(response)
124
 
125
  # Add some professional and engaging replies for the user
 
59
  f"4. **Confidentiality**: Ensure that all information and insights provided remain secure and confidential, respecting user privacy.\n"
60
  f"5. **Explainability**: Provide clear, understandable, and actionable explanations for every AI-generated insight, ensuring users can easily follow the rationale behind the analysis.\n\n"
61
  f"Your primary goal is to assist users by providing accurate, personalized, and actionable insights related to private markets. Always maintain professionalism and conciseness. Ensure that responses are easy to interpret, and avoid jargon whenever possible.\n\n"
 
62
  )
63
  },
64
  {"role": "user", "content": message}
 
68
  except Exception as e:
69
  return f"Oops, looks like something went wrong! Error: {str(e)}"
70
 
71
+ # Function to format the response data in a readable and highlighted form
72
  def format_response(data):
73
  if not data:
74
  return "No data available for this query."
75
 
76
  if isinstance(data, dict):
77
+ formatted_response = "### Insights:\n\n"
78
  for key, value in data.items():
79
+ formatted_response += f"**{key.capitalize()}**: {value}\n\n"
80
  elif isinstance(data, list):
81
+ formatted_response = "### Insights:\n\n" + "\n".join(f"{idx+1}. {item}" for idx, item in enumerate(data))
82
  else:
83
+ formatted_response = f"### Key Insights:\n\n{data}"
84
 
85
  return formatted_response.strip()
86
 
 
118
  # Get dynamic AI response if query doesn't match predefined terms
119
  response = get_groq_response(user_input, user_language)
120
 
121
+ # Format the response for easy readability and highlighting
122
  formatted_response = format_response(response)
123
 
124
  # Add some professional and engaging replies for the user