Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -81,22 +81,21 @@ def market_analysis_agent(user_input, history=[]):
|
|
| 81 |
|
| 82 |
# Handle private market queries with datasets
|
| 83 |
if "company" in user_input.lower():
|
| 84 |
-
response = company_profile
|
| 85 |
elif "financials" in user_input.lower():
|
| 86 |
-
response = financials
|
| 87 |
elif "investors" in user_input.lower():
|
| 88 |
-
response = investors
|
| 89 |
elif "products" in user_input.lower():
|
| 90 |
-
response = products_services
|
| 91 |
elif "news" in user_input.lower() or "updates" in user_input.lower():
|
| 92 |
-
# Format the news updates response
|
| 93 |
response = format_response(news_updates)
|
| 94 |
elif "legal" in user_input.lower() or "compliance" in user_input.lower():
|
| 95 |
-
response = legal_compliance
|
| 96 |
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():
|
| 97 |
-
response = social_media
|
| 98 |
elif "workforce" in user_input.lower():
|
| 99 |
-
response = workforce
|
| 100 |
else:
|
| 101 |
# Get dynamic AI response if query doesn't match predefined terms
|
| 102 |
response = get_groq_response(user_input, user_language)
|
|
@@ -118,15 +117,22 @@ def market_analysis_agent(user_input, history=[]):
|
|
| 118 |
except Exception as e:
|
| 119 |
return [(user_input, f"Oops, something went wrong: {str(e)}")], history
|
| 120 |
|
| 121 |
-
# Function to format dataset responses
|
| 122 |
def format_response(data):
|
| 123 |
-
#
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
for key, value in data.items():
|
| 126 |
-
formatted_response += f"{key.capitalize()}:\n"
|
| 127 |
-
for item in value:
|
| 128 |
-
formatted_response += f"
|
| 129 |
-
|
|
|
|
|
|
|
| 130 |
|
| 131 |
# Gradio Interface setup
|
| 132 |
chat_interface = gr.Interface(
|
|
|
|
| 81 |
|
| 82 |
# Handle private market queries with datasets
|
| 83 |
if "company" in user_input.lower():
|
| 84 |
+
response = format_response(company_profile)
|
| 85 |
elif "financials" in user_input.lower():
|
| 86 |
+
response = format_response(financials)
|
| 87 |
elif "investors" in user_input.lower():
|
| 88 |
+
response = format_response(investors)
|
| 89 |
elif "products" in user_input.lower():
|
| 90 |
+
response = format_response(products_services)
|
| 91 |
elif "news" in user_input.lower() or "updates" in user_input.lower():
|
|
|
|
| 92 |
response = format_response(news_updates)
|
| 93 |
elif "legal" in user_input.lower() or "compliance" in user_input.lower():
|
| 94 |
+
response = format_response(legal_compliance)
|
| 95 |
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():
|
| 96 |
+
response = format_response(social_media)
|
| 97 |
elif "workforce" in user_input.lower():
|
| 98 |
+
response = format_response(workforce)
|
| 99 |
else:
|
| 100 |
# Get dynamic AI response if query doesn't match predefined terms
|
| 101 |
response = get_groq_response(user_input, user_language)
|
|
|
|
| 117 |
except Exception as e:
|
| 118 |
return [(user_input, f"Oops, something went wrong: {str(e)}")], history
|
| 119 |
|
| 120 |
+
# Function to format dataset responses for readability and easy copying
|
| 121 |
def format_response(data):
|
| 122 |
+
# Check if the dataset is empty
|
| 123 |
+
if not data:
|
| 124 |
+
return "No data available for this query."
|
| 125 |
+
|
| 126 |
+
formatted_response = "Here are the insights for your query:\n\n"
|
| 127 |
+
|
| 128 |
+
# Loop through each dataset and format it in a readable manner
|
| 129 |
for key, value in data.items():
|
| 130 |
+
formatted_response += f"**{key.capitalize()}**:\n"
|
| 131 |
+
for idx, item in enumerate(value, start=1):
|
| 132 |
+
formatted_response += f"{idx}. {item}\n"
|
| 133 |
+
formatted_response += "\n"
|
| 134 |
+
|
| 135 |
+
return formatted_response.strip()
|
| 136 |
|
| 137 |
# Gradio Interface setup
|
| 138 |
chat_interface = gr.Interface(
|