From b0e9de69512293701f89720236b7d369137ff74a Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sat, 8 Feb 2025 12:58:54 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=A2=9E=E5=8A=A0DIFY=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E6=97=B6=E9=97=B4=20#422?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/config/default.py | 1 + astrbot/core/provider/sources/dify_source.py | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index 50000bdd8..4dc1ebd11 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -435,6 +435,7 @@ CONFIG_METADATA_2 = { "dify_api_key": "", "dify_api_base": "https://api.dify.ai/v1", "dify_workflow_output_key": "", + "timeout": 60, }, "whisper(API)": { "id": "whisper", diff --git a/astrbot/core/provider/sources/dify_source.py b/astrbot/core/provider/sources/dify_source.py index db10bcc67..6f946871a 100644 --- a/astrbot/core/provider/sources/dify_source.py +++ b/astrbot/core/provider/sources/dify_source.py @@ -31,7 +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.timeout = provider_config.get("timeout", 120) + if isinstance(self.timeout, str): + self.timeout = int(self.timeout) self.conversation_ids = {} @@ -78,7 +80,8 @@ class ProviderDify(Provider): query=prompt, user=session_id, conversation_id=conversation_id, - files=files_payload + files=files_payload, + timeout=self.timeout ): logger.debug(f"dify resp chunk: {chunk}") if chunk['event'] == "message" or \ @@ -96,7 +99,8 @@ class ProviderDify(Provider): **session_var }, user=session_id, - files=files_payload + files=files_payload, + timeout=self.timeout ): match chunk['event']: case "workflow_started":