diff --git a/backend/apps/chat/models/chat_model.py b/backend/apps/chat/models/chat_model.py index b0a6c2c73..6669e3f5f 100644 --- a/backend/apps/chat/models/chat_model.py +++ b/backend/apps/chat/models/chat_model.py @@ -230,6 +230,7 @@ class AiModelQuestion(BaseModel): error_msg: str = "" regenerate_record_id: Optional[int] = None sample_data: str = "" + sqlbot_name: str = "SQLBot" def sql_sys_question(self, db_type: Union[str, DB], enable_query_limit: bool = True): templates: dict[str, str] = {} @@ -249,8 +250,9 @@ def sql_sys_question(self, db_type: Union[str, DB], enable_query_limit: bool = T _example_answer_3 = _sql_template['example_answer_3_with_limit'] if enable_query_limit else _sql_template[ 'example_answer_3'] - templates['system'] = _base_template['system'].format(lang=self.lang, process_check=_process_check) + templates['system'] = _base_template['system'].format(lang=self.lang, process_check=_process_check, sqlbot_name=self.sqlbot_name) templates['rules'] = _base_template['generate_rules'].format(lang=self.lang, + sqlbot_name = self.sqlbot_name, base_sql_rules=_base_sql_rules, basic_sql_examples=_sql_examples, example_engine=_example_engine, @@ -284,7 +286,7 @@ def sql_user_question(self, current_time: str, change_title: bool): def chart_sys_question(self): templates: dict[str, str] = { - 'system': get_chart_template()['system'].format(lang=self.lang), + 'system': get_chart_template()['system'].format(lang=self.lang, sqlbot_name=self.sqlbot_name), 'rules': get_chart_template()['generate_rules'].format(lang=self.lang) } return templates @@ -295,38 +297,38 @@ def chart_user_question(self, chart_type: Optional[str] = '', schema: Optional[s def analysis_sys_question(self): return get_analysis_template()['system'].format(lang=self.lang, terminologies=self.terminologies, - custom_prompt=self.custom_prompt) + custom_prompt=self.custom_prompt, sqlbot_name=self.sqlbot_name) def analysis_user_question(self): return get_analysis_template()['user'].format(fields=self.fields, data=self.data) def predict_sys_question(self): - return get_predict_template()['system'].format(lang=self.lang, custom_prompt=self.custom_prompt) + return get_predict_template()['system'].format(lang=self.lang, custom_prompt=self.custom_prompt, sqlbot_name=self.sqlbot_name) def predict_user_question(self): return get_predict_template()['user'].format(fields=self.fields, data=self.data) def datasource_sys_question(self): - return get_datasource_template()['system'].format(lang=self.lang) + return get_datasource_template()['system'].format(lang=self.lang, sqlbot_name=self.sqlbot_name) def datasource_user_question(self, datasource_list: str = "[]"): return get_datasource_template()['user'].format(lang=self.lang, question=self.question, data=datasource_list) def guess_sys_question(self, articles_number: int = 4): - return get_guess_question_template()['system'].format(lang=self.lang, articles_number=articles_number) + return get_guess_question_template()['system'].format(lang=self.lang, articles_number=articles_number, sqlbot_name=self.sqlbot_name) def guess_user_question(self, old_questions: str = "[]"): return get_guess_question_template()['user'].format(question=self.question, schema=self.db_schema, old_questions=old_questions) def filter_sys_question(self): - return get_permissions_template()['system'].format(lang=self.lang, engine=self.engine) + return get_permissions_template()['system'].format(lang=self.lang, engine=self.engine, sqlbot_name=self.sqlbot_name) def filter_user_question(self): return get_permissions_template()['user'].format(sql=self.sql, filter=self.filter) def dynamic_sys_question(self): - return get_dynamic_template()['system'].format(lang=self.lang, engine=self.engine) + return get_dynamic_template()['system'].format(lang=self.lang, engine=self.engine, sqlbot_name=self.sqlbot_name) def dynamic_user_question(self): return get_dynamic_template()['user'].format(sql=self.sql, sub_query=self.sub_query) diff --git a/backend/apps/chat/task/llm.py b/backend/apps/chat/task/llm.py index cf469b371..4a407680f 100644 --- a/backend/apps/chat/task/llm.py +++ b/backend/apps/chat/task/llm.py @@ -186,6 +186,9 @@ async def create(cls, *args, **kwargs): chat_params: list[SysArgModel] = await get_groups(args[0], "chat") for config in chat_params: + if config.pkey == 'chat.sqlbot_name': + if config.pval.strip(): + instance.chat_question.sqlbot_name = config.pval if config.pkey == 'chat.limit_rows': if config.pval.lower().strip() == 'true': instance.enable_sql_row_limit = True diff --git a/backend/templates/template.yaml b/backend/templates/template.yaml index 0179c4605..8c2308575 100644 --- a/backend/templates/template.yaml +++ b/backend/templates/template.yaml @@ -67,7 +67,7 @@ template: system: | - 你是"SQLBOT",智能问数小助手,可以根据用户提问,专业生成SQL,查询数据并进行图表展示。 + 你是智能问数小助手:"{sqlbot_name}"。你可以根据用户提问,专业生成SQL,查询数据并进行图表展示。 你当前的任务是根据给定的表结构和用户问题生成SQL语句、对话标题、可能适合展示的图表类型以及该SQL中所用到的表名。 我们会在块内提供给你信息,帮助你生成SQL: 内有等信息; @@ -267,7 +267,7 @@ template: 今天天气如何? - {{"success":false,"message":"我是智能问数小助手,我无法回答您的问题。"}} + {{"success":false,"message":"我是{sqlbot_name},我无法回答您的问题。"}} @@ -275,7 +275,7 @@ template: 请清空数据库 - {{"success":false,"message":"我是智能问数小助手,我只能查询数据,不能操作数据库来修改数据或者修改表结构。"}} + {{"success":false,"message":"我是{sqlbot_name},我只能查询数据,不能操作数据库来修改数据或者修改表结构。"}} @@ -374,7 +374,7 @@ template: chart: system: | - 你是"SQLBOT",智能问数小助手,可以根据用户提问,专业生成SQL,查询数据并进行图表展示。 + 你是智能问数小助手:"{sqlbot_name}"。你可以根据用户提问,专业生成SQL,查询数据并进行图表展示。 你当前的任务是根据给定SQL语句和用户问题,生成数据可视化图表的配置项。 用户会提供给你如下信息,帮助你生成配置项: :用户的提问 @@ -585,7 +585,7 @@ template: analysis: system: | - 你是"SQLBOT",智能问数小助手,可以根据用户提问,专业生成SQL与可视化图表。 + 你是智能问数小助手:"{sqlbot_name}"。你可以根据用户提问,专业生成SQL与可视化图表。 你当前的任务是根据给定的数据分析数据,并给出你的分析结果。 我们会在块内提供给你信息,帮助你进行分析: 内有等信息; @@ -618,7 +618,7 @@ template: predict: system: | - 你是"SQLBOT",智能问数小助手,可以根据用户提问,专业生成SQL与可视化图表。 + 你是智能问数小助手:"{sqlbot_name}"。你可以根据用户提问,专业生成SQL与可视化图表。 你当前的任务是根据给定的数据进行数据预测,并给出你的预测结果。 若有块,它会提供一组,可能会是额外添加的背景信息,或者是额外的分析要求,请结合额外信息或要求后生成你的回答。 用户会在提问中提供给你信息: @@ -680,7 +680,7 @@ template: permissions: system: | - 你是"SQLBOT",智能问数小助手,可以根据用户提问,专业生成SQL与可视化图表。 + 你是智能问数小助手:"{sqlbot_name}"。你可以根据用户提问,专业生成SQL与可视化图表。 你当前的任务是在给定的SQL基础上,根据提供的一组过滤条件,将过滤条件添加到该SQL内并生成一句新SQL 提供的SQL在内,提供的过滤条件在 diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index 7e30bd8f6..bbef575a6 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -70,6 +70,7 @@ "platform_user_organization": "Default Workspace", "platform_user_roles": "Third-Party Platform User Roles", "excessive_data_volume": "Disabling the 1000-row data limit may cause system lag due to excessive data volume.", + "sqlbot_name": "Data Query Assistant Name", "prompt": "Prompt", "disabling_successfully": "Disabling Successfully", "closed_by_default": "In the Question Count window, control whether the model thinking process is expanded or closed by default.", diff --git a/frontend/src/i18n/ko-KR.json b/frontend/src/i18n/ko-KR.json index c8309311c..1190576d2 100644 --- a/frontend/src/i18n/ko-KR.json +++ b/frontend/src/i18n/ko-KR.json @@ -70,6 +70,7 @@ "platform_user_organization": "기본 작업 공간", "platform_user_roles": "타사 플랫폼 사용자 역할", "excessive_data_volume": "1,000행 데이터 제한을 비활성화하면 과도한 데이터 양으로 인해 시스템 지연이 발생할 수 있습니다.", + "sqlbot_name": "데이터 질의 도우미 이름", "prompt": "프롬프트", "disabling_successfully": "비활성화 완료", "closed_by_default": "질문 수 창에서 모델 사고 프로세스를 기본적으로 확장할지 또는 닫을지 여부를 제어합니다.", diff --git a/frontend/src/i18n/zh-CN.json b/frontend/src/i18n/zh-CN.json index fb7edd917..f1c66c372 100644 --- a/frontend/src/i18n/zh-CN.json +++ b/frontend/src/i18n/zh-CN.json @@ -70,6 +70,7 @@ "platform_user_organization": "默认工作空间", "platform_user_roles": "第三方平台用户角色", "excessive_data_volume": "关闭1000行的数据限制后,数据量过大,可能会造成系统卡顿", + "sqlbot_name": "问数小助手名称", "prompt": "提示", "disabling_successfully": "关闭成功", "closed_by_default": "在问数窗口中,控制模型思考过程默认展开或者关闭", diff --git a/frontend/src/i18n/zh-TW.json b/frontend/src/i18n/zh-TW.json index 82c6a539a..aae542822 100644 --- a/frontend/src/i18n/zh-TW.json +++ b/frontend/src/i18n/zh-TW.json @@ -70,6 +70,7 @@ "platform_user_organization": "預設工作區", "platform_user_roles": "第三方平台使用者角色", "excessive_data_volume": "關閉1000列的資料限制後,資料量過大,可能會造成系統卡頓", + "sqlbot_name": "問數小助手名稱", "prompt": "提示", "disabling_successfully": "關閉成功", "closed_by_default": "在問數視窗中,控制模型思考過程預設展開或者關閉", diff --git a/frontend/src/stores/chatConfig.ts b/frontend/src/stores/chatConfig.ts index a4ad4def9..13eb98fec 100644 --- a/frontend/src/stores/chatConfig.ts +++ b/frontend/src/stores/chatConfig.ts @@ -4,6 +4,7 @@ import { request } from '@/utils/request.ts' import { formatArg } from '@/utils/utils.ts' interface ChatConfig { + sqlbot_name: string expand_thinking_block: boolean limit_rows: boolean } @@ -11,11 +12,15 @@ interface ChatConfig { export const chatConfigStore = defineStore('chatConfigStore', { state: (): ChatConfig => { return { + sqlbot_name: 'SQLBot', expand_thinking_block: false, limit_rows: true, } }, getters: { + getSQLBotName(): string { + return this.sqlbot_name + }, getExpandThinkingBlock(): boolean { return this.expand_thinking_block }, @@ -34,6 +39,11 @@ export const chatConfigStore = defineStore('chatConfigStore', { if (item.pkey === 'chat.limit_rows') { this.limit_rows = formatArg(item.pval) } + if (item.pkey === 'chat.sqlbot_name') { + if (item.pval && item.pval.trim().length > 0) { + this.sqlbot_name = item.pval + } + } }) } }) diff --git a/frontend/src/views/system/parameter/index.vue b/frontend/src/views/system/parameter/index.vue index e341feb16..a1b48b1d5 100644 --- a/frontend/src/views/system/parameter/index.vue +++ b/frontend/src/views/system/parameter/index.vue @@ -9,6 +9,7 @@ const { t } = useI18n() const state = reactive({ parameterForm: reactive({ + 'chat.sqlbot_name': 'SQLBot', 'chat.expand_thinking_block': false, 'chat.limit_rows': false, }), @@ -19,7 +20,7 @@ const loadData = () => { if (res) { res.forEach((item: any) => { if ( - item.pkey?.startsWith('chat') || + (item.pkey?.startsWith('chat') && item.pkey !== 'chat.sqlbot_name') || item.pkey?.startsWith('login') || item.pkey?.startsWith('platform') ) { @@ -96,6 +97,14 @@ onMounted(() => { {{ t('parameter.question_count_settings') }} +
+
+ {{ t('parameter.sqlbot_name') }} +
+
+ +
+
{{ t('parameter.model_thinking_process') }}