feat: run fixed research pipelines within durable budgets

This commit is contained in:
yuxuanhui
2026-09-08 22:16:05 +08:00
parent eb4850a003
commit 7860434b04
25 changed files with 2357 additions and 37 deletions
+51
View File
@@ -16,6 +16,8 @@ from .workspace_contracts import (
Expansion,
ExperimentPreview,
FeatureConversion,
FlowControl,
FlowStart,
Generation,
ImportCommit,
ImportPreview,
@@ -225,3 +227,52 @@ async def research_lineage(
async with request.app.state.sessions() as db:
return await lineage(db, alpha_id, experiment_id, limit, offset)
@router.get("/flows/recipe")
async def fixed_recipe():
from .workflows import fixed_workflow
return fixed_workflow().model_dump(mode="json")
@router.post("/flows/runs", status_code=201)
async def start_flow(body: FlowStart, request: Request):
from .workflows import Workflows
if body.workflow_id:
raise HTTPException(422, "自定义流程将在 QuantFlow 阶段开放")
async with request.app.state.sessions.begin() as db:
config = await request.app.state.ai.config(db)
result = await Workflows(db).start(body, config.revision)
request.app.state.research.wake.set()
return result
@router.get("/flows/runs")
async def flow_runs(request: Request, limit: int = Query(25, ge=1, le=100), offset: int = Query(0, ge=0)):
from .workflows import Workflows
async with request.app.state.sessions() as db:
return await Workflows(db).list(limit, offset)
@router.get("/flows/runs/{run_id}")
async def flow_run(run_id: str, request: Request):
from .workflows import Workflows
async with request.app.state.sessions() as db:
return await Workflows(db).get(run_id)
@router.post("/flows/runs/{run_id}/control")
async def control_flow(run_id: str, body: FlowControl, request: Request):
from .runtime import control
from .workflows import Workflows
async with request.app.state.sessions.begin() as db:
await control(db, run_id, body)
result = await Workflows(db).get(run_id)
request.app.state.research.wake.set()
request.app.state.runner.backtests.wake.set()
return result