Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,21 @@ def get_groq_response(message, category):
|
|
13 |
"Stress Management": "Provide soothing advice and tips to help the user manage stress. Be calm, empathetic, and reassuring.",
|
14 |
"Career Advice": "Offer professional and constructive career advice. Be encouraging, insightful, and action-oriented.",
|
15 |
"General": "Engage in general conversation. Be friendly, approachable, and easygoing.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
# Add more categories as needed...
|
17 |
}
|
18 |
|
@@ -41,6 +56,7 @@ categories = {
|
|
41 |
"Academic Support": ["Study Tips", "Exam Preparation", "Project Guidance", "Time Management"],
|
42 |
"Mental & Physical Wellness": ["Stress Management", "Motivation & Focus", "Mental Health", "Physical Health"],
|
43 |
"Career & Financial": ["Networking & Career Building", "Resume Building", "Interview Preparation"],
|
|
|
44 |
}
|
45 |
|
46 |
# Gradio Interface
|
@@ -84,5 +100,32 @@ with gr.Blocks() as chat_interface:
|
|
84 |
inputs=[user_input, sub_category, chatbot_output],
|
85 |
outputs=[chatbot_output, chatbot_output]
|
86 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
chat_interface.launch()
|
|
|
13 |
"Stress Management": "Provide soothing advice and tips to help the user manage stress. Be calm, empathetic, and reassuring.",
|
14 |
"Career Advice": "Offer professional and constructive career advice. Be encouraging, insightful, and action-oriented.",
|
15 |
"General": "Engage in general conversation. Be friendly, approachable, and easygoing.",
|
16 |
+
"Data Analysis": """
|
17 |
+
You are an advanced AI tool designed to assist users in understanding and drawing insights from their data. Your objective is to analyze the data provided, identify key patterns, trends, and anomalies, and present the information in a clear, structured, and insightful manner. You must:
|
18 |
+
|
19 |
+
1. Data Analysis: Thoroughly analyze the data and identify key insights such as trends, correlations, patterns, and outliers.
|
20 |
+
|
21 |
+
2. Clear Explanation: Provide detailed explanations of the data, breaking it down into simple and understandable segments. Use analogies or examples if necessary to simplify complex concepts.
|
22 |
+
|
23 |
+
3. Visual Representation: Where applicable, create tables, graphs, pie charts, or histograms to present the data visually, enhancing comprehension.
|
24 |
+
|
25 |
+
4. Actionable Insights: Offer actionable recommendations or key takeaways from the data, making it easy for users to derive value from your analysis.
|
26 |
+
|
27 |
+
5. Contextual Understanding: Ensure you understand the context of the data provided. If the data is part of a larger problem or scenario, clarify how it fits into the bigger picture.
|
28 |
+
|
29 |
+
6. Customization: Adapt your analysis to the user's specific needs, whether it’s business, personal, or scientific data.
|
30 |
+
""",
|
31 |
# Add more categories as needed...
|
32 |
}
|
33 |
|
|
|
56 |
"Academic Support": ["Study Tips", "Exam Preparation", "Project Guidance", "Time Management"],
|
57 |
"Mental & Physical Wellness": ["Stress Management", "Motivation & Focus", "Mental Health", "Physical Health"],
|
58 |
"Career & Financial": ["Networking & Career Building", "Resume Building", "Interview Preparation"],
|
59 |
+
"Data Analysis": ["Analyze Business Data", "Analyze Scientific Data", "Analyze Personal Data"] # New category for Data Analysis
|
60 |
}
|
61 |
|
62 |
# Gradio Interface
|
|
|
100 |
inputs=[user_input, sub_category, chatbot_output],
|
101 |
outputs=[chatbot_output, chatbot_output]
|
102 |
)
|
103 |
+
|
104 |
+
# Additional field for Data Analysis inputs (only visible when Data Analysis is selected)
|
105 |
+
with gr.Row(visible=False) as data_analysis_row:
|
106 |
+
data_input = gr.Textbox(label="Input Your Data", placeholder="Paste or type your data here...")
|
107 |
+
analyze_button = gr.Button("Analyze Data")
|
108 |
+
data_analysis_output = gr.Textbox(label="Analysis Result", interactive=False)
|
109 |
+
|
110 |
+
def toggle_data_analysis_visibility(category):
|
111 |
+
if category == "Data Analysis":
|
112 |
+
return gr.update(visible=True)
|
113 |
+
else:
|
114 |
+
return gr.update(visible=False)
|
115 |
+
|
116 |
+
main_category.change(toggle_data_analysis_visibility, inputs=main_category, outputs=data_analysis_row)
|
117 |
+
|
118 |
+
# Handle Data Analysis
|
119 |
+
def handle_data_analysis(data_input):
|
120 |
+
if not data_input.strip():
|
121 |
+
return "Please provide valid data for analysis."
|
122 |
+
analysis_result = get_groq_response(data_input, "Data Analysis")
|
123 |
+
return analysis_result
|
124 |
+
|
125 |
+
analyze_button.click(
|
126 |
+
handle_data_analysis,
|
127 |
+
inputs=data_input,
|
128 |
+
outputs=data_analysis_output
|
129 |
+
)
|
130 |
|
131 |
chat_interface.launch()
|