fix(chat_db_qa): tell LLM the table list is a TOP-K subset, not the full DB (#3045)

Co-authored-by: hankchrome <hankchrome@github.com>
This commit is contained in:
hankchorome
2026-05-13 11:42:39 +08:00
committed by GitHub
parent 8a4940ded8
commit fa1a8d2f70

View File

@@ -18,6 +18,16 @@ available to answer this question." Feel free to fudge information.
Use the following tables generate sql if have any table info:
{table_info}
NOTE: this is a QA-only scene; you cannot execute SQL here. The table list \
above contains only the TOP-K most relevant tables retrieved from a vector \
store; it is NOT the complete list of tables in the database. If the user \
asks for a total count of tables, a list of all tables, a schema overview, \
or any other metadata that requires knowing the whole database, do NOT \
answer with a count or list derived from the partial table list above. \
Instead, acknowledge the limitation and show the SQL query against \
INFORMATION_SCHEMA (or the dialect-specific system catalog) that the user \
can run in a SQL-executing scene to obtain the answer.
user question:
{input}
think step by step.
@@ -27,9 +37,16 @@ _DEFAULT_TEMPLATE_ZH = """
根据要求和问题,提供专业的答案。如果无法从提供的内容中获取答案,请说:\
“知识库中提供的信息不足以回答此问题。” 禁止随意捏造信息。
使用以下表结构信息:
使用以下表结构信息:
{table_info}
注意这是只问答QA场景无法在此处执行 SQL。以上表清单只是从向量库\
检索到的 TOP-K 最相关表,并非数据库中所有表的完整清单。当用户询问表的\
总数、所有表的列表、schema 结构总览,或其他需要了解整个数据库元信息的\
问题时,请勿根据以上部分表清单直接给出数量或列表。请说明此限制,并展示\
可在「可执行 SQL」场景中运行、针对 INFORMATION_SCHEMA或方言对应的系统\
目录)的 SQL 查询,以便用户取得正确答案。
问题:
{input}
一步步思考。