From a4bfa965024c8ea2f13e604c999019dd0ee40c0a Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Fri, 14 Feb 2025 15:41:02 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=94=AF=E6=8C=81=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=20Dify=20=E5=B7=A5=E4=BD=9C=E6=B5=81?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E8=BE=93=E5=85=A5=E5=8F=98=E9=87=8F=E5=90=8D?= =?UTF-8?q?=20#441?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/config/default.py | 7 +++++++ astrbot/core/provider/sources/dify_source.py | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index 2f055f05f..17ee27949 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -496,6 +496,7 @@ CONFIG_METADATA_2 = { "dify_api_key": "", "dify_api_base": "https://api.dify.ai/v1", "dify_workflow_output_key": "", + "dify_query_input_key": "astrbot_text_query", "timeout": 60, }, "whisper(API)": { @@ -647,6 +648,12 @@ CONFIG_METADATA_2 = { "type": "string", "hint": "Dify Workflow 输出变量名。当应用类型为 workflow 时才使用。默认为 astrbot_wf_output。", }, + "dify_query_input_key": { + "description": "Prompt 输入变量名", + "type": "string", + "hint": "发送的消息文本内容对应的输入变量名。默认为 astrbot_text_query。", + "obvious": True, + } }, }, "provider_settings": { diff --git a/astrbot/core/provider/sources/dify_source.py b/astrbot/core/provider/sources/dify_source.py index 4e8e3e851..33c53e218 100644 --- a/astrbot/core/provider/sources/dify_source.py +++ b/astrbot/core/provider/sources/dify_source.py @@ -31,6 +31,9 @@ class ProviderDify(Provider): raise Exception("Dify API 类型不能为空。") self.model_name = "dify" self.workflow_output_key = provider_config.get("dify_workflow_output_key", "astrbot_wf_output") + self.dify_query_input_key = provider_config.get("dify_query_input_key", "astrbot_text_query") + if not self.dify_query_input_key: + self.dify_query_input_key = "astrbot_text_query" self.timeout = provider_config.get("timeout", 120) if isinstance(self.timeout, str): self.timeout = int(self.timeout) @@ -95,7 +98,7 @@ class ProviderDify(Provider): case "workflow": async for chunk in self.api_client.workflow_run( inputs={ - "astrbot_text_query": prompt, + self.dify_query_input_key: prompt, "astrbot_session_id": session_id, **session_var },