新增cdsl
This commit is contained in:
@@ -127,6 +127,30 @@ async def read_task(task_id: str) -> JSONResponse:
|
||||
return JSONResponse(task)
|
||||
|
||||
|
||||
@app.get("/v1/tasks/{task_id}/design-intent")
|
||||
async def read_current_design_intent(task_id: str) -> JSONResponse:
|
||||
try:
|
||||
safe_id = safe_task_id(task_id)
|
||||
result = store.read_design_intent(safe_id)
|
||||
except ValueError as error:
|
||||
raise HTTPException(status_code=400, detail=str(error)) from error
|
||||
if result is None:
|
||||
raise HTTPException(status_code=404, detail="No DesignIntent exists for this task")
|
||||
return JSONResponse({"task_id": safe_id, "intent_id": result["record"]["intent_id"], **result})
|
||||
|
||||
|
||||
@app.get("/v1/tasks/{task_id}/design-intents/{intent_id}")
|
||||
async def read_design_intent(task_id: str, intent_id: str) -> JSONResponse:
|
||||
try:
|
||||
safe_id = safe_task_id(task_id)
|
||||
result = store.read_design_intent(safe_id, intent_id)
|
||||
except ValueError as error:
|
||||
raise HTTPException(status_code=400, detail=str(error)) from error
|
||||
if result is None:
|
||||
raise HTTPException(status_code=404, detail="DesignIntent not found")
|
||||
return JSONResponse({"task_id": safe_id, "intent_id": result["record"]["intent_id"], **result})
|
||||
|
||||
|
||||
@app.get("/v1/tasks/{task_id}/artifacts/{artifact_path:path}")
|
||||
async def read_artifact(task_id: str, artifact_path: str) -> StreamingResponse:
|
||||
from fastapi.responses import FileResponse
|
||||
@@ -165,6 +189,10 @@ async def update_parameters(task_id: str, payload: ParameterUpdate) -> JSONRespo
|
||||
safe_id = safe_task_id(task_id)
|
||||
task = store.read_task(safe_id)
|
||||
current_revision_id = str((task or {}).get("current_revision") or "")
|
||||
current_revision = next(
|
||||
(item for item in (task or {}).get("revisions", []) if item.get("revision_id") == current_revision_id),
|
||||
{},
|
||||
)
|
||||
current_path = store.current_cdsl_path(safe_id)
|
||||
if not task or not current_path or not current_revision_id:
|
||||
raise ValueError("Task has no successful CDSL revision")
|
||||
@@ -179,6 +207,11 @@ async def update_parameters(task_id: str, payload: ParameterUpdate) -> JSONRespo
|
||||
summary="Updated CDSL parameters",
|
||||
parent_revision_id=current_revision_id,
|
||||
operation={"type": "parameter_update", "values": payload.values},
|
||||
part_skills=None,
|
||||
generation_assumptions=[],
|
||||
design_intent_id=str(current_revision.get("design_intent_id") or ""),
|
||||
design_intent_path=str(current_revision.get("design_intent_path") or ""),
|
||||
design_intent_status="accepted" if current_revision.get("design_intent_id") else "",
|
||||
)
|
||||
return JSONResponse(result)
|
||||
except ValueError as error:
|
||||
|
||||
Reference in New Issue
Block a user