remove same chart_description for more than 1 time
Browse files
python_code_executor_service.py
CHANGED
|
@@ -342,7 +342,7 @@ class PythonExecutor:
|
|
| 342 |
output_parts.append(f"\n**Error:** Error processing analysis operation: {str(e)}")
|
| 343 |
if hasattr(operation, 'result_var'):
|
| 344 |
output_parts.append(f"Expected variables: {operation.result_var}")
|
| 345 |
-
|
| 346 |
# Process chart if it exists
|
| 347 |
if response.charts is not None:
|
| 348 |
chart = response.charts
|
|
@@ -351,6 +351,11 @@ class PythonExecutor:
|
|
| 351 |
if chart.code:
|
| 352 |
chart_result = self.execute_code(chart.code)
|
| 353 |
if chart_result.get('plots'):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 354 |
for i, plot_data in enumerate(chart_result['plots']):
|
| 355 |
try:
|
| 356 |
public_url = await self.save_plot_to_supabase(
|
|
@@ -358,7 +363,6 @@ class PythonExecutor:
|
|
| 358 |
description=chart.image_description,
|
| 359 |
chat_id=chat_id
|
| 360 |
)
|
| 361 |
-
output_parts.append(f"\n**Chart:** {chart.image_description}")
|
| 362 |
output_parts.append(f"")
|
| 363 |
except Exception as e:
|
| 364 |
output_parts.append(f"\n**Warning:** Error uploading chart {i+1}: {str(e)}")
|
|
|
|
| 342 |
output_parts.append(f"\n**Error:** Error processing analysis operation: {str(e)}")
|
| 343 |
if hasattr(operation, 'result_var'):
|
| 344 |
output_parts.append(f"Expected variables: {operation.result_var}")
|
| 345 |
+
|
| 346 |
# Process chart if it exists
|
| 347 |
if response.charts is not None:
|
| 348 |
chart = response.charts
|
|
|
|
| 351 |
if chart.code:
|
| 352 |
chart_result = self.execute_code(chart.code)
|
| 353 |
if chart_result.get('plots'):
|
| 354 |
+
# Only add the description header once before all charts
|
| 355 |
+
if chart.image_description:
|
| 356 |
+
output_parts.append(f"\n**Chart:** {chart.image_description}")
|
| 357 |
+
|
| 358 |
+
# Then add all chart images without repeating the description
|
| 359 |
for i, plot_data in enumerate(chart_result['plots']):
|
| 360 |
try:
|
| 361 |
public_url = await self.save_plot_to_supabase(
|
|
|
|
| 363 |
description=chart.image_description,
|
| 364 |
chat_id=chat_id
|
| 365 |
)
|
|
|
|
| 366 |
output_parts.append(f"")
|
| 367 |
except Exception as e:
|
| 368 |
output_parts.append(f"\n**Warning:** Error uploading chart {i+1}: {str(e)}")
|