Spaces:
Running
Running
Pulastya B commited on
Commit Β·
1c52933
1
Parent(s): b2a95b5
Fixing the issues with the SSE streaming all the history
Browse files- Server Logs.txt +0 -250
- src/api/app.py +9 -5
Server Logs.txt
DELETED
|
@@ -1,250 +0,0 @@
|
|
| 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/api/app.py
CHANGED
|
@@ -383,11 +383,10 @@ async def stream_progress(session_id: str):
|
|
| 383 |
print(f"[SSE] SENDING connection event to client")
|
| 384 |
yield f"data: {safe_json_dumps(connection_event)}\n\n"
|
| 385 |
|
| 386 |
-
#
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
yield f"data: {safe_json_dumps(event)}\n\n"
|
| 391 |
|
| 392 |
print(f"[SSE] Starting event stream loop for session {session_id}")
|
| 393 |
|
|
@@ -461,6 +460,11 @@ def run_analysis_background(file_path: str, task_description: str, target_col: O
|
|
| 461 |
try:
|
| 462 |
logger.info(f"[BACKGROUND] Starting analysis for session {session_id[:8]}...")
|
| 463 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 464 |
# π₯ Get isolated agent for this session
|
| 465 |
session_agent = await get_agent_for_session(session_id)
|
| 466 |
|
|
|
|
| 383 |
print(f"[SSE] SENDING connection event to client")
|
| 384 |
yield f"data: {safe_json_dumps(connection_event)}\n\n"
|
| 385 |
|
| 386 |
+
# β DON'T replay history - causes duplicate results when reconnecting
|
| 387 |
+
# Each new query should only show events from that query, not previous ones
|
| 388 |
+
# History is only useful for debugging, not for client display
|
| 389 |
+
print(f"[SSE] Skipping history replay (follow-up query should show fresh events)")
|
|
|
|
| 390 |
|
| 391 |
print(f"[SSE] Starting event stream loop for session {session_id}")
|
| 392 |
|
|
|
|
| 460 |
try:
|
| 461 |
logger.info(f"[BACKGROUND] Starting analysis for session {session_id[:8]}...")
|
| 462 |
|
| 463 |
+
# π§Ή Clear SSE history for fresh event stream (prevents duplicate results)
|
| 464 |
+
print(f"[π§Ή] Clearing SSE history for {session_id[:8]}...")
|
| 465 |
+
if session_id in progress_manager._history:
|
| 466 |
+
progress_manager._history[session_id] = []
|
| 467 |
+
|
| 468 |
# π₯ Get isolated agent for this session
|
| 469 |
session_agent = await get_agent_for_session(session_id)
|
| 470 |
|