mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 00:53:54 +08:00
Merge branch 'knowledge-base-fix' of https://github.com/xinnan-tech/xiaozhi-esp32-server into Knowledge-Base
This commit is contained in:
@@ -84,11 +84,12 @@ def search_from_ragflow(conn, question=None):
|
|||||||
else:
|
else:
|
||||||
contents.append(str(content))
|
contents.append(str(content))
|
||||||
|
|
||||||
# 构建适合大模型的上下文内容(每段前加编号,段间两个换行)
|
if contents:
|
||||||
context_text = "\n\n".join(
|
# 组织知识库内容为引用模式
|
||||||
f"{i+1}. {c.strip()}" for i, c in enumerate(contents[:5])
|
context_text = f"# 关于问题【{question}】查到知识库如下\n"
|
||||||
)
|
context_text += "```\n\n\n".join(contents[:5])
|
||||||
if not context_text:
|
context_text += "\n```"
|
||||||
|
else:
|
||||||
context_text = "根据知识库查询结果,没有相关信息。"
|
context_text = "根据知识库查询结果,没有相关信息。"
|
||||||
return ActionResponse(Action.REQLLM, context_text, None)
|
return ActionResponse(Action.REQLLM, context_text, None)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user