Унифицировать ответ /api/runs и добавить статусы шагов workflow.
Введен единый JSON-контракт для success/failed с общими полями, добавлен трекинг step status (queued/running/success/failed) и output_summary, а сборка run-ответа централизована через общий helper.
This commit is contained in:
+1
-3
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user