fix: execute-stream POST → GET für EventSource
All checks were successful
Deploy Development / deploy (push) Successful in 54s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 16s

Backend:
- prompts.py: @router.post → @router.get für /execute-stream
- EventSource unterstützt nur GET-Requests
- modules/timeframes nutzen Defaults (SSE kann keine komplexen Params)

Fixes:
- "Connection to server lost" bei Analyse-Ausführung

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Lars 2026-04-18 07:07:16 +02:00
parent e9712cef23
commit 1139b00743

View File

@ -1445,12 +1445,10 @@ from prompt_executor import execute_prompt_with_data
from models import UnifiedPromptCreate, UnifiedPromptUpdate from models import UnifiedPromptCreate, UnifiedPromptUpdate
@router.post("/execute-stream") @router.get("/execute-stream")
async def execute_unified_prompt_stream( async def execute_unified_prompt_stream(
prompt_slug: str = Query(..., description="Slug of prompt to execute"), prompt_slug: str = Query(..., description="Slug of prompt to execute"),
token: Optional[str] = Query(None, description="Auth token (temporary solution for SSE)"), token: Optional[str] = Query(None, description="Auth token (temporary solution for SSE)"),
modules: Optional[dict] = None,
timeframes: Optional[dict] = None,
debug: bool = Query(False, description="Include debug information (node_states, etc.)"), debug: bool = Query(False, description="Include debug information (node_states, etc.)"),
save: bool = Query(False, description="Save result to ai_insights") save: bool = Query(False, description="Save result to ai_insights")
): ):
@ -1477,24 +1475,22 @@ async def execute_unified_prompt_stream(
raise HTTPException(401, "Invalid or expired token") raise HTTPException(401, "Invalid or expired token")
profile_id = row['profile_id'] profile_id = row['profile_id']
# Use default modules/timeframes if not provided # Use default modules/timeframes (SSE doesn't support complex params)
if not modules: modules = {
modules = { 'körper': True,
'körper': True, 'ernährung': True,
'ernährung': True, 'training': True,
'training': True, 'schlaf': True,
'schlaf': True, 'vitalwerte': True
'vitalwerte': True }
}
if not timeframes: timeframes = {
timeframes = { 'körper': 30,
'körper': 30, 'ernährung': 30,
'ernährung': 30, 'training': 14,
'training': 14, 'schlaf': 14,
'schlaf': 14, 'vitalwerte': 7
'vitalwerte': 7 }
}
# Wrapper function for OpenRouter calls # Wrapper function for OpenRouter calls
async def workflow_llm_call(prompt: str, model: str = None) -> str: async def workflow_llm_call(prompt: str, model: str = None) -> str: