Update app.py
Browse files
app.py
CHANGED
@@ -88,14 +88,13 @@ def market_analysis_agent(user_input, history=[]):
|
|
88 |
response = investors
|
89 |
elif "products" in user_input.lower():
|
90 |
response = products_services
|
91 |
-
elif "news" or "updates" in user_input.lower():
|
92 |
-
|
93 |
-
|
|
|
94 |
response = legal_compliance
|
95 |
-
elif "social media" or "instagram" or "linkedin" or "twitter" in user_input.lower():
|
96 |
response = social_media
|
97 |
-
elif "product" or "services" in user_input.lower():
|
98 |
-
response = products_services
|
99 |
elif "workforce" in user_input.lower():
|
100 |
response = workforce
|
101 |
else:
|
@@ -119,6 +118,16 @@ def market_analysis_agent(user_input, history=[]):
|
|
119 |
except Exception as e:
|
120 |
return [(user_input, f"Oops, something went wrong: {str(e)}")], history
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
# Gradio Interface setup
|
123 |
chat_interface = gr.Interface(
|
124 |
fn=market_analysis_agent, # Function for handling user interaction
|
|
|
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:
|
|
|
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 |
+
# Format the response nicely
|
124 |
+
formatted_response = ""
|
125 |
+
for key, value in data.items():
|
126 |
+
formatted_response += f"{key.capitalize()}:\n"
|
127 |
+
for item in value:
|
128 |
+
formatted_response += f"- {item}\n"
|
129 |
+
return formatted_response
|
130 |
+
|
131 |
# Gradio Interface setup
|
132 |
chat_interface = gr.Interface(
|
133 |
fn=market_analysis_agent, # Function for handling user interaction
|