SatyamSinghal commited on
Commit
b543336
·
verified ·
1 Parent(s): b9944d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -42,8 +42,14 @@ def command_handler(user_input):
42
  return None
43
 
44
  # Function to get the response from OpenAI with professionalism and energy
45
- def get_groq_response(message, user_language):
46
  try:
 
 
 
 
 
 
47
  response = openai.ChatCompletion.create(
48
  model="llama-3.1-70b-versatile",
49
  messages=[
@@ -61,7 +67,7 @@ def get_groq_response(message, user_language):
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}
65
  ]
66
  )
67
  return response.choices[0].message["content"]
@@ -110,14 +116,13 @@ def market_analysis_agent(user_input, history=[]):
110
  response = news_updates
111
  elif "legal" in user_input.lower() or "compliance" in user_input.lower():
112
  response = legal_compliance
113
-
114
  elif "social media" in user_input.lower() or "instagram" in user_input.lower() or "linkedin" in user_input.lower() or "twitter" in user_input.lower():
115
  response = social_media
116
  elif "workforce" in user_input.lower():
117
  response = workforce
118
  else:
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 highlighting
123
  formatted_response = format_response(response)
 
42
  return None
43
 
44
  # Function to get the response from OpenAI with professionalism and energy
45
+ def get_groq_response(message, user_language, custom_data=None):
46
  try:
47
+ # If custom data is available, include it in the AI prompt
48
+ if custom_data:
49
+ prompt = f"Use the following information for analysis: {custom_data}. Then answer the user's query: {message}"
50
+ else:
51
+ prompt = message
52
+
53
  response = openai.ChatCompletion.create(
54
  model="llama-3.1-70b-versatile",
55
  messages=[
 
67
  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"
68
  )
69
  },
70
+ {"role": "user", "content": prompt}
71
  ]
72
  )
73
  return response.choices[0].message["content"]
 
116
  response = news_updates
117
  elif "legal" in user_input.lower() or "compliance" in user_input.lower():
118
  response = legal_compliance
 
119
  elif "social media" in user_input.lower() or "instagram" in user_input.lower() or "linkedin" in user_input.lower() or "twitter" in user_input.lower():
120
  response = social_media
121
  elif "workforce" in user_input.lower():
122
  response = workforce
123
  else:
124
  # Get dynamic AI response if query doesn't match predefined terms
125
+ response = get_groq_response(user_input, user_language, custom_data=json.dumps(company_profile))
126
 
127
  # Format the response for easy readability and highlighting
128
  formatted_response = format_response(response)