SatyamSinghal commited on
Commit
8ebd080
·
verified ·
1 Parent(s): 609433d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -21
app.py CHANGED
@@ -27,22 +27,24 @@ def command_handler(user_input):
27
  term = user_input[7:].strip()
28
  definitions = {
29
  "market analysis": (
30
- "Market analysis is like peeking into the crystal ball of business! 🔮 It's where we gather "
31
- "data about the market to forecast trends, track competition, and make smarter investment decisions!"
 
32
  ),
33
  "financials": (
34
- "Financial analysis is like the heartbeat of a company 💓. It tells us if the company is healthy, "
35
- "sustainable, and ready to grow! 💰"
36
  ),
37
  "investors": (
38
- "Investors are like the superheroes of the business world 🦸‍♂️. They bring in the cash to fuel growth, "
39
- "while hoping for big returns on their investment!"
 
40
  )
41
  }
42
- return definitions.get(term.lower(), "Hmm, I dont have a fun story for that term yet. Try another!")
43
  return None
44
 
45
- # Function to get the response from OpenAI with humor and energy
46
  def get_groq_response(message, user_language):
47
  try:
48
  response = openai.ChatCompletion.create(
@@ -51,9 +53,10 @@ def get_groq_response(message, user_language):
51
  {
52
  "role": "system",
53
  "content": (
54
- f"You are a cheerful and energetic Private Market Analyst AI with a passion for explaining "
55
- f"complex market analysis with humor, analogies, and wit. Keep it fun, engaging, and informative! "
56
- f"Use your energy to keep the user excited and curious about market trends!"
 
57
  )
58
  },
59
  {"role": "user", "content": message}
@@ -91,14 +94,13 @@ def market_analysis_agent(user_input, history=[]):
91
  # Get dynamic AI response if query doesn't match predefined terms
92
  response = get_groq_response(user_input, user_language)
93
 
94
- # Add some cool and fun responses for engagement
95
  cool_replies = [
96
- "You're on fire! 🔥",
97
- "Boom! 💥 That’s a market insight right there!",
98
- "Youve got this! 🚀",
99
- "Let's keep that momentum going! 💎",
100
- "That’s the power of market knowledge! 💪",
101
- "You’re crushing it! 🎯"
102
  ]
103
  response = f"{response} {cool_replies[hash(user_input) % len(cool_replies)]}"
104
 
@@ -117,9 +119,10 @@ chat_interface = gr.Interface(
117
  live=False, # Disable live responses; show after submit
118
  title="Private Market AI Agent", # Title of the app
119
  description=(
120
- "Welcome to your cheerful and energetic Private Market Analyst! 🎉\n\n"
121
- "Ask me anything about company profiles, market trends, financials, investors, and more! 🌟"
122
- "I’ll break it down with jokes, stories, and humor to make market analysis a blast! 🚀"
 
123
  )
124
  )
125
 
 
27
  term = user_input[7:].strip()
28
  definitions = {
29
  "market analysis": (
30
+ "Market analysis is the process of evaluating a business's position in the market by assessing "
31
+ "competitors, trends, and customer behavior to make informed decisions for growth and investment. "
32
+ "Think of it as gathering the insights needed to craft a winning strategy. 📊"
33
  ),
34
  "financials": (
35
+ "Financial analysis provides a snapshot of a company's fiscal health. It involves reviewing metrics like "
36
+ "profit margins, revenues, and expenditures to assess if the business is sustainable and scalable. 💵"
37
  ),
38
  "investors": (
39
+ "Investors are the capital partners that fuel innovation and expansion. They provide financial resources "
40
+ "in exchange for equity or debt, aiming to generate a return on their investment. It's all about leveraging "
41
+ "their capital to scale. 🏦"
42
  )
43
  }
44
+ return definitions.get(term.lower(), "I don't have a definition for that term yet. Let’s dive into your query directly!")
45
  return None
46
 
47
+ # Function to get the response from OpenAI with professionalism and energy
48
  def get_groq_response(message, user_language):
49
  try:
50
  response = openai.ChatCompletion.create(
 
53
  {
54
  "role": "system",
55
  "content": (
56
+ f"You are a professional, energetic Private Market Analyst AI. Your task is to explain market trends, "
57
+ f"company insights, and investment strategies in a clear, engaging, and authoritative manner. "
58
+ f"While providing top-tier market analysis, keep the tone polished, insightful, and relevant to business leaders. "
59
+ f"Always maintain professionalism while making the content informative and engaging."
60
  )
61
  },
62
  {"role": "user", "content": message}
 
94
  # Get dynamic AI response if query doesn't match predefined terms
95
  response = get_groq_response(user_input, user_language)
96
 
97
+ # Add some professional and engaging replies for the user
98
  cool_replies = [
99
+ "That’s a great insight! Keep the questions coming. 🔍",
100
+ "Excellent direction! Let’s explore that further. 📈",
101
+ "Insightful! Lets dive into the numbers. 📊",
102
+ "You've got the right focus. Let's sharpen those strategies. 🧠",
103
+ "You're on the right track. Let’s optimize that idea! 🔧"
 
104
  ]
105
  response = f"{response} {cool_replies[hash(user_input) % len(cool_replies)]}"
106
 
 
119
  live=False, # Disable live responses; show after submit
120
  title="Private Market AI Agent", # Title of the app
121
  description=(
122
+ "Welcome to your professional Private Market Analyst AI! 📊\n\n"
123
+ "Ask me anything about market trends, company profiles, financial analysis, investors, and more! "
124
+ "I’ll provide you with actionable insights, backed by data and clear explanations, to help you make informed decisions. "
125
+ "Let’s break down the complexities of the market with precision and insight. 🔍"
126
  )
127
  )
128