Spaces:
Build error
Build error
Upload 4 files
Browse files- app.py +1 -1
- prompt_models.py +45 -55
app.py
CHANGED
|
@@ -186,7 +186,7 @@ with col1a:
|
|
| 186 |
st.markdown(clean_response)
|
| 187 |
st.session_state.chatbot['chat_history'].append({"role": "assistant", "content": clean_response})
|
| 188 |
except AttributeError as e:
|
| 189 |
-
st.error(f"
|
| 190 |
else:
|
| 191 |
st.write('You need to upload the data first')
|
| 192 |
|
|
|
|
| 186 |
st.markdown(clean_response)
|
| 187 |
st.session_state.chatbot['chat_history'].append({"role": "assistant", "content": clean_response})
|
| 188 |
except AttributeError as e:
|
| 189 |
+
st.error(f"Please confirm data before before starting the chat: {e}")
|
| 190 |
else:
|
| 191 |
st.write('You need to upload the data first')
|
| 192 |
|
prompt_models.py
CHANGED
|
@@ -208,62 +208,52 @@ def prompt_chatbot(user_query, df, df1, df2):
|
|
| 208 |
|
| 209 |
def prompt_analyze(output, var_summaries, df, error):
|
| 210 |
prompt = f"""
|
| 211 |
-
|
| 212 |
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
{
|
| 217 |
-
|
| 218 |
-
2. Variabel yang dihasilkan:
|
| 219 |
-
{chr(10).join(var_summaries) if var_summaries else 'Tidak ada variabel baru dibuat'}
|
| 220 |
-
|
| 221 |
-
3. Error (jika ada):
|
| 222 |
-
{error if error else 'Tidak ada error'}
|
| 223 |
|
| 224 |
-
|
| 225 |
-
A.
|
| 226 |
-
-
|
| 227 |
-
-
|
| 228 |
-
-
|
| 229 |
-
|
| 230 |
-
B.
|
| 231 |
-
-
|
| 232 |
-
-
|
| 233 |
-
- Highlight
|
| 234 |
-
|
| 235 |
-
C.
|
| 236 |
-
-
|
| 237 |
-
-
|
| 238 |
-
-
|
| 239 |
-
|
| 240 |
-
D.
|
| 241 |
-
-
|
| 242 |
-
-
|
| 243 |
-
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
1.
|
| 247 |
-
2.
|
| 248 |
-
3.
|
| 249 |
-
4.
|
| 250 |
-
5.
|
| 251 |
-
6.
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
'
|
| 255 |
-
1.
|
| 256 |
-
2.
|
| 257 |
-
3.
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
-
|
| 262 |
-
-
|
| 263 |
-
-
|
| 264 |
-
|
| 265 |
-
Important
|
| 266 |
-
- Gunakan bahasa inggris untuk hasil text summarizenya
|
| 267 |
"""
|
| 268 |
-
|
| 269 |
return prompt
|
|
|
|
| 208 |
|
| 209 |
def prompt_analyze(output, var_summaries, df, error):
|
| 210 |
prompt = f"""
|
| 211 |
+
You are a data analyst explaining Python code execution results to non-technical stakeholders.
|
| 212 |
|
| 213 |
+
Execution results to analyze:
|
| 214 |
+
1. Text output: {output}
|
| 215 |
+
2. Generated variables: {chr(10).join(var_summaries) if var_summaries else 'No new variables created'}
|
| 216 |
+
3. Errors (if any): {error if error else 'No errors'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
|
| 218 |
+
Analysis format:
|
| 219 |
+
A. Graphics:
|
| 220 |
+
- Describe visualization type
|
| 221 |
+
- Identify main patterns/trends
|
| 222 |
+
- Provide business interpretation
|
| 223 |
+
|
| 224 |
+
B. Console Output:
|
| 225 |
+
- Translate numerical metrics to business context
|
| 226 |
+
- Explain statistical significance
|
| 227 |
+
- Highlight key decision-making metrics
|
| 228 |
+
|
| 229 |
+
C. New Variables:
|
| 230 |
+
- For new DataFrame columns: explain relationship with other columns
|
| 231 |
+
- For statistical variables: explain analytical implications
|
| 232 |
+
- Classify variable type (numeric/categorical/time series)
|
| 233 |
+
|
| 234 |
+
D. Next Recommendations:
|
| 235 |
+
- Suggest relevant additional analysis techniques
|
| 236 |
+
- Recommend supporting visualizations
|
| 237 |
+
- Identify potential data issues
|
| 238 |
+
|
| 239 |
+
Strict rules:
|
| 240 |
+
1. NEVER mention technical code details or libraries
|
| 241 |
+
2. Focus on business interpretation
|
| 242 |
+
3. Use everyday analogies for complex stats
|
| 243 |
+
4. Prioritize actionable insights
|
| 244 |
+
5. Limit to max 3 main points per category
|
| 245 |
+
6. Use clear numbered bullet points
|
| 246 |
+
|
| 247 |
+
Example structure:
|
| 248 |
+
'Analysis shows:
|
| 249 |
+
1. Visualization indicates... [graph interpretation]
|
| 250 |
+
2. R-squared value of 0.85 suggests... [metric explanation]
|
| 251 |
+
3. New "prediction" column has... [variable analysis]
|
| 252 |
+
Recommendations: [specific suggestions]'
|
| 253 |
+
|
| 254 |
+
Supporting data:
|
| 255 |
+
- DataFrame dimensions: {df.shape} rows x {len(df.columns)} columns
|
| 256 |
+
- Available columns: {list(df.columns)}
|
| 257 |
+
- Last descriptive stats: {df.describe().to_string() if not df.empty else 'Not available'}
|
|
|
|
|
|
|
|
|
|
| 258 |
"""
|
|
|
|
| 259 |
return prompt
|