mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 13:33:57 +08:00
fix: 优化退出流程并添加超时保护
- 添加 is_exiting 标志防止退出流程被中断 - 工具调用添加 30 秒超时保护,避免流程卡死 - TTS 相关操作添加超时保护 - 优化 OpenAI 客户端超时配置
This commit is contained in:
@@ -17,8 +17,12 @@ class LLMProvider(LLMProviderBase):
|
||||
self.base_url = config.get("base_url")
|
||||
else:
|
||||
self.base_url = config.get("url")
|
||||
timeout = config.get("timeout", 300)
|
||||
self.timeout = int(timeout) if timeout else 300
|
||||
custom_timeout = httpx.Timeout(
|
||||
pool=2.0,
|
||||
connect=3.0,
|
||||
write=5.0,
|
||||
read=10.0
|
||||
)
|
||||
|
||||
param_defaults = {
|
||||
"max_tokens": int,
|
||||
@@ -45,7 +49,7 @@ class LLMProvider(LLMProviderBase):
|
||||
model_key_msg = check_model_key("LLM", self.api_key)
|
||||
if model_key_msg:
|
||||
logger.bind(tag=TAG).error(model_key_msg)
|
||||
self.client = openai.OpenAI(api_key=self.api_key, base_url=self.base_url, timeout=httpx.Timeout(self.timeout))
|
||||
self.client = openai.OpenAI(api_key=self.api_key, base_url=self.base_url, timeout=custom_timeout)
|
||||
|
||||
@staticmethod
|
||||
def normalize_dialogue(dialogue):
|
||||
|
||||
Reference in New Issue
Block a user