feat: refine ai writing search flow
This commit is contained in:
1 parent
025e43f4c5
commit
d21dbeb214
15 files changed
+260
-113
No files matched your search
+16
-4
@@ -58,6 +58,16 @@ async def pause_material_confirm(state: AIWritingState) -> dict:
|
||||
|
||||
# 单输入框文本:可能是技能名 / 来源 / 检索意图,re_search 和 enable_skill_search 都用得到
|
||||
user_query = (user_input.get("userQuery") or user_input.get("user_query") or "").strip()
|
||||
requested_source = user_input.get("materialSource") or user_input.get("material_source")
|
||||
fallback_source = state.get("material_source") or "general"
|
||||
material_source = requested_source if requested_source in ("general", "knowledge_base", "notebook") else fallback_source
|
||||
if material_source not in ("general", "knowledge_base", "notebook"):
|
||||
material_source = "general"
|
||||
source_label = {
|
||||
"general": "通用检索",
|
||||
"knowledge_base": "知识库检索",
|
||||
"notebook": "我的空间",
|
||||
}.get(material_source, "通用检索")
|
||||
|
||||
if action == "confirm":
|
||||
approved_ids = set(user_input.get("approvedMaterialIds") or [m["id"] for m in pkg["materials"]])
|
||||
@@ -84,9 +94,10 @@ async def pause_material_confirm(state: AIWritingState) -> dict:
|
||||
# enable_skill_search:旧版「启用技能检索」按钮的兼容入口——通用检索现在
|
||||
# 本来就按 agent 配置技能编排,researcher 把它按 user_query 追加检索处理
|
||||
if action == "enable_skill_search":
|
||||
msg = f"按输入「{user_query[:30]}」匹配技能检索并追加素材…" if user_query else "重新检索中…"
|
||||
msg = f"按输入「{user_query[:30]}」使用{source_label}追加素材…" if user_query else f"使用{source_label}重新检索中…"
|
||||
return {
|
||||
"last_user_intervention": {**user_input, "action": "enable_skill_search", "user_query": user_query},
|
||||
"last_user_intervention": {**user_input, "action": "enable_skill_search", "user_query": user_query, "material_source": material_source},
|
||||
"material_source": material_source,
|
||||
"status": "researching",
|
||||
"progress_events": [{"type": "resumed", "agent_name": "系统", "message": msg}],
|
||||
}
|
||||
@@ -94,9 +105,10 @@ async def pause_material_confirm(state: AIWritingState) -> dict:
|
||||
# re_search:带 user_query = 在配置技能中匹配检索并**追加**素材;
|
||||
# 不带输入 = 重新生成检索词、覆盖式重检(兼容旧版 extraKeywords 数组追加)
|
||||
extra_kws = user_input.get("extraKeywords") or []
|
||||
msg = f"按输入「{user_query[:30]}」匹配技能检索并追加素材…" if user_query else "重新搜索中..."
|
||||
msg = f"按输入「{user_query[:30]}」使用{source_label}追加素材…" if user_query else f"使用{source_label}重新搜索中..."
|
||||
return {
|
||||
"last_user_intervention": {**user_input, "_extra_keywords": extra_kws, "user_query": user_query},
|
||||
"last_user_intervention": {**user_input, "_extra_keywords": extra_kws, "user_query": user_query, "material_source": material_source},
|
||||
"material_source": material_source,
|
||||
"status": "researching",
|
||||
"progress_events": [{"type": "resumed", "agent_name": "系统", "message": msg}],
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user