feat: add durable WorldQuant backtests with UI and AI confirmation
This commit is contained in:
@@ -17,6 +17,23 @@ async def fake_stream(messages, info):
|
||||
str(p.content) for m in messages[latest:] for p in m.parts if isinstance(p, UserPromptPart)
|
||||
)
|
||||
returns = [p for m in messages[latest:] for p in m.parts if isinstance(p, ToolReturnPart)]
|
||||
if returns and returns[-1].tool_name == "prepare_backtest":
|
||||
content = returns[-1].content
|
||||
content = json.loads(content) if isinstance(content, str) else content
|
||||
yield {
|
||||
0: DeltaToolCall(
|
||||
name="start_backtest",
|
||||
json_args=json.dumps(
|
||||
{
|
||||
"preview_id": content["preview_id"],
|
||||
"version": 1,
|
||||
"idempotency_key": content["preview_id"],
|
||||
}
|
||||
),
|
||||
tool_call_id=uuid4().hex,
|
||||
)
|
||||
}
|
||||
return
|
||||
if returns and "LOOP" not in text:
|
||||
if returns[-1].tool_name == "capability_probe":
|
||||
yield str(returns[-1].content)
|
||||
@@ -35,6 +52,23 @@ async def fake_stream(messages, info):
|
||||
await asyncio.sleep(2)
|
||||
yield ",查询完成。"
|
||||
return
|
||||
elif "回测" in text:
|
||||
name, args = (
|
||||
"prepare_backtest",
|
||||
{
|
||||
"inline": {
|
||||
"name": "AI 固定回测",
|
||||
"source": {"kind": "ai"},
|
||||
"candidates": [
|
||||
{
|
||||
"client_item_id": "ai-1",
|
||||
"expression": "rank(close)",
|
||||
"settings": {"region": "USA", "universe": "TOP3000", "delay": 1},
|
||||
}
|
||||
],
|
||||
}
|
||||
},
|
||||
)
|
||||
elif "批量" in text:
|
||||
name, args = "bulk_update_research", {"alpha_ids": ["a0000", "a0001"], "add_tags": ["AI"]}
|
||||
elif "修改" in text or "update" in text:
|
||||
|
||||
Reference in New Issue
Block a user