Spaces:
Running
Running
Pulastya B commited on
Commit Β·
b2a95b5
1
Parent(s): bb48618
Fixed the SSE Streaming not working
Browse files- FRRONTEEEND/components/ChatInterface.tsx +14 -2
- Server Logs.txt +250 -0
- src/orchestrator.py +58 -0
FRRONTEEEND/components/ChatInterface.tsx
CHANGED
|
@@ -212,6 +212,7 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 212 |
const scrollRef = useRef<HTMLDivElement>(null);
|
| 213 |
const eventSourceRef = useRef<EventSource | null>(null);
|
| 214 |
const processedAnalysisRef = useRef<Set<string>>(new Set()); // Track processed analysis_complete events
|
|
|
|
| 215 |
|
| 216 |
// Auth context for user tracking
|
| 217 |
const { user, isAuthenticated, dbSessionId, signOut } = useAuth();
|
|
@@ -283,13 +284,19 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 283 |
}
|
| 284 |
|
| 285 |
// Check if we're already connected to the correct session
|
| 286 |
-
|
|
|
|
| 287 |
// Same session - check if connection is still alive
|
| 288 |
if (eventSourceRef.current && eventSourceRef.current.readyState !== 2) {
|
| 289 |
console.log('β»οΈ Reusing existing SSE connection for same session');
|
| 290 |
return;
|
| 291 |
}
|
| 292 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
|
| 294 |
// Different session or connection is closed - need new connection
|
| 295 |
// First, close any existing connection
|
|
@@ -417,7 +424,7 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 417 |
isCleaningUpRef.current = false;
|
| 418 |
}
|
| 419 |
};
|
| 420 |
-
}, [activeSessionId]);
|
| 421 |
|
| 422 |
const processAnalysisResult = (result: any, sessionId: string) => {
|
| 423 |
// Extract and display the analysis result from SSE
|
|
@@ -554,6 +561,11 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
|
|
| 554 |
// Follow-up query - send task description only, backend will use cached dataset
|
| 555 |
formData.append('task_description', input);
|
| 556 |
console.log(`π€ Follow-up query for session ${sessionKey.slice(0, 8)}...`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 557 |
}
|
| 558 |
|
| 559 |
formData.append('session_id', sessionKey);
|
|
|
|
| 212 |
const scrollRef = useRef<HTMLDivElement>(null);
|
| 213 |
const eventSourceRef = useRef<EventSource | null>(null);
|
| 214 |
const processedAnalysisRef = useRef<Set<string>>(new Set()); // Track processed analysis_complete events
|
| 215 |
+
const [sseReconnectTrigger, setSseReconnectTrigger] = useState(0); // Force SSE reconnection for follow-up queries
|
| 216 |
|
| 217 |
// Auth context for user tracking
|
| 218 |
const { user, isAuthenticated, dbSessionId, signOut } = useAuth();
|
|
|
|
| 284 |
}
|
| 285 |
|
| 286 |
// Check if we're already connected to the correct session
|
| 287 |
+
// BUT: If sseReconnectTrigger changed, we MUST reconnect (follow-up query sent)
|
| 288 |
+
if (sseSessionRef.current === activeSessionId && sseReconnectTrigger === 0) {
|
| 289 |
// Same session - check if connection is still alive
|
| 290 |
if (eventSourceRef.current && eventSourceRef.current.readyState !== 2) {
|
| 291 |
console.log('β»οΈ Reusing existing SSE connection for same session');
|
| 292 |
return;
|
| 293 |
}
|
| 294 |
}
|
| 295 |
+
|
| 296 |
+
// If reconnect was triggered, log it
|
| 297 |
+
if (sseReconnectTrigger > 0) {
|
| 298 |
+
console.log(`π SSE reconnect triggered (trigger=${sseReconnectTrigger})`);
|
| 299 |
+
}
|
| 300 |
|
| 301 |
// Different session or connection is closed - need new connection
|
| 302 |
// First, close any existing connection
|
|
|
|
| 424 |
isCleaningUpRef.current = false;
|
| 425 |
}
|
| 426 |
};
|
| 427 |
+
}, [activeSessionId, sseReconnectTrigger]); // π Also reconnect when trigger changes
|
| 428 |
|
| 429 |
const processAnalysisResult = (result: any, sessionId: string) => {
|
| 430 |
// Extract and display the analysis result from SSE
|
|
|
|
| 561 |
// Follow-up query - send task description only, backend will use cached dataset
|
| 562 |
formData.append('task_description', input);
|
| 563 |
console.log(`π€ Follow-up query for session ${sessionKey.slice(0, 8)}...`);
|
| 564 |
+
|
| 565 |
+
// π CRITICAL: Force SSE reconnection for follow-up queries
|
| 566 |
+
// The previous SSE was closed after analysis_complete, need new connection
|
| 567 |
+
console.log('π Triggering SSE reconnection for follow-up query...');
|
| 568 |
+
setSseReconnectTrigger(prev => prev + 1);
|
| 569 |
}
|
| 570 |
|
| 571 |
formData.append('session_id', sessionKey);
|
Server Logs.txt
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
β
SBERT loaded on CPU
|
| 2 |
+
π Token Budget: 120,000 tokens available (128,000 - 8,000 reserve)
|
| 3 |
+
β
Sessions database initialized at ./cache_db/sessions.db
|
| 4 |
+
β
Created new session: 0af921ec-b3c2-4da2-a86c-3e2ca0625b99
|
| 5 |
+
π Output directory: /tmp/data_science_agent/outputs
|
| 6 |
+
INFO:src.api.app:β
Health check agent initialized with provider: mistral
|
| 7 |
+
INFO:src.api.app:π₯ Per-session agents enabled - each user gets isolated instance
|
| 8 |
+
INFO:src.api.app:π€ Multi-agent architecture enabled with 5 specialists
|
| 9 |
+
INFO: Application startup complete.
|
| 10 |
+
INFO: Uvicorn running on http://0.0.0.0:7860 (Press CTRL+C to quit)
|
| 11 |
+
INFO: 10.16.14.243:64867 - "GET /?logs=container HTTP/1.1" 200 OK
|
| 12 |
+
INFO: 10.16.14.243:64867 - "GET /index.css HTTP/1.1" 200 OK
|
| 13 |
+
INFO: 10.16.14.243:64867 - "GET /?logs=container HTTP/1.1" 200 OK
|
| 14 |
+
INFO: 10.16.21.217:19912 - "GET /index.css HTTP/1.1" 200 OK
|
| 15 |
+
INFO: 10.16.21.217:54528 - "GET / HTTP/1.1" 200 OK
|
| 16 |
+
INFO: 10.16.14.243:55708 - "GET /index.css HTTP/1.1" 200 OK
|
| 17 |
+
INFO: 10.16.21.217:54528 - "GET /assets/index-Doh4YfmS.js HTTP/1.1" 304 Not Modified
|
| 18 |
+
INFO: 10.16.14.243:55708 - "GET /favicon.ico HTTP/1.1" 200 OK
|
| 19 |
+
[SSE] ENDPOINT: Client connected for session_id=4b707472-0fe1-4130-8ad5-0c8f6a2cee66
|
| 20 |
+
[SSE] Queue registered, total subscribers: 1
|
| 21 |
+
INFO: 10.16.14.243:8417 - "GET /api/progress/stream/4b707472-0fe1-4130-8ad5-0c8f6a2cee66 HTTP/1.1" 200 OK
|
| 22 |
+
[SSE] SENDING connection event to client
|
| 23 |
+
[SSE] Sending 0 history events
|
| 24 |
+
[SSE] Starting event stream loop for session 4b707472-0fe1-4130-8ad5-0c8f6a2cee66
|
| 25 |
+
INFO:src.api.app:SSE stream cancelled for session 4b707472-0fe1-4130-8ad5-0c8f6a2cee66
|
| 26 |
+
INFO:src.api.app:SSE stream closed for session 4b707472-0fe1-4130-8ad5-0c8f6a2cee66
|
| 27 |
+
INFO:src.api.app:[ASYNC] Created new session: 77dee15c...
|
| 28 |
+
INFO:src.api.app:[ASYNC] File saved: uber_trips_dataset_50k.csv
|
| 29 |
+
INFO: 10.16.21.217:38897 - "POST /run-async HTTP/1.1" 200 OK
|
| 30 |
+
INFO:src.api.app:[BACKGROUND] Starting analysis for session 77dee15c...
|
| 31 |
+
INFO:src.api.app:[π] Creating lightweight session for 77dee15c...
|
| 32 |
+
INFO:src.api.app:β
Session created for 77dee15c (cache: 1/50) - <1s init
|
| 33 |
+
[DEBUG] Session fallback triggered - has_ambiguous_ref=True, resolved={}
|
| 34 |
+
[DEBUG] resolve_ambiguity returning: {}
|
| 35 |
+
[DEBUG] Orchestrator received resolved_params: {}
|
| 36 |
+
[DEBUG] Current file_path: '/tmp/data_science_agent/uber_trips_dataset_50k.csv', target_col: 'None'
|
| 37 |
+
π Extracting dataset schema locally (no LLM)...
|
| 38 |
+
π§ Semantic layer: Embedded 14 columns
|
| 39 |
+
Found 10 similar column pairs (potential duplicates)
|
| 40 |
+
π§ Semantic layer enriched 14 columns
|
| 41 |
+
β
Schema extracted: 50000 rows Γ 14 cols
|
| 42 |
+
File size: 8.46 MB
|
| 43 |
+
π‘ Inferred target column: fare_amount (confidence: 0.41)
|
| 44 |
+
Task type inferred: regression
|
| 45 |
+
π§ Semantic routing β π Visualization Specialist (confidence: 0.09)
|
| 46 |
+
π Reasoning: Selected viz_agent (confidence: 0.13)
|
| 47 |
+
|
| 48 |
+
π Delegating to: Visualization Specialist
|
| 49 |
+
Specialization: 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.
|
| 50 |
+
π― Agent-specific tools: 17 tools for viz_agent
|
| 51 |
+
π¦ Loaded 17 agent-specific tools
|
| 52 |
+
π Exploratory analysis detected - disabling auto-ML (question asks about relationships, not predictions)
|
| 53 |
+
πΎ Saved to session: dataset=/tmp/data_science_agent/uber_trips_dataset_50k.csv, target=fare_amount
|
| 54 |
+
π° Token budget: 0/500000 (0%)
|
| 55 |
+
π Token Budget Check: 677 / 120,000 tokens
|
| 56 |
+
β
Within budget
|
| 57 |
+
π° Token budget: 677/128000 (0.5%)
|
| 58 |
+
[SSE] ENDPOINT: Client connected for session_id=77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 59 |
+
[SSE] Queue registered, total subscribers: 1
|
| 60 |
+
INFO: 10.16.21.217:38897 - "GET /api/progress/stream/77dee15c-fa80-4df8-946b-cd10f79bad2d HTTP/1.1" 200 OK
|
| 61 |
+
[SSE] SENDING connection event to client
|
| 62 |
+
[SSE] Sending 0 history events
|
| 63 |
+
[SSE] Starting event stream loop for session 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 64 |
+
INFO:httpx:HTTP Request: POST https://api.mistral.ai/v1/chat/completions "HTTP/1.1 200 OK"
|
| 65 |
+
π Tokens: 2700 this call | 2700/500000 this minute
|
| 66 |
+
[SSE] PROGRESS_MANAGER EMIT: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, event_type=token_update, msg=π Tokens: 2700 this call | 2700/500000 this minute
|
| 67 |
+
[SSE] History stored, total events for 77dee15c-fa80-4df8-946b-cd10f79bad2d: 1
|
| 68 |
+
[SSE] Found 1 subscribers for 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 69 |
+
[SSE] Successfully queued event to subscriber 1
|
| 70 |
+
|
| 71 |
+
π§ Executing: generate_interactive_scatter
|
| 72 |
+
Arguments: {
|
| 73 |
+
"file_path": "/tmp/data_science_agent/uber_trips_dataset_50k.csv",
|
| 74 |
+
"x_col": "distance_km",
|
| 75 |
+
"y_col": "fare_amount",
|
| 76 |
+
"color_col": "city",
|
| 77 |
+
"output_path": "/tmp/data_science_agent/fare_vs_distance.html"
|
| 78 |
+
}
|
| 79 |
+
[SSE] EMIT tool_executing: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, tool=generate_interactive_scatter
|
| 80 |
+
[SSE] PROGRESS_MANAGER EMIT: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, event_type=tool_executing, msg=π§ Executing: generate_interactive_scatter
|
| 81 |
+
[SSE] History stored, total events for 77dee15c-fa80-4df8-946b-cd10f79bad2d: 2
|
| 82 |
+
[SSE] Found 1 subscribers for 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 83 |
+
[SSE] Successfully queued event to subscriber 1
|
| 84 |
+
π Final parameters: ['file_path', 'x_col', 'y_col', 'color_col', 'output_path']
|
| 85 |
+
[SSE] GOT event from queue: token_update
|
| 86 |
+
[SSE] GOT event from queue: tool_executing
|
| 87 |
+
πΎ Checkpoint saved: iteration 1, last tool: generate_interactive_scatter
|
| 88 |
+
β Completed: generate_interactive_scatter
|
| 89 |
+
[SSE] PROGRESS_MANAGER EMIT: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, event_type=tool_completed, msg=β Completed: generate_interactive_scatter
|
| 90 |
+
[SSE] History stored, total events for 77dee15c-fa80-4df8-946b-cd10f79bad2d: 3
|
| 91 |
+
[SSE] Found 1 subscribers for 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 92 |
+
[SSE] Successfully queued event to subscriber 1
|
| 93 |
+
π° Token budget: 2700/500000 (1%)
|
| 94 |
+
π Token Budget Check: 1,011 / 120,000 tokens
|
| 95 |
+
β
Within budget
|
| 96 |
+
π° Token budget: 1011/128000 (0.8%)
|
| 97 |
+
[SSE] GOT event from queue: tool_completed
|
| 98 |
+
INFO:httpx:HTTP Request: POST https://api.mistral.ai/v1/chat/completions "HTTP/1.1 200 OK"
|
| 99 |
+
π Tokens: 3033 this call | 5733/500000 this minute
|
| 100 |
+
[SSE] PROGRESS_MANAGER EMIT: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, event_type=token_update, msg=π Tokens: 3033 this call | 5733/500000 this minute
|
| 101 |
+
[SSE] History stored, total events for 77dee15c-fa80-4df8-946b-cd10f79bad2d: 4
|
| 102 |
+
[SSE] Found 1 subscribers for 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 103 |
+
[SSE] Successfully queued event to subscriber 1
|
| 104 |
+
|
| 105 |
+
π§ Executing: generate_interactive_time_series
|
| 106 |
+
Arguments: {
|
| 107 |
+
"file_path": "/tmp/data_science_agent/uber_trips_dataset_50k.csv",
|
| 108 |
+
"time_col": "pickup_time",
|
| 109 |
+
"value_cols": [
|
| 110 |
+
"fare_amount",
|
| 111 |
+
"distance_km"
|
| 112 |
+
],
|
| 113 |
+
"output_path": "/tmp/data_science_agent/fare_over_time.html"
|
| 114 |
+
}
|
| 115 |
+
[SSE] EMIT tool_executing: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, tool=generate_interactive_time_series
|
| 116 |
+
[SSE] PROGRESS_MANAGER EMIT: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, event_type=tool_executing, msg=π§ Executing: generate_interactive_time_series
|
| 117 |
+
[SSE] History stored, total events for 77dee15c-fa80-4df8-946b-cd10f79bad2d: 5
|
| 118 |
+
[SSE] Found 1 subscribers for 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 119 |
+
[SSE] Successfully queued event to subscriber 1
|
| 120 |
+
π Final parameters: ['file_path', 'time_col', 'value_cols', 'output_path']
|
| 121 |
+
[SSE] GOT event from queue: token_update
|
| 122 |
+
[SSE] GOT event from queue: tool_executing
|
| 123 |
+
πΎ Checkpoint saved: iteration 2, last tool: generate_interactive_time_series
|
| 124 |
+
β Completed: generate_interactive_time_series
|
| 125 |
+
[SSE] PROGRESS_MANAGER EMIT: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, event_type=tool_completed, msg=β Completed: generate_interactive_time_series
|
| 126 |
+
[SSE] History stored, total events for 77dee15c-fa80-4df8-946b-cd10f79bad2d: 6
|
| 127 |
+
[SSE] Found 1 subscribers for 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 128 |
+
[SSE] Successfully queued event to subscriber 1
|
| 129 |
+
π° Token budget: 5733/500000 (1%)
|
| 130 |
+
π Token Budget Check: 1,276 / 120,000 tokens
|
| 131 |
+
β
Within budget
|
| 132 |
+
π° Token budget: 1276/128000 (1.0%)
|
| 133 |
+
[SSE] GOT event from queue: tool_completed
|
| 134 |
+
INFO:httpx:HTTP Request: POST https://api.mistral.ai/v1/chat/completions "HTTP/1.1 200 OK"
|
| 135 |
+
π Tokens: 3583 this call | 9316/500000 this minute
|
| 136 |
+
[SSE] PROGRESS_MANAGER EMIT: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, event_type=token_update, msg=π Tokens: 3583 this call | 9316/500000 this minute
|
| 137 |
+
[SSE] History stored, total events for 77dee15c-fa80-4df8-946b-cd10f79bad2d: 7
|
| 138 |
+
[SSE] Found 1 subscribers for 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 139 |
+
[SSE] Successfully queued event to subscriber 1
|
| 140 |
+
[DEBUG] Added plot to array:
|
| 141 |
+
[DEBUG] title: Scatter
|
| 142 |
+
[DEBUG] url: /outputs/fare_vs_distance.html
|
| 143 |
+
[DEBUG] type: html
|
| 144 |
+
[DEBUG] Merging 0 reports into plots array
|
| 145 |
+
[DEBUG] Final plots array length: 1
|
| 146 |
+
β
Enhanced summary generated with 1 plots, 0 metrics
|
| 147 |
+
[DEBUG] Plots array contains 1 items:
|
| 148 |
+
[DEBUG] Plot 1: title='Scatter', url='/outputs/fare_vs_distance.html', type='html'
|
| 149 |
+
|
| 150 |
+
β
Session saved: 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 151 |
+
INFO:src.api.app:[BACKGROUND] Analysis completed for session 77dee15c...
|
| 152 |
+
[SSE] PROGRESS_MANAGER EMIT: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, event_type=analysis_complete, msg=β
Analysis completed successfully!
|
| 153 |
+
[SSE] History stored, total events for 77dee15c-fa80-4df8-946b-cd10f79bad2d: 8
|
| 154 |
+
[SSE] Found 1 subscribers for 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 155 |
+
[SSE] Successfully queued event to subscriber 1
|
| 156 |
+
[SSE] GOT event from queue: token_update
|
| 157 |
+
[SSE] GOT event from queue: analysis_complete
|
| 158 |
+
INFO:src.api.app:SSE stream closed for session 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 159 |
+
INFO: 10.16.21.217:42826 - "GET /outputs/fare_vs_distance.html HTTP/1.1" 200 OK
|
| 160 |
+
INFO: 10.16.14.243:46126 - "GET /outputs/fare_vs_distance.html HTTP/1.1" 206 Partial Content
|
| 161 |
+
INFO: 10.16.14.243:46126 - "GET /outputs/fare_vs_distance.html HTTP/1.1" 206 Partial Content
|
| 162 |
+
INFO: 10.16.21.217:54249 - "GET /outputs/fare_vs_distance.html HTTP/1.1" 200 OK
|
| 163 |
+
INFO: 10.16.14.243:42229 - "GET / HTTP/1.1" 200 OK
|
| 164 |
+
INFO: 10.16.21.217:53128 - "GET /outputs/fare_vs_distance.html HTTP/1.1" 200 OK
|
| 165 |
+
INFO: 10.16.14.243:41612 - "GET /outputs/fare_vs_distance.html HTTP/1.1" 206 Partial Content
|
| 166 |
+
INFO: 10.16.21.217:61863 - "GET /outputs/fare_vs_distance.html HTTP/1.1" 206 Partial Content
|
| 167 |
+
INFO:src.api.app:[ASYNC] Reusing session: 77dee15c... (follow-up)
|
| 168 |
+
INFO:src.api.app:[ASYNC] Follow-up query for session 77dee15c... - using cached dataset
|
| 169 |
+
INFO: 10.16.21.217:48177 - "POST /run-async HTTP/1.1" 200 OK
|
| 170 |
+
INFO:src.api.app:[BACKGROUND] Starting analysis for session 77dee15c...
|
| 171 |
+
INFO:src.api.app:[β»οΈ] Reusing session 77dee15c... (requests: 2)
|
| 172 |
+
π Checkpoint loaded: iteration 2, last tool: generate_interactive_time_series
|
| 173 |
+
ποΈ Clearing old checkpoint to start fresh workflow
|
| 174 |
+
ποΈ Checkpoint cleared for session 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 175 |
+
[DEBUG] Ultimate fallback: Using last_dataset from session: /tmp/data_science_agent/uber_trips_dataset_50k.csv
|
| 176 |
+
[DEBUG] Ultimate fallback: Using last_target_col from session: fare_amount
|
| 177 |
+
[DEBUG] resolve_ambiguity returning: {'file_path': '/tmp/data_science_agent/uber_trips_dataset_50k.csv', 'target_col': 'fare_amount'}
|
| 178 |
+
[DEBUG] Orchestrator received resolved_params: {'file_path': '/tmp/data_science_agent/uber_trips_dataset_50k.csv', 'target_col': 'fare_amount'}
|
| 179 |
+
[DEBUG] Current file_path: '', target_col: 'None'
|
| 180 |
+
π Using dataset from session: /tmp/data_science_agent/uber_trips_dataset_50k.csv
|
| 181 |
+
π Using target column from session: fare_amount
|
| 182 |
+
|
| 183 |
+
**Session Context:**
|
| 184 |
+
- Dataset: /tmp/data_science_agent/uber_trips_dataset_50k.csv
|
| 185 |
+
- Target Column: fare_amount
|
| 186 |
+
- Output Files:
|
| 187 |
+
- other: /tmp/data_science_agent/fare_over_time.html
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
π Extracting dataset schema locally (no LLM)...
|
| 191 |
+
π§ Semantic layer: Embedded 14 columns
|
| 192 |
+
Found 10 similar column pairs (potential duplicates)
|
| 193 |
+
π§ Semantic layer enriched 14 columns
|
| 194 |
+
β
Schema extracted: 50000 rows Γ 14 cols
|
| 195 |
+
File size: 8.46 MB
|
| 196 |
+
Task type inferred: regression
|
| 197 |
+
π§ Semantic routing β π Visualization Specialist (confidence: 0.21)
|
| 198 |
+
π Reasoning: Selected viz_agent (confidence: 0.31)
|
| 199 |
+
|
| 200 |
+
π Delegating to: Visualization Specialist
|
| 201 |
+
Specialization: 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.
|
| 202 |
+
π― Agent-specific tools: 17 tools for viz_agent
|
| 203 |
+
π¦ Loaded 17 agent-specific tools
|
| 204 |
+
π Exploratory analysis detected - disabling auto-ML (question asks about relationships, not predictions)
|
| 205 |
+
πΎ Saved to session: dataset=/tmp/data_science_agent/uber_trips_dataset_50k.csv, target=fare_amount
|
| 206 |
+
π Token budget reset (was 9316/500000)
|
| 207 |
+
π° Token budget: 0/500000 (0%)
|
| 208 |
+
π Token Budget Check: 676 / 120,000 tokens
|
| 209 |
+
β
Within budget
|
| 210 |
+
π° Token budget: 676/128000 (0.5%)
|
| 211 |
+
INFO:httpx:HTTP Request: POST https://api.mistral.ai/v1/chat/completions "HTTP/1.1 200 OK"
|
| 212 |
+
π Tokens: 4220 this call | 4220/500000 this minute
|
| 213 |
+
[SSE] PROGRESS_MANAGER EMIT: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, event_type=token_update, msg=π Tokens: 4220 this call | 4220/500000 this minute
|
| 214 |
+
[SSE] History stored, total events for 77dee15c-fa80-4df8-946b-cd10f79bad2d: 9
|
| 215 |
+
[SSE] Found 0 subscribers for 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 216 |
+
|
| 217 |
+
π§ Executing: execute_python_code
|
| 218 |
+
Arguments: {
|
| 219 |
+
"code": "import pandas as pd\nimport plotly.express as px\nimport plotly.graph_objects as go\nfrom plotly.subplots import make_subplots\n\n# Load the dataset\nfile_path = '/tmp/data_science_agent/uber_trips_dataset_50k.csv'\ndf = pd.read_csv(file_path)\n\n# Convert pickup_time to datetime and extract temporal features\ndf['pickup_time'] = pd.to_datetime(df['pickup_time'])\ndf['pickup_date'] = df['pickup_time'].dt.date\ndf['pickup_month'] = df['pickup_time'].dt.to_period('M').astype(str)\ndf['pickup_dayofweek'] = df['pickup_time'].dt.day_name()\ndf['pickup_hour'] = df['pickup_time'].dt.hour\n\n# Create monthly demand analysis\nmonthly_demand = df.groupby('pickup_month').agg({\n 'fare_amount': ['sum', 'mean', 'count'],\n 'distance_km': ['mean']\n}).reset_index()\nmonthly_demand.columns = ['pickup_month', 'total_fare_amount', 'avg_fare_amount', 'trip_count', 'avg_distance_km']\n\n# Create day of week analysis\ndayofweek_order = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']\ndayofweek_demand = df.groupby('pickup_dayofweek').agg({\n 'fare_amount': ['sum', 'mean', 'count'],\n 'distance_km': ['mean']\n}).reindex(dayofweek_order).reset_index()\ndayofweek_demand.columns = ['pickup_dayofweek', 'total_fare_amount', 'avg_fare_amount', 'trip_count', 'avg_distance_km']\n\n# Create hourly analysis\nhourly_demand = df.groupby('pickup_hour').agg({\n 'fare_amount': ['sum', 'mean', 'count'],\n 'distance_km': ['mean']\n}).reset_index()\nhourly_demand.columns = ['pickup_hour', 'total_fare_amount', 'avg_fare_amount', 'trip_count', 'avg_distance_km']\n\n# Create interactive visualizations\nfig1 = make_subplots(rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.05,\n subplot_titles=('Monthly Trip Count and Total Fare Amount', 'Monthly Average Fare and Distance'))\n\n# Add monthly trip count and total fare\nfig1.add_trace(go.Bar(x=monthly_demand['pickup_month'], y=monthly_demand['trip_count'],\n name='Trip Count', marker_color='royalblue'), row=1, col=1)\nfig1.add_trace(go.Scatter(x=monthly_demand['pickup_month'], y=monthly_demand['total_fare_amount'],\n name='Total Fare Amount', line=dict(color='firebrick', width=2)), row=1, col=1)\n\n# Add monthly average fare and distance\nfig1.add_trace(go.Scatter(x=monthly_demand['pickup_month'], y=monthly_demand['avg_fare_amount'],\n name='Avg Fare Amount', line=dict(color='green', width=2)), row=2, col=1)\nfig1.add_trace(go.Scatter(x=monthly_demand['pickup_month'], y=monthly_demand['avg_distance_km'],\n name='Avg Distance', line=dict(color='orange', width=2)), row=2, col=1)\n\nfig1.update_layout(height=800, title_text='Monthly Demand Patterns',\n hovermode='x unified', template='plotly_white')\n\n# Create day of week visualization\nfig2 = make_subplots(rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.05,\n subplot_titles=('Day of Week Trip Count and Total Fare Amount', 'Day of Week Average Fare and Distance'))\n\nfig2.add_trace(go.Bar(x=dayofweek_demand['pickup_dayofweek'], y=dayofweek_demand['trip_count'],\n name='Trip Count', marker_color='royalblue'), row=1, col=1)\nfig2.add_trace(go.Scatter(x=dayofweek_demand['pickup_dayofweek'], y=dayofweek_demand['total_fare_amount'],\n name='Total Fare Amount', line=dict(color='firebrick', width=2)), row=1, col=1)\n\nfig2.add_trace(go.Scatter(x=dayofweek_demand['pickup_dayofweek'], y=dayofweek_demand['avg_fare_amount'],\n name='Avg Fare Amount', line=dict(color='green', width=2)), row=2, col=1)\nfig2.add_trace(go.Scatter(x=dayofweek_demand['pickup_dayofweek'], y=dayofweek_demand['avg_distance_km'],\n name='Avg Distance', line=dict(color='orange', width=2)), row=2, col=1)\n\nfig2.update_layout(height=800, title_text='Day of Week Demand Patterns',\n hovermode='x unified', template='plotly_white')\n\n# Create hourly visualization\nfig3 = px.line(hourly_demand, x='pickup_hour', y=['trip_count', 'total_fare_amount'],\n title='Hourly Demand Patterns',\n labels={'value': 'Count/Amount', 'pickup_hour': 'Hour of Day', 'variable': 'Metric'})\nfig3.update_layout(template='plotly_white', hovermode='x unified')\n\n# Save visualizations\nfig1.write_html('/tmp/data_science_agent/monthly_demand_patterns.html')\nfig2.write_html('/tmp/data_science_agent/dayofweek_demand_patterns.html')\nfig3.write_html('/tmp/data_science_agent/hourly_demand_patterns.html')\n\n# Return summary statistics\nsummary_stats = {\n 'monthly_patterns': monthly_demand.to_dict('records'),\n 'dayofweek_patterns': dayofweek_demand.to_dict('records'),\n 'hourly_patterns': hourly_demand.to_dict('records'),\n 'visualizations_created': [\n '/tmp/data_science_agent/monthly_demand_patterns.html',\n '/tmp/data_science_agent/dayofweek_demand_patterns.html',\n '/tmp/data_science_agent/hourly_demand_patterns.html'\n ]\n}\n\nsummary_stats",
|
| 220 |
+
"working_directory": "/tmp/data_science_agent",
|
| 221 |
+
"timeout": 30
|
| 222 |
+
}
|
| 223 |
+
[SSE] EMIT tool_executing: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, tool=execute_python_code
|
| 224 |
+
[SSE] PROGRESS_MANAGER EMIT: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, event_type=tool_executing, msg=π§ Executing: execute_python_code
|
| 225 |
+
[SSE] History stored, total events for 77dee15c-fa80-4df8-946b-cd10f79bad2d: 10
|
| 226 |
+
[SSE] Found 0 subscribers for 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 227 |
+
π Final parameters: ['code', 'working_directory', 'timeout']
|
| 228 |
+
πΎ Checkpoint saved: iteration 1, last tool: execute_python_code
|
| 229 |
+
β Completed: execute_python_code
|
| 230 |
+
[SSE] PROGRESS_MANAGER EMIT: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, event_type=tool_completed, msg=β Completed: execute_python_code
|
| 231 |
+
[SSE] History stored, total events for 77dee15c-fa80-4df8-946b-cd10f79bad2d: 11
|
| 232 |
+
[SSE] Found 0 subscribers for 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 233 |
+
π° Token budget: 4220/500000 (1%)
|
| 234 |
+
π Token Budget Check: 1,064 / 120,000 tokens
|
| 235 |
+
β
Within budget
|
| 236 |
+
π° Token budget: 1064/128000 (0.8%)
|
| 237 |
+
INFO:httpx:HTTP Request: POST https://api.mistral.ai/v1/chat/completions "HTTP/1.1 200 OK"
|
| 238 |
+
π Tokens: 5467 this call | 9687/500000 this minute
|
| 239 |
+
[SSE] PROGRESS_MANAGER EMIT: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, event_type=token_update, msg=π Tokens: 5467 this call | 9687/500000 this minute
|
| 240 |
+
[SSE] History stored, total events for 77dee15c-fa80-4df8-946b-cd10f79bad2d: 12
|
| 241 |
+
[SSE] Found 0 subscribers for 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 242 |
+
[DEBUG] Merging 0 reports into plots array
|
| 243 |
+
[DEBUG] Final plots array length: 0
|
| 244 |
+
β
Enhanced summary generated with 0 plots, 0 metrics
|
| 245 |
+
|
| 246 |
+
β
Session saved: 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
| 247 |
+
INFO:src.api.app:[BACKGROUND] Analysis completed for session 77dee15c...
|
| 248 |
+
[SSE] PROGRESS_MANAGER EMIT: session=77dee15c-fa80-4df8-946b-cd10f79bad2d, event_type=analysis_complete, msg=β
Analysis completed successfully!
|
| 249 |
+
[SSE] History stored, total events for 77dee15c-fa80-4df8-946b-cd10f79bad2d: 13
|
| 250 |
+
[SSE] Found 0 subscribers for 77dee15c-fa80-4df8-946b-cd10f79bad2d
|
src/orchestrator.py
CHANGED
|
@@ -6,6 +6,7 @@ Supports multiple providers: Groq and Gemini.
|
|
| 6 |
|
| 7 |
import json
|
| 8 |
import os
|
|
|
|
| 9 |
from typing import Dict, Any, List, Optional
|
| 10 |
from pathlib import Path
|
| 11 |
import time
|
|
@@ -1640,6 +1641,63 @@ You receive quality reports from EDA agent and deliver clean data to modeling ag
|
|
| 1640 |
"path": data_path,
|
| 1641 |
"url": f"/outputs/{url_path}"
|
| 1642 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1643 |
|
| 1644 |
# Build COMPREHENSIVE response template following user's format
|
| 1645 |
summary_lines = []
|
|
|
|
| 6 |
|
| 7 |
import json
|
| 8 |
import os
|
| 9 |
+
import re
|
| 10 |
from typing import Dict, Any, List, Optional
|
| 11 |
from pathlib import Path
|
| 12 |
import time
|
|
|
|
| 1641 |
"path": data_path,
|
| 1642 |
"url": f"/outputs/{url_path}"
|
| 1643 |
})
|
| 1644 |
+
|
| 1645 |
+
# === SCAN execute_python_code OUTPUT FOR HTML FILES ===
|
| 1646 |
+
# When LLM uses execute_python_code to create visualizations, the HTML paths
|
| 1647 |
+
# are not in output_path - we need to scan the output/stdout for .html paths
|
| 1648 |
+
if tool == "execute_python_code":
|
| 1649 |
+
# Get raw output from code execution
|
| 1650 |
+
raw_output = str(nested_result.get("output", "")) + str(nested_result.get("stdout", "")) + str(result.get("output", ""))
|
| 1651 |
+
|
| 1652 |
+
# Also scan the code itself for write_html() calls
|
| 1653 |
+
code_str = str(step.get("arguments", {}).get("code", ""))
|
| 1654 |
+
|
| 1655 |
+
# Regex to find .html file paths in output or code
|
| 1656 |
+
html_paths = set()
|
| 1657 |
+
|
| 1658 |
+
# Pattern 1: Paths in write_html() calls
|
| 1659 |
+
write_html_pattern = r"write_html\s*\(\s*['\"]([^'\"]+\.html)['\"]"
|
| 1660 |
+
html_paths.update(re.findall(write_html_pattern, code_str))
|
| 1661 |
+
|
| 1662 |
+
# Pattern 2: Paths like /tmp/data_science_agent/*.html in output
|
| 1663 |
+
output_pattern = r"(/tmp/data_science_agent/[^\s'\"]+\.html)"
|
| 1664 |
+
html_paths.update(re.findall(output_pattern, raw_output))
|
| 1665 |
+
html_paths.update(re.findall(output_pattern, code_str))
|
| 1666 |
+
|
| 1667 |
+
# Pattern 3: visualizations_created list in output (common pattern)
|
| 1668 |
+
viz_list_pattern = r"visualizations_created['\"]?\s*:\s*\[([^\]]+)\]"
|
| 1669 |
+
viz_match = re.search(viz_list_pattern, raw_output)
|
| 1670 |
+
if viz_match:
|
| 1671 |
+
viz_paths = re.findall(r"['\"]([^'\"]+\.html)['\"]", viz_match.group(1))
|
| 1672 |
+
html_paths.update(viz_paths)
|
| 1673 |
+
|
| 1674 |
+
print(f"[DEBUG] execute_python_code artifact scanner found {len(html_paths)} HTML files: {html_paths}")
|
| 1675 |
+
|
| 1676 |
+
# Register each found HTML as a plot
|
| 1677 |
+
for html_path in html_paths:
|
| 1678 |
+
# Extract title from filename
|
| 1679 |
+
filename = html_path.split("/")[-1]
|
| 1680 |
+
plot_title = filename.replace("_", " ").replace(".html", "").title()
|
| 1681 |
+
|
| 1682 |
+
# Clean path for URL
|
| 1683 |
+
if html_path.startswith('/tmp/data_science_agent/'):
|
| 1684 |
+
url_path = html_path.replace('/tmp/data_science_agent/', '')
|
| 1685 |
+
else:
|
| 1686 |
+
url_path = filename
|
| 1687 |
+
|
| 1688 |
+
# Avoid duplicates
|
| 1689 |
+
existing_urls = [p.get("url", "") for p in plots]
|
| 1690 |
+
new_url = f"/outputs/{url_path}"
|
| 1691 |
+
if new_url not in existing_urls:
|
| 1692 |
+
plots.append({
|
| 1693 |
+
"title": plot_title,
|
| 1694 |
+
"path": html_path,
|
| 1695 |
+
"url": new_url,
|
| 1696 |
+
"type": "html"
|
| 1697 |
+
})
|
| 1698 |
+
print(f"[DEBUG] Registered plot from execute_python_code:")
|
| 1699 |
+
print(f"[DEBUG] title: {plot_title}")
|
| 1700 |
+
print(f"[DEBUG] url: {new_url}")
|
| 1701 |
|
| 1702 |
# Build COMPREHENSIVE response template following user's format
|
| 1703 |
summary_lines = []
|