SatyamSinghal commited on
Commit
5362085
·
verified ·
1 Parent(s): be483d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -36
app.py CHANGED
@@ -28,21 +28,17 @@ def command_handler(user_input):
28
  term = user_input[7:].strip()
29
  definitions = {
30
  "market analysis": (
31
- "Market analysis is the process of evaluating a business's position in the market by assessing "
32
- "competitors, trends, and customer behavior to make informed decisions for growth and investment. "
33
- "Think of it as gathering the insights needed to craft a winning strategy. 📊"
34
  ),
35
  "financials": (
36
- "Financial analysis provides a snapshot of a company's fiscal health. It involves reviewing metrics like "
37
- "profit margins, revenues, and expenditures to assess if the business is sustainable and scalable. 💵"
38
  ),
39
  "investors": (
40
- "Investors are the capital partners that fuel innovation and expansion. They provide financial resources "
41
- "in exchange for equity or debt, aiming to generate a return on their investment. It's all about leveraging "
42
- "their capital to scale. 🏦"
43
  )
44
  }
45
- return definitions.get(term.lower(), "I don't have a definition for that term yet. Let’s dive into your query directly!")
46
  return None
47
 
48
  # Function to get the response from OpenAI with professionalism and energy
@@ -54,10 +50,9 @@ def get_groq_response(message, user_language):
54
  {
55
  "role": "system",
56
  "content": (
57
- f"You are a professional, energetic Private Market Analyst AI. Your task is to explain market trends, "
58
- f"company insights, and investment strategies in a clear, engaging, and authoritative manner. "
59
- f"While providing top-tier market analysis, keep the tone polished, insightful, and relevant to business leaders. "
60
- f"Always maintain professionalism while making the content informative and engaging."
61
  )
62
  },
63
  {"role": "user", "content": message}
@@ -69,27 +64,15 @@ def get_groq_response(message, user_language):
69
 
70
  # Function to format the response data in a readable and copyable form
71
  def format_response(data):
72
- # Check if the dataset is empty or not in a format that can be iterated
73
  if not data:
74
  return "No data available for this query."
75
 
76
- # Ensure that the data is iterable (list, dict, etc.)
77
  if isinstance(data, dict):
78
- formatted_response = "Here are the insights for your query:\n\n"
79
-
80
  for key, value in data.items():
81
- formatted_response += f"**{key.capitalize()}**:\n"
82
- if isinstance(value, list): # Check if the value is a list
83
- for idx, item in enumerate(value, start=1):
84
- formatted_response += f"{idx}. {item}\n"
85
- else:
86
- formatted_response += f"{value}\n"
87
- formatted_response += "\n"
88
-
89
- elif isinstance(data, list): # If the data is a list
90
- formatted_response = "Here are the insights for your query:\n\n"
91
- for idx, item in enumerate(data, start=1):
92
- formatted_response += f"{idx}. {item}\n"
93
  else:
94
  formatted_response = str(data)
95
 
@@ -134,11 +117,10 @@ def market_analysis_agent(user_input, history=[]):
134
 
135
  # Add some professional and engaging replies for the user
136
  cool_replies = [
137
- "That’s a great insight! Keep the questions coming. 🔍",
138
- "Excellent direction! Let’s explore that further. 📈",
139
- "Insightful! Let’s dive into the numbers. 📊",
140
- "You've got the right focus. Let's sharpen those strategies. 🧠",
141
- "You're on the right track. Let’s optimize that idea! 🔧"
142
  ]
143
  formatted_response += f"\n{cool_replies[hash(user_input) % len(cool_replies)]}"
144
 
@@ -159,8 +141,8 @@ chat_interface = gr.Interface(
159
  description=(
160
  "Welcome to your professional Private Market Analyst AI! 📊\n\n"
161
  "Ask me anything about market trends, company profiles, financial analysis, investors, and more! "
162
- "I’ll provide you with actionable insights, backed by data and clear explanations, to help you make informed decisions. "
163
- "Lets break down the complexities of the market with precision and insight. 🔍"
164
  )
165
  )
166
 
 
28
  term = user_input[7:].strip()
29
  definitions = {
30
  "market analysis": (
31
+ "Market analysis evaluates a business's position by studying competitors, trends, and customer behavior. "
32
+ "It helps in crafting strategies for growth. 📊"
 
33
  ),
34
  "financials": (
35
+ "Financial analysis examines profit margins, revenues, and expenses to determine fiscal health and sustainability. 💵"
 
36
  ),
37
  "investors": (
38
+ "Investors provide capital in exchange for equity or debt, enabling business growth and scaling. 🏦"
 
 
39
  )
40
  }
41
+ return definitions.get(term.lower(), "Definition not available. Let’s dive into your query!")
42
  return None
43
 
44
  # Function to get the response from OpenAI with professionalism and energy
 
50
  {
51
  "role": "system",
52
  "content": (
53
+ f"You are a professional and concise Private Market Analyst AI. Your task is to explain market trends, "
54
+ f"company insights, and investment strategies in a clear, impactful, and concise manner. "
55
+ f"Keep the responses brief yet informative, focusing on the key points. Always maintain professionalism. "
 
56
  )
57
  },
58
  {"role": "user", "content": message}
 
64
 
65
  # Function to format the response data in a readable and copyable form
66
  def format_response(data):
 
67
  if not data:
68
  return "No data available for this query."
69
 
 
70
  if isinstance(data, dict):
71
+ formatted_response = "Insights:\n\n"
 
72
  for key, value in data.items():
73
+ formatted_response += f"**{key.capitalize()}**: {value}\n"
74
+ elif isinstance(data, list):
75
+ formatted_response = "Insights:\n\n" + "\n".join(f"{idx+1}. {item}" for idx, item in enumerate(data))
 
 
 
 
 
 
 
 
 
76
  else:
77
  formatted_response = str(data)
78
 
 
117
 
118
  # Add some professional and engaging replies for the user
119
  cool_replies = [
120
+ "Insightful! Let's keep going! 🔍",
121
+ "Good question! More insights ahead. 📈",
122
+ "You're on the right track. Let’s keep this going. 🧠",
123
+ "Great focus! Lets explore further. 💡"
 
124
  ]
125
  formatted_response += f"\n{cool_replies[hash(user_input) % len(cool_replies)]}"
126
 
 
141
  description=(
142
  "Welcome to your professional Private Market Analyst AI! 📊\n\n"
143
  "Ask me anything about market trends, company profiles, financial analysis, investors, and more! "
144
+ "I’ll provide you with concise insights that are informative and to the point, helping you make well-informed decisions. "
145
+ "Let's break down market complexities with clarity. 🔍"
146
  )
147
  )
148