优化代码

This commit is contained in:
2025-07-18 16:50:24 +08:00
parent 5d5c3c0257
commit 6ba3141885
4 changed files with 223 additions and 1038 deletions
+5 -1
View File
@@ -240,11 +240,15 @@ class OpenAiLLM:
self._kwargs = kwargs
def invoke(self, user_prompt="你是谁?", need_retry=True):
def invoke(self, user_prompt="你是谁?", need_retry=True,**extra_kwargs):
# 初始化 OpenAI 客户端
max_retries = 3
retry_count = 0
# 合并额外的kwargs与self._kwargs
kwargs = {**self._kwargs}
if extra_kwargs:
kwargs.update(extra_kwargs)
if "timeout" not in self._kwargs:
timeout = httpx.Timeout(300.0)
self._kwargs["timeout"] = timeout