Spaces:
Build error
Build error
Update app.py
Browse files
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
|
| 31 |
-
"
|
|
|
|
| 32 |
),
|
| 33 |
"financials": (
|
| 34 |
-
"Financial analysis
|
| 35 |
-
"
|
| 36 |
),
|
| 37 |
"investors": (
|
| 38 |
-
"Investors are
|
| 39 |
-
"
|
|
|
|
| 40 |
)
|
| 41 |
}
|
| 42 |
-
return definitions.get(term.lower(), "
|
| 43 |
return None
|
| 44 |
|
| 45 |
-
# Function to get the response from OpenAI with
|
| 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
|
| 55 |
-
f"
|
| 56 |
-
f"
|
|
|
|
| 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
|
| 95 |
cool_replies = [
|
| 96 |
-
"
|
| 97 |
-
"
|
| 98 |
-
"
|
| 99 |
-
"Let's
|
| 100 |
-
"
|
| 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
|
| 121 |
-
"Ask me anything about company profiles,
|
| 122 |
-
"I’ll
|
|
|
|
| 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! Let’s 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 |
|