Report generator
Browse files- orchestrator_agent.py +30 -8
orchestrator_agent.py
CHANGED
|
@@ -57,15 +57,36 @@ def create_agent(csv_url: str, api_key: str) -> Agent:
|
|
| 57 |
csv_metadata = get_csv_basic_info(csv_url)
|
| 58 |
|
| 59 |
system_prompt = (
|
| 60 |
-
"You are a data analyst."
|
| 61 |
-
"
|
| 62 |
-
"
|
| 63 |
-
"
|
| 64 |
-
"
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
)
|
|
|
|
| 69 |
return Agent(
|
| 70 |
model=initialize_model(api_key),
|
| 71 |
deps_type=str,
|
|
@@ -73,6 +94,7 @@ def create_agent(csv_url: str, api_key: str) -> Agent:
|
|
| 73 |
system_prompt=system_prompt
|
| 74 |
)
|
| 75 |
|
|
|
|
| 76 |
def csv_orchestrator_chat(csv_url: str, user_question: str) -> str:
|
| 77 |
print("CSV URL:", csv_url)
|
| 78 |
print("User questions:", user_question)
|
|
|
|
| 57 |
csv_metadata = get_csv_basic_info(csv_url)
|
| 58 |
|
| 59 |
system_prompt = (
|
| 60 |
+
"You are a data analyst assistant with limited tool capabilities. "
|
| 61 |
+
"Available tools can only handle simple data queries: "
|
| 62 |
+
"- Count rows/columns\n- Calculate basic stats (avg, sum, min/max)\n"
|
| 63 |
+
"- Create simple visualizations (pie charts, bar graphs)\n"
|
| 64 |
+
"- Show column names/types\n\n"
|
| 65 |
+
|
| 66 |
+
"Query Handling Rules:\n"
|
| 67 |
+
"1. If query is complex, ambiguous, or exceeds tool capabilities:\n"
|
| 68 |
+
" - Break into simpler sub-questions\n"
|
| 69 |
+
" - Ask for clarification\n"
|
| 70 |
+
" - Rephrase to nearest simple query\n"
|
| 71 |
+
"2. For 'full report' requests:\n"
|
| 72 |
+
" - Outline possible analysis steps\n"
|
| 73 |
+
" - Ask user to select one component at a time\n\n"
|
| 74 |
+
|
| 75 |
+
"Examples:\n"
|
| 76 |
+
"- Bad query: 'Show me everything'\n"
|
| 77 |
+
" Response: 'I can show row count (10), columns (5: Name, Age...), "
|
| 78 |
+
"or a pie chart of categories. Which would you like?'\n"
|
| 79 |
+
"- Bad query: 'Analyze trends'\n"
|
| 80 |
+
" Response: 'For trend analysis, I can show monthly averages or "
|
| 81 |
+
"year-over-year comparisons. Please specify time period and metric.'\n\n"
|
| 82 |
+
|
| 83 |
+
"Current CSV Context:\n"
|
| 84 |
+
f"- URL: {csv_url}\n"
|
| 85 |
+
f"- Metadata: {csv_metadata}\n\n"
|
| 86 |
+
|
| 87 |
+
"Always format images as: "
|
| 88 |
)
|
| 89 |
+
|
| 90 |
return Agent(
|
| 91 |
model=initialize_model(api_key),
|
| 92 |
deps_type=str,
|
|
|
|
| 94 |
system_prompt=system_prompt
|
| 95 |
)
|
| 96 |
|
| 97 |
+
|
| 98 |
def csv_orchestrator_chat(csv_url: str, user_question: str) -> str:
|
| 99 |
print("CSV URL:", csv_url)
|
| 100 |
print("User questions:", user_question)
|