feat(studio): R3 step_respond、运行页 UX 与 R4 思考流式

新增 worldbook 步骤 LLM 回复(thinking/draft/questions/evaluation),
运行页聊天区与产物/选项联动;评价区标签改为「评价与修改建议」;
流式开关开启时 NDJSON 推送思考内容,完成后拆分更新各字段。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-31 22:07:42 +08:00
parent fa6907fb8d
commit f3792915a3
20 changed files with 1639 additions and 304 deletions

View File

@@ -1,13 +1,16 @@
import json
import logging
from typing import Any, Dict, List
from fastapi import APIRouter, HTTPException
from fastapi.responses import StreamingResponse
from models.studio_models import (
AdvanceRunRequest,
CreateStudioProjectRequest,
PipelineDefinition,
RenameRunRequest,
RunMessageRequest,
StudioProject,
StudioProjectSummary,
StudioRun,
@@ -186,6 +189,66 @@ async def advance_studio_run(
raise HTTPException(status_code=500, detail=str(e))
@router.post("/projects/{project_id}/runs/{run_id}/message")
async def send_studio_run_message(
project_id: str, run_id: str, req: RunMessageRequest
):
if req.stream:
async def ndjson_stream():
try:
async for event in studio_run_service.send_run_message_stream(
project_id,
run_id,
req.content,
profile_id=req.profileId,
api_config=req.apiConfig,
):
yield json.dumps(event, ensure_ascii=False) + "\n"
except FileNotFoundError as e:
yield json.dumps(
{"type": "error", "detail": str(e)}, ensure_ascii=False
) + "\n"
except ValueError as e:
yield json.dumps(
{"type": "error", "detail": str(e)}, ensure_ascii=False
) + "\n"
except Exception as e:
logger.error(
"Failed to stream studio run message %s/%s: %s",
project_id,
run_id,
e,
)
yield json.dumps(
{"type": "error", "detail": f"消息处理失败:{e}"},
ensure_ascii=False,
) + "\n"
return StreamingResponse(
ndjson_stream(),
media_type="application/x-ndjson",
)
try:
return await studio_run_service.send_run_message(
project_id,
run_id,
req.content,
stream=req.stream,
profile_id=req.profileId,
api_config=req.apiConfig,
)
except FileNotFoundError as e:
raise HTTPException(status_code=404, detail=str(e))
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
except Exception as e:
logger.error(
"Failed to send studio run message %s/%s: %s", project_id, run_id, e
)
raise HTTPException(status_code=500, detail=f"消息处理失败:{e}")
@router.delete("/projects/{project_id}/runs/{run_id}")
async def delete_studio_run(project_id: str, run_id: str):
try: