Spaces:
Running
Running
Pulastya B commited on
Commit Β·
bb48618
1
Parent(s): 644cb0d
Fixed the Agent Routing Logic which was causing issues
Browse files- src/orchestrator.py +24 -10
src/orchestrator.py
CHANGED
|
@@ -990,7 +990,7 @@ You are a DOER. Complete workflows based on user intent."""
|
|
| 990 |
"eda_agent": {
|
| 991 |
"name": "EDA Specialist",
|
| 992 |
"emoji": "π¬",
|
| 993 |
-
"description": "
|
| 994 |
"system_prompt": """You are the EDA Specialist Agent - an expert in exploratory data analysis.
|
| 995 |
|
| 996 |
**Your Expertise:**
|
|
@@ -1020,7 +1020,7 @@ You work collaboratively with other specialists and hand off cleaned data to pre
|
|
| 1020 |
"modeling_agent": {
|
| 1021 |
"name": "ML Modeling Specialist",
|
| 1022 |
"emoji": "π€",
|
| 1023 |
-
"description": "
|
| 1024 |
"system_prompt": """You are the ML Modeling Specialist Agent - an expert in machine learning.
|
| 1025 |
|
| 1026 |
**Your Expertise:**
|
|
@@ -1066,7 +1066,7 @@ You receive preprocessed data from data engineering agents and collaborate with
|
|
| 1066 |
"viz_agent": {
|
| 1067 |
"name": "Visualization Specialist",
|
| 1068 |
"emoji": "π",
|
| 1069 |
-
"description": "
|
| 1070 |
"system_prompt": """You are the Visualization Specialist Agent - an expert in data visualization.
|
| 1071 |
|
| 1072 |
**Your Expertise:**
|
|
@@ -1096,7 +1096,7 @@ You collaborate with all agents to visualize their outputs - EDA results, model
|
|
| 1096 |
"insight_agent": {
|
| 1097 |
"name": "Business Insights Specialist",
|
| 1098 |
"emoji": "π‘",
|
| 1099 |
-
"description": "
|
| 1100 |
"system_prompt": """You are the Business Insights Specialist Agent - an expert in translating data into action.
|
| 1101 |
|
| 1102 |
**Your Expertise:**
|
|
@@ -1127,7 +1127,7 @@ You synthesize outputs from all other agents and provide the final business narr
|
|
| 1127 |
"preprocessing_agent": {
|
| 1128 |
"name": "Data Engineering Specialist",
|
| 1129 |
"emoji": "βοΈ",
|
| 1130 |
-
"description": "
|
| 1131 |
"system_prompt": """You are the Data Engineering Specialist Agent - an expert in data preparation.
|
| 1132 |
|
| 1133 |
**Your Expertise:**
|
|
@@ -2880,12 +2880,26 @@ You receive quality reports from EDA agent and deliver clean data to modeling ag
|
|
| 2880 |
wants_viz = any(kw in task_lower for kw in ["plot", "graph", "visualiz", "dashboard", "chart", "show", "display", "create", "generate"])
|
| 2881 |
wants_clean = any(kw in task_lower for kw in ["clean", "missing", "impute"])
|
| 2882 |
wants_features = any(kw in task_lower for kw in ["feature", "engineer", "time-based", "extract features"])
|
| 2883 |
-
wants_train = any(kw in task_lower for kw in ["train", "model", "predict", "best model", "classify", "regression", "forecast"])
|
| 2884 |
|
| 2885 |
-
#
|
| 2886 |
-
|
| 2887 |
-
|
| 2888 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2889 |
|
| 2890 |
# π DETECT SPECIFIC PLOT TYPE - Match user's exact visualization request
|
| 2891 |
plot_type_guidance = ""
|
|
|
|
| 990 |
"eda_agent": {
|
| 991 |
"name": "EDA Specialist",
|
| 992 |
"emoji": "π¬",
|
| 993 |
+
"description": "Explore and understand data patterns, relationships, correlations, and distributions. Answer questions about how variables relate, change together, or affect each other. Analyze data quality, detect outliers and anomalies. Generate descriptive statistics, correlation matrices, scatter plots, histograms, box plots, and distribution visualizations to reveal insights.",
|
| 994 |
"system_prompt": """You are the EDA Specialist Agent - an expert in exploratory data analysis.
|
| 995 |
|
| 996 |
**Your Expertise:**
|
|
|
|
| 1020 |
"modeling_agent": {
|
| 1021 |
"name": "ML Modeling Specialist",
|
| 1022 |
"emoji": "π€",
|
| 1023 |
+
"description": "Build and train predictive machine learning models to forecast outcomes, classify categories, or predict future values. Perform supervised learning tasks including regression and classification. Train baseline models, optimize hyperparameters, conduct cross-validation, and evaluate model performance metrics like accuracy, precision, recall, and R-squared.",
|
| 1024 |
"system_prompt": """You are the ML Modeling Specialist Agent - an expert in machine learning.
|
| 1025 |
|
| 1026 |
**Your Expertise:**
|
|
|
|
| 1066 |
"viz_agent": {
|
| 1067 |
"name": "Visualization Specialist",
|
| 1068 |
"emoji": "π",
|
| 1069 |
+
"description": "Create visual representations, charts, graphs, and dashboards to display data patterns. Generate interactive plots including scatter plots, line charts, bar graphs, heatmaps, time series visualizations, and statistical plots. Design comprehensive dashboards and visual reports to communicate findings clearly.",
|
| 1070 |
"system_prompt": """You are the Visualization Specialist Agent - an expert in data visualization.
|
| 1071 |
|
| 1072 |
**Your Expertise:**
|
|
|
|
| 1096 |
"insight_agent": {
|
| 1097 |
"name": "Business Insights Specialist",
|
| 1098 |
"emoji": "π‘",
|
| 1099 |
+
"description": "Interpret trained machine learning model results and translate findings into actionable business recommendations. Explain why models make certain predictions, analyze feature importance from completed models, identify root causes in model outputs, generate what-if scenarios, and provide strategic business insights based on model performance and predictions.",
|
| 1100 |
"system_prompt": """You are the Business Insights Specialist Agent - an expert in translating data into action.
|
| 1101 |
|
| 1102 |
**Your Expertise:**
|
|
|
|
| 1127 |
"preprocessing_agent": {
|
| 1128 |
"name": "Data Engineering Specialist",
|
| 1129 |
"emoji": "βοΈ",
|
| 1130 |
+
"description": "Clean and prepare raw data for analysis by handling missing values, removing or treating outliers, encoding categorical variables, scaling numerical features, and engineering new features. Transform messy data into analysis-ready datasets through imputation, normalization, one-hot encoding, and feature creation.",
|
| 1131 |
"system_prompt": """You are the Data Engineering Specialist Agent - an expert in data preparation.
|
| 1132 |
|
| 1133 |
**Your Expertise:**
|
|
|
|
| 2880 |
wants_viz = any(kw in task_lower for kw in ["plot", "graph", "visualiz", "dashboard", "chart", "show", "display", "create", "generate"])
|
| 2881 |
wants_clean = any(kw in task_lower for kw in ["clean", "missing", "impute"])
|
| 2882 |
wants_features = any(kw in task_lower for kw in ["feature", "engineer", "time-based", "extract features"])
|
| 2883 |
+
wants_train = any(kw in task_lower for kw in ["train", "model", "predict", "best model", "classify", "regression", "forecast", "build model"])
|
| 2884 |
|
| 2885 |
+
# π CRITICAL: Detect exploratory/relationship questions (should NOT trigger ML training)
|
| 2886 |
+
wants_relationship = any(kw in task_lower for kw in [
|
| 2887 |
+
"how does", "how do", "relationship", "relate", "correlation", "correlate",
|
| 2888 |
+
"affect", "effect", "impact", "influence", "change with", "vary with",
|
| 2889 |
+
"compare", "difference between", "distribution", "pattern"
|
| 2890 |
+
])
|
| 2891 |
+
|
| 2892 |
+
# π― AUTO-ENABLE TRAINING: Only if explicitly asking for predictions AND not asking about relationships
|
| 2893 |
+
# Don't auto-enable for exploratory questions even if target exists
|
| 2894 |
+
if target_col and not wants_viz and not wants_clean and not wants_relationship and self.workflow_state.task_type in ["regression", "classification"]:
|
| 2895 |
+
# Additional check: only auto-enable if question implies prediction
|
| 2896 |
+
if wants_train or any(kw in task_lower for kw in ["predict", "forecast", "estimate"]):
|
| 2897 |
+
print(f" π― Auto-enabling ML training (detected {self.workflow_state.task_type} task with target='{target_col}')")
|
| 2898 |
+
wants_train = True
|
| 2899 |
+
elif wants_relationship:
|
| 2900 |
+
# Override: Relationship questions should NOT train models
|
| 2901 |
+
print(f" π Exploratory analysis detected - disabling auto-ML (question asks about relationships, not predictions)")
|
| 2902 |
+
wants_train = False
|
| 2903 |
|
| 2904 |
# π DETECT SPECIFIC PLOT TYPE - Match user's exact visualization request
|
| 2905 |
plot_type_guidance = ""
|