Spaces:
Runtime error
Runtime error
feat: Improve error handling in ExecutorAgent by enhancing prompt clarity and response guidance for insufficient data scenarios
Browse files- README.md +3 -1
- backend/app/agents/executor.py +8 -7
README.md
CHANGED
|
@@ -168,12 +168,14 @@ User: "What about their locations?"
|
|
| 168 |
AI: [Understands context from previous query]
|
| 169 |
|
| 170 |
"Calculate Return Rate by Region. Don't give any chart"
|
| 171 |
-
β
|
| 172 |
|
| 173 |
"hi" or "how are you"
|
| 174 |
β Responds conversationally without triggering data analysis
|
| 175 |
```
|
| 176 |
|
|
|
|
|
|
|
| 177 |
---
|
| 178 |
|
| 179 |
## π Key Technical Features
|
|
|
|
| 168 |
AI: [Understands context from previous query]
|
| 169 |
|
| 170 |
"Calculate Return Rate by Region. Don't give any chart"
|
| 171 |
+
β β οΈ Note: Sample dataset lacks return data - AI will explain limitation and suggest alternatives
|
| 172 |
|
| 173 |
"hi" or "how are you"
|
| 174 |
β Responds conversationally without triggering data analysis
|
| 175 |
```
|
| 176 |
|
| 177 |
+
> **π Note on Test Prompt #10:** The challenge includes "Calculate Return Rate" but the Sample Superstore.csv doesn't contain return/refund data. The AI correctly identifies this limitation and explains what data would be needed. This demonstrates intelligent error handling.
|
| 178 |
+
|
| 179 |
---
|
| 180 |
|
| 181 |
## π Key Technical Features
|
backend/app/agents/executor.py
CHANGED
|
@@ -646,19 +646,20 @@ Do NOT import any system modules. Only use: pandas, matplotlib.pyplot, numpy.
|
|
| 646 |
|
| 647 |
# Build the prompt for Gemini
|
| 648 |
if is_insufficient_data:
|
| 649 |
-
prompt = f"""You are a data analysis assistant. The user asked a question that cannot be
|
| 650 |
|
| 651 |
User Question: {question}
|
| 652 |
|
| 653 |
-
Available Data
|
| 654 |
-
- Columns: {columns_info}
|
| 655 |
-
- Shape: {data_shape}
|
| 656 |
|
| 657 |
-
Analysis Plan
|
| 658 |
{plan}
|
| 659 |
|
| 660 |
-
|
| 661 |
-
|
|
|
|
|
|
|
|
|
|
| 662 |
else:
|
| 663 |
# Perform basic pandas analysis to get actual results
|
| 664 |
analysis_result = self._perform_pandas_analysis(df, question, plan)
|
|
|
|
| 646 |
|
| 647 |
# Build the prompt for Gemini
|
| 648 |
if is_insufficient_data:
|
| 649 |
+
prompt = f"""You are a helpful data analysis assistant. The user asked a question that cannot be answered with the current dataset.
|
| 650 |
|
| 651 |
User Question: {question}
|
| 652 |
|
| 653 |
+
Available Data Columns: {columns_info}
|
|
|
|
|
|
|
| 654 |
|
| 655 |
+
Analysis Plan Notes:
|
| 656 |
{plan}
|
| 657 |
|
| 658 |
+
Provide a friendly response that:
|
| 659 |
+
1. Explains what data/column is missing (e.g., "Returns" or "Return Status")
|
| 660 |
+
2. Suggests what alternative analysis CAN be done with the current data (e.g., sales by region, profit trends, etc.)
|
| 661 |
+
|
| 662 |
+
Keep response concise, helpful, and actionable (3-4 sentences max)."""
|
| 663 |
else:
|
| 664 |
# Perform basic pandas analysis to get actual results
|
| 665 |
analysis_result = self._perform_pandas_analysis(df, question, plan)
|