fix: Correct indentation in SSE execute_workflow_async function
Some checks failed
Deploy Development / deploy (push) Successful in 49s
Build Test / pytest-backend (push) Failing after 1s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 17s

This commit is contained in:
Lars 2026-04-13 11:27:44 +02:00
parent fbeabcde97
commit bc60b9f5c9

View File

@ -1526,42 +1526,42 @@ async def execute_unified_prompt_stream(
nonlocal execution_complete nonlocal execution_complete
try: try:
# Execute workflow with progress callbacks # Execute workflow with progress callbacks
result = await execute_prompt_with_data( result = await execute_prompt_with_data(
prompt_slug=prompt_slug, prompt_slug=prompt_slug,
profile_id=profile_id, profile_id=profile_id,
modules=modules, modules=modules,
timeframes=timeframes, timeframes=timeframes,
openrouter_call_func=workflow_llm_call, openrouter_call_func=workflow_llm_call,
enable_debug=debug or save, enable_debug=debug or save,
progress_callback=progress_callback progress_callback=progress_callback
) )
# Save to ai_insights if requested (same logic as /execute) # Save to ai_insights if requested (same logic as /execute)
if save: if save:
if result['type'] == 'pipeline': if result['type'] == 'pipeline':
final_output = result.get('output', {}) final_output = result.get('output', {})
if isinstance(final_output, dict) and len(final_output) == 1: if isinstance(final_output, dict) and len(final_output) == 1:
content = list(final_output.values())[0] content = list(final_output.values())[0]
else:
content = json.dumps(final_output, ensure_ascii=False)
elif result['type'] == 'workflow':
content = _workflow_user_facing_content(result.get('aggregated_result'))
else: else:
content = result.get('output', '') content = json.dumps(final_output, ensure_ascii=False)
if isinstance(content, dict): elif result['type'] == 'workflow':
content = json.dumps(content, ensure_ascii=False) content = _workflow_user_facing_content(result.get('aggregated_result'))
else:
content = result.get('output', '')
if isinstance(content, dict):
content = json.dumps(content, ensure_ascii=False)
# Save to database (minimal metadata for now) # Save to database (minimal metadata for now)
with get_db() as conn: with get_db() as conn:
cur = get_cursor(conn) cur = get_cursor(conn)
cur.execute( cur.execute(
"""INSERT INTO ai_insights (profile_id, scope, content, metadata, created_at) """INSERT INTO ai_insights (profile_id, scope, content, metadata, created_at)
VALUES (%s, %s, %s, %s, NOW())""", VALUES (%s, %s, %s, %s, NOW())""",
(profile_id, prompt_slug, content, json.dumps({"prompt_type": result['type']})) (profile_id, prompt_slug, content, json.dumps({"prompt_type": result['type']}))
) )
conn.commit() conn.commit()
except Exception as e: except Exception as e:
# Queue error event # Queue error event
await event_queue.put({ await event_queue.put({
"type": "execution_failed", "type": "execution_failed",