mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 17:13:54 +08:00
refactor: 优化超时配置,响应社区反馈
- 工具调用超时改为可配置项 tool_call_timeout,默认30秒 - OpenAI 超时恢复可配置机制,支持细粒度配置和单一值 - TTS 超时保护统一添加到所有流式TTS实现 - 将 ActionResponse 导入移到文件顶部 - 修复超时配置边界情况处理
This commit is contained in:
@@ -150,8 +150,8 @@ async def process_intent_result(
|
||||
def process_function_call():
|
||||
conn.dialogue.put(Message(role="user", content=original_text))
|
||||
|
||||
# 使用统一工具处理器处理所有工具调用,添加超时保护
|
||||
TOOL_CALL_TIMEOUT = 30
|
||||
# 工具调用超时时间
|
||||
tool_call_timeout = int(conn.config.get("tool_call_timeout", 30))
|
||||
# 使用统一工具处理器处理所有工具调用
|
||||
try:
|
||||
result = asyncio.run_coroutine_threadsafe(
|
||||
@@ -159,7 +159,7 @@ async def process_intent_result(
|
||||
conn, function_call_data
|
||||
),
|
||||
conn.loop,
|
||||
).result(timeout=TOOL_CALL_TIMEOUT)
|
||||
).result(timeout=tool_call_timeout)
|
||||
except Exception as e:
|
||||
conn.logger.bind(tag=TAG).error(f"工具调用失败: {e}")
|
||||
result = ActionResponse(
|
||||
|
||||
Reference in New Issue
Block a user