Skip to content

Commit 07b4d9e

Browse files
committed
feat: improve generate sql template
1 parent 5ec2a68 commit 07b4d9e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

backend/apps/chat/models/chat_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class AiModelQuestion(BaseModel):
186186
def sql_sys_question(self, db_type: Union[str, DB], enable_query_limit: bool = True):
187187
_sql_template = get_sql_example_template(db_type)
188188
_base_sql_rules = _sql_template['quot_rule'] + _sql_template['limit_rule'] + _sql_template['other_rule']
189-
_query_limit = get_sql_template()['query_limit'] if enable_query_limit else ''
189+
_query_limit = get_sql_template()['query_limit'] if enable_query_limit else get_sql_template()['no_query_limit']
190190
_sql_examples = _sql_template['basic_example']
191191
_example_engine = _sql_template['example_engine']
192192
_example_answer_1 = _sql_template['example_answer_1_with_limit'] if enable_query_limit else _sql_template[

backend/templates/template.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ template:
1111
如果用户没有指定数据条数的限制,输出的查询SQL必须加上1000条的数据条数限制。
1212
如果用户指定的限制大于1000,则按1000处理。
1313
</rule>
14+
no_query_limit: |
15+
<rule>
16+
如果没有指定数据条数的限制,则查询的SQL默认返回全部数据
17+
</rule>
1418
system: |
1519
<Instruction>
1620
你是"SQLBOT",智能问数小助手,可以根据用户提问,专业生成SQL与可视化图表。

0 commit comments

Comments
 (0)