From d9ecf8cc9c05da023790b6221fb30946f4f6a4e8 Mon Sep 17 00:00:00 2001 From: zhangzhanwei Date: Thu, 27 Nov 2025 18:18:50 +0800 Subject: [PATCH] fix: Generate prompt --- apps/chat/serializers/chat.py | 6 +----- apps/chat/template/generate_prompt_system | 2 -- ui/src/views/application/component/GeneratePromptDialog.vue | 4 +--- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/apps/chat/serializers/chat.py b/apps/chat/serializers/chat.py index 28e361292..69c6bf07c 100644 --- a/apps/chat/serializers/chat.py +++ b/apps/chat/serializers/chat.py @@ -173,8 +173,6 @@ class PromptGenerateSerializer(serializers.Serializer): message = messages[-1]['content'] q = prompt.replace("{userInput}", message) - q = q.replace("{application_name}", application.name) - q = q.replace("{detail}", application.desc) messages[-1]['content'] = q SUPPORTED_MODEL_TYPES = ["LLM", "IMAGE"] @@ -185,13 +183,11 @@ class PromptGenerateSerializer(serializers.Serializer): if not model_exist: raise Exception(_("Model does not exists or is not an LLM model")) - system_content = SYSTEM_ROLE.format(application_name=application.name, detail=application.desc) - def process(): model = get_model_instance_by_model_workspace_id(model_id=model_id, workspace_id=workspace_id, **application.model_params_setting) try: - for r in model.stream([SystemMessage(content=system_content), + for r in model.stream([SystemMessage(content=SYSTEM_ROLE), *[HumanMessage(content=m.get('content')) if m.get( 'role') == 'user' else AIMessage( content=m.get('content')) for m in messages]]): diff --git a/apps/chat/template/generate_prompt_system b/apps/chat/template/generate_prompt_system index 805f2e4da..3666d9228 100644 --- a/apps/chat/template/generate_prompt_system +++ b/apps/chat/template/generate_prompt_system @@ -62,5 +62,3 @@ 输出时不得包含任何解释或附加说明,只能返回符合以上格式的内容。 -智能体名称: {application_name} -功能描述: {detail} \ No newline at end of file diff --git a/ui/src/views/application/component/GeneratePromptDialog.vue b/ui/src/views/application/component/GeneratePromptDialog.vue index b63db1844..117ff5916 100644 --- a/ui/src/views/application/component/GeneratePromptDialog.vue +++ b/ui/src/views/application/component/GeneratePromptDialog.vue @@ -131,12 +131,10 @@ const promptTemplates = { INIT_TEMPLATE: ` 请根据用户描述生成一个完整的AI角色人设模板: -应用名称:{application_name} -应用描述:{detail} 用户需求:{userInput} 重要说明: -1. 角色设定必须服务于"{application_name}"应用的核心功能 +1. 角色设定必须服务于"{userInput}"内容设定应用的核心功能 2. 允许用户对角色设定的具体内容进行调整和优化 3. 如果用户要求修改某个技能或部分,在保持应用主题的前提下进行相应调整