更新DifyQueryRetrieval类的初始化参数,改为使用环境变量获取API密钥和基础URL;优化意图识别示例中的参数传递;调整问题和回答的格式描述;增加请求超时设置。

This commit is contained in:
2025-07-17 09:05:05 +08:00
parent 8a58fef1a7
commit bd0f86ff61
6 changed files with 33 additions and 25 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ class DifyClient:
self.api_key = api_key
self.base_url = base_url
def _send_request(self, method, endpoint, json=None, params=None, stream=False):
def _send_request(self, method, endpoint, json=None, params=None, stream=False, timeout=300):
headers = {
"Authorization": f"Bearer {self.api_key}",
"Content-Type": "application/json",
@@ -16,7 +16,7 @@ class DifyClient:
url = f"{self.base_url}{endpoint}"
response = requests.request(
method, url, json=json, params=params, headers=headers, stream=stream, verify=False
method, url, json=json, params=params, headers=headers, stream=stream, verify=False, timeout=timeout
)
return response