refactor: unify data preparations and research input snapshots
Deploy production / deploy (push) Successful in 53s
Deploy production / deploy (push) Successful in 53s
This commit is contained in:
@@ -22,7 +22,7 @@ def research_step(text, returns, history):
|
||||
return "get_backtest_results", {"run_id": run_id}
|
||||
data = content(returns[-1])
|
||||
return f"已读取本次研究的 {data['total']} 条真实保存结果;缺失 Sharpe 仍为未知。"
|
||||
if context.get("unsaved_field_selection") and not context.get("template_input_id"):
|
||||
if context.get("unsaved_field_selection") and not context.get("input_snapshot_id"):
|
||||
return "请先保存字段选择,再点击用此输入研究。"
|
||||
if not returns:
|
||||
return "get_backtest_capabilities", {}
|
||||
@@ -30,39 +30,23 @@ def research_step(text, returns, history):
|
||||
data = content(last)
|
||||
if "error" in data:
|
||||
return f"研究尚未完成:{data['error']}"
|
||||
scope = context.get("catalog_scope") or {
|
||||
"instrument_type": "EQUITY",
|
||||
"region": "USA",
|
||||
"universe": "TOP3000",
|
||||
"delay": 1,
|
||||
}
|
||||
if last.tool_name == "get_backtest_capabilities":
|
||||
if context.get("template_input_id"):
|
||||
if context.get("input_snapshot_id"):
|
||||
return "get_research_input", {
|
||||
"input_id": context["template_input_id"],
|
||||
"input_id": context["input_snapshot_id"],
|
||||
"field_type": "MATRIX",
|
||||
"limit": 1,
|
||||
}
|
||||
return "search_catalog", {"filters": {**scope, "q": "TEST_FIN", "limit": 1}}
|
||||
if last.tool_name == "search_catalog":
|
||||
if data["dataset_id"] is None:
|
||||
return "search_catalog", {
|
||||
"dataset_id": data["items"][0]["id"],
|
||||
"filters": {**scope, "field_type": "MATRIX", "limit": 1},
|
||||
}
|
||||
return "prepare_research_input", {
|
||||
"scope": scope,
|
||||
"dataset_id": data["dataset_id"],
|
||||
"collection_version": data["collection_version"],
|
||||
"field_ids": [data["items"][0]["id"]],
|
||||
}
|
||||
return "search_data_preparations", {"limit": 1}
|
||||
if last.tool_name == "search_data_preparations":
|
||||
return "prepare_research_input", {"items": [{"id": data["items"][0]["id"], "version": data["items"][0]["version"]}]}
|
||||
if last.tool_name in ("get_research_input", "prepare_research_input"):
|
||||
field = data["items"][0]
|
||||
field = next(f for f in data["items"] if f["field_type"] == "MATRIX")
|
||||
saved_scope = data["scope"]
|
||||
return "prepare_research_backtest", {
|
||||
"name": "Chatbox 数据集研究",
|
||||
"hypothesis": "验证所选合成字段的横截面排序信号",
|
||||
"template_input_id": data["id"],
|
||||
"input_snapshot_id": data["id"],
|
||||
"candidates": [
|
||||
{
|
||||
"client_item_id": "research-1",
|
||||
|
||||
Reference in New Issue
Block a user