Commit
Β·
9cb7c11
1
Parent(s):
2dd2794
update to code agent
Browse files- app.py +8 -8
- followup_agent.py +42 -30
app.py
CHANGED
@@ -729,14 +729,14 @@ with gr.Blocks(title="π€ French Public Data Analysis Agent", theme=gr.themes.S
|
|
729 |
followup_section_header = gr.HTML("""
|
730 |
<div style="text-align: center; margin: 2rem 0;">
|
731 |
<h2 style="color: #374151; margin-bottom: 0.5rem;">π€ Follow-up Analysis</h2>
|
732 |
-
<p style="color: #6b7280; margin: 0;">Ask
|
733 |
</div>
|
734 |
""", visible=False)
|
735 |
|
736 |
with gr.Row(visible=False) as followup_input_row:
|
737 |
followup_input = gr.Textbox(
|
738 |
label="Follow-up Question",
|
739 |
-
placeholder="e.g., Show me correlation between
|
740 |
scale=4
|
741 |
)
|
742 |
followup_button = gr.Button(
|
@@ -772,12 +772,12 @@ with gr.Blocks(title="π€ French Public Data Analysis Agent", theme=gr.themes.S
|
|
772 |
|
773 |
with gr.Row(visible=False) as followup_examples_row:
|
774 |
followup_examples = [
|
775 |
-
("
|
776 |
-
("
|
777 |
-
("
|
778 |
-
("
|
779 |
-
("
|
780 |
-
("π
|
781 |
]
|
782 |
|
783 |
for emoji_text, query_text in followup_examples:
|
|
|
729 |
followup_section_header = gr.HTML("""
|
730 |
<div style="text-align: center; margin: 2rem 0;">
|
731 |
<h2 style="color: #374151; margin-bottom: 0.5rem;">π€ Follow-up Analysis</h2>
|
732 |
+
<p style="color: #6b7280; margin: 0;">Ask about report findings, request data analysis, or get contextual information</p>
|
733 |
</div>
|
734 |
""", visible=False)
|
735 |
|
736 |
with gr.Row(visible=False) as followup_input_row:
|
737 |
followup_input = gr.Textbox(
|
738 |
label="Follow-up Question",
|
739 |
+
placeholder="e.g., What are the main findings?, Show me correlation between columns, What is road safety policy in France?",
|
740 |
scale=4
|
741 |
)
|
742 |
followup_button = gr.Button(
|
|
|
772 |
|
773 |
with gr.Row(visible=False) as followup_examples_row:
|
774 |
followup_examples = [
|
775 |
+
("π Report Summary", "What were the main findings from the analysis?"),
|
776 |
+
("π Context Info", "What is the policy context for this data in France?"),
|
777 |
+
("π Create Chart", "Show me the correlation between two numerical columns with a scatter plot"),
|
778 |
+
("π Data Statistics", "Give me statistical summary for a specific column"),
|
779 |
+
("π― Filter Data", "Filter the data by specific criteria and show results"),
|
780 |
+
("π General Question", "Tell me more about this topic and its importance"),
|
781 |
]
|
782 |
|
783 |
for emoji_text, query_text in followup_examples:
|
followup_agent.py
CHANGED
@@ -57,37 +57,49 @@ def generate_followup_prompt(user_question, report_context=None):
|
|
57 |
|
58 |
USER'S FOLLOW-UP QUESTION: "{user_question}"
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
AVAILABLE TOOLS:
|
61 |
-
1. **
|
62 |
-
2. **
|
63 |
-
3. **
|
64 |
-
4. **
|
65 |
-
5. **
|
66 |
-
6. **
|
67 |
-
7. **
|
68 |
-
8. **
|
69 |
-
9. **
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
-
|
77 |
-
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
- Use the
|
86 |
-
-
|
87 |
-
-
|
88 |
-
|
89 |
-
|
90 |
-
-
|
|
|
|
|
|
|
91 |
|
92 |
Answer the user's question: "{user_question}"
|
93 |
"""
|
|
|
57 |
|
58 |
USER'S FOLLOW-UP QUESTION: "{user_question}"
|
59 |
|
60 |
+
IMPORTANT: Analyze the user's question carefully to determine what type of response is needed.
|
61 |
+
|
62 |
+
QUESTION ANALYSIS:
|
63 |
+
- **General Information/Web Search**: If the question asks for general information, definitions, or requires web search (e.g., "What is X?", "Tell me about Y", "How does Z work?"), use web search tools and provide a text answer. DO NOT load datasets or create visualizations.
|
64 |
+
|
65 |
+
- **Dataset Questions**: If the question is specifically about the dataset, data analysis, statistics, or requests visualizations (e.g., "Show me correlation", "Create a chart", "What's the distribution of X?", "Filter by Y"), then use dataset tools.
|
66 |
+
|
67 |
+
- **Report Context**: If the question asks about the previous report content or findings, use get_previous_report_content() and provide a text answer.
|
68 |
+
|
69 |
AVAILABLE TOOLS:
|
70 |
+
1. **DuckDuckGoSearchTool** - For general web search and information queries
|
71 |
+
2. **get_previous_report_content()** - Get context about the previous report
|
72 |
+
3. **load_previous_dataset()** - Load the dataset (ONLY if question needs data analysis)
|
73 |
+
4. **get_dataset_summary(df)** - Get dataset structure info
|
74 |
+
5. **create_followup_visualization()** - Create charts (ONLY if explicitly requested)
|
75 |
+
6. **analyze_column_correlation()** - Analyze column relationships with plots
|
76 |
+
7. **create_statistical_summary()** - Generate stats with visualizations
|
77 |
+
8. **filter_and_visualize_data()** - Filter data and create targeted visualizations
|
78 |
+
9. **search_datasets()** - Search for additional datasets
|
79 |
+
10. **get_dataset_info()** - Get info about specific datasets
|
80 |
+
|
81 |
+
RESPONSE STRATEGY:
|
82 |
+
1. **First, determine the question type:**
|
83 |
+
- Is this a general knowledge/web search question? β Use web search, provide text answer
|
84 |
+
- Is this about the previous report content? β Use get_previous_report_content(), provide text answer
|
85 |
+
- Is this a data analysis question? β Use dataset tools as needed
|
86 |
+
- Does it explicitly ask for a chart/visualization? β Use appropriate visualization tools
|
87 |
+
|
88 |
+
2. **For data analysis questions only:**
|
89 |
+
- Load dataset if you need to analyze the actual data
|
90 |
+
- Create visualizations ONLY if the user explicitly asks for them or if the question specifically requires visual analysis (correlations, distributions, trends)
|
91 |
+
- Provide clear text explanations
|
92 |
+
|
93 |
+
3. **Be efficient with tool usage:**
|
94 |
+
- Use the minimum number of tools needed to answer the question
|
95 |
+
- Don't create visualizations unless requested or clearly needed
|
96 |
+
- Don't load datasets for general questions
|
97 |
+
|
98 |
+
GUIDELINES:
|
99 |
+
- Match your response type to the question type
|
100 |
+
- Be direct and efficient - don't over-engineer the response
|
101 |
+
- Only use data analysis tools when the question is actually about data analysis
|
102 |
+
- Provide concise, helpful answers focused on what the user asked
|
103 |
|
104 |
Answer the user's question: "{user_question}"
|
105 |
"""
|