Update app.py
Browse files
app.py
CHANGED
@@ -106,7 +106,6 @@ def format_response(data):
|
|
106 |
|
107 |
return formatted_response.strip()
|
108 |
|
109 |
-
# Function to handle the interaction and queries
|
110 |
def market_analysis_agent(user_input, history=[]):
|
111 |
try:
|
112 |
# Detect the language of the user's input
|
@@ -119,64 +118,41 @@ def market_analysis_agent(user_input, history=[]):
|
|
119 |
history.append((user_input, command_response))
|
120 |
return history, history
|
121 |
|
122 |
-
#
|
123 |
-
if "
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
elif "investors" in user_input.lower():
|
128 |
-
response = investors
|
129 |
-
elif "products" in user_input.lower():
|
130 |
-
response = products_services
|
131 |
-
elif "news" in user_input.lower() or "updates" in user_input.lower():
|
132 |
-
response = news_updates
|
133 |
-
elif "legal" in user_input.lower() or "compliance" in user_input.lower():
|
134 |
-
response = legal_compliance
|
135 |
-
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():
|
136 |
-
response = social_media
|
137 |
-
elif "workforce" in user_input.lower():
|
138 |
-
response = workforce
|
139 |
else:
|
140 |
-
#
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
# Add some professional and engaging replies for the user
|
147 |
cool_replies = [
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
"Valuable input. Let’s build on this insight together. 🚀",
|
153 |
-
"You're making smart moves. Let’s keep adding value. 💡",
|
154 |
-
"Curiosity drives innovation — let’s keep pushing boundaries. 🔎",
|
155 |
-
"Strategic thinking in action! Let’s continue refining. 🎯",
|
156 |
-
"I see you're aiming for precision — let’s achieve clarity together. ⚙️",
|
157 |
-
"Sharp question! Let’s identify the key drivers. 🔑",
|
158 |
-
"You're thinking ahead. Let’s stay future-focused. 📅",
|
159 |
-
"Business insights are coming together — let’s maximize value. 📚",
|
160 |
-
"Making data-driven decisions? You’re spot on. 📊",
|
161 |
-
"I like your approach. Let’s keep this analytical momentum. 🧠",
|
162 |
-
"Big ideas require sharper analysis. Let’s keep refining. ✨",
|
163 |
-
"You’re asking the right questions — let’s uncover the next steps. 🚦",
|
164 |
-
"The numbers don’t lie — let’s make them work for us. 💸",
|
165 |
-
"Smart query! Let’s turn it into actionable intelligence. 🔎",
|
166 |
-
"Excellent business acumen. Let’s push further. 📈",
|
167 |
-
"Your focus is commendable — let’s identify new opportunities. 💻",
|
168 |
-
"Looks like you're identifying hidden value — let’s explore. 💎",
|
169 |
-
"Another smart step toward actionable insights. Let’s keep moving. 🚀",
|
170 |
-
"Strategic moves require sharp insights. Let’s build on this. 🛠️",
|
171 |
-
"You’re driving a data-driven approach. Let’s keep up the pace. 📊",
|
172 |
-
"Excellent thought process — let’s continue to optimize. 💼",
|
173 |
-
"Financial insights require precision — let’s dive deeper. 💰",
|
174 |
-
"Impressive thinking. Let’s sharpen the competitive advantage. ⚔️",
|
175 |
-
"Every number tells a story — let’s ensure it works in your favor. 🖋️",
|
176 |
-
"This shows strong foresight. Let’s unlock the next opportunity. 🔐",
|
177 |
-
"Taking this step reflects your analytical mindset. Let’s continue. 📚",
|
178 |
-
"Looks like a winning strategy. Let’s make it even stronger. 🏆"
|
179 |
-
]
|
180 |
formatted_response += f"\n{cool_replies[hash(user_input) % len(cool_replies)]}"
|
181 |
|
182 |
# Add to chat history
|
|
|
106 |
|
107 |
return formatted_response.strip()
|
108 |
|
|
|
109 |
def market_analysis_agent(user_input, history=[]):
|
110 |
try:
|
111 |
# Detect the language of the user's input
|
|
|
118 |
history.append((user_input, command_response))
|
119 |
return history, history
|
120 |
|
121 |
+
# Check if the query is related to cryptocurrency
|
122 |
+
if "bitcoin" in user_input.lower() or "crypto" in user_input.lower():
|
123 |
+
# Trigger the fetch_crypto_trends function
|
124 |
+
crypto_data = fetch_crypto_trends(symbol="BTC", market="USD", api_key="YOUR_API_KEY")
|
125 |
+
formatted_response = format_response(crypto_data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
else:
|
127 |
+
# Handle other predefined market queries
|
128 |
+
if "company" in user_input.lower():
|
129 |
+
response = company_profile
|
130 |
+
elif "financials" in user_input.lower():
|
131 |
+
response = financials
|
132 |
+
elif "investors" in user_input.lower():
|
133 |
+
response = investors
|
134 |
+
elif "products" in user_input.lower():
|
135 |
+
response = products_services
|
136 |
+
elif "news" in user_input.lower() or "updates" in user_input.lower():
|
137 |
+
response = news_updates
|
138 |
+
elif "legal" in user_input.lower() or "compliance" in user_input.lower():
|
139 |
+
response = legal_compliance
|
140 |
+
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():
|
141 |
+
response = social_media
|
142 |
+
elif "workforce" in user_input.lower():
|
143 |
+
response = workforce
|
144 |
+
else:
|
145 |
+
# Get dynamic AI response if query doesn't match predefined terms
|
146 |
+
response = get_groq_response(user_input, user_language, custom_data=json.dumps(company_profile))
|
147 |
+
# Format the response for easy readability and highlighting
|
148 |
+
formatted_response = format_response(response)
|
149 |
|
150 |
# Add some professional and engaging replies for the user
|
151 |
cool_replies = [
|
152 |
+
"Insightful observation. Let’s keep the momentum going. 📊",
|
153 |
+
"Good question! Let’s extract deeper business insights. 📈",
|
154 |
+
# Add your other cool replies here
|
155 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
formatted_response += f"\n{cool_replies[hash(user_input) % len(cool_replies)]}"
|
157 |
|
158 |
# Add to chat history
|