mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-26 04:39:53 +01:00
Merge branch 'knowledge-base-fix' of https://github.com/xinnan-tech/xiaozhi-esp32-server into Knowledge-Base
This commit is contained in:
commit
6de4a29dbf
1 changed files with 6 additions and 5 deletions
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue