Унифицировать ответ /api/runs и добавить статусы шагов workflow.

Введен единый JSON-контракт для success/failed с общими полями, добавлен трекинг step status (queued/running/success/failed) и output_summary, а сборка run-ответа централизована через общий helper.
This commit is contained in:
Barabashka
2026-04-22 12:28:08 +03:00
parent 9068b7fe07
commit 93ee7aea1c
4 changed files with 271 additions and 36 deletions
+1 -3
View File
@@ -1,11 +1,9 @@
from fastapi import APIRouter
from pydantic import TypeAdapter
from src.schemas import ScenarioRunRequest, ScenarioRunResponse
from src.workflow_runner import run_scenario_workflow
router = APIRouter(prefix="/api", tags=["workflow"])
_run_response_adapter = TypeAdapter(ScenarioRunResponse)
@router.post("/runs", response_model=ScenarioRunResponse)
@@ -14,4 +12,4 @@ async def run_scenario(request: ScenarioRunRequest) -> ScenarioRunResponse:
input_data=request.input,
scenario_id=request.scenario_id,
)
return _run_response_adapter.validate_python(result)
return ScenarioRunResponse.model_validate(result)