Implement forced tool selection in AIClient and OpenAIModel, enhancing tool invocation capabilities. Added methods for extracting forced tool names from user messages and updated logging to reflect forced tool usage. Improved error handling for timeout scenarios in message processing.

This commit is contained in:
Mimikko-zeus
2026-03-03 14:14:16 +08:00
parent 00501eb44d
commit 7d7a4b8f54
5 changed files with 343 additions and 4 deletions

View File

@@ -8,6 +8,8 @@ from pathlib import Path
import re
from typing import Any, Dict, Optional
import httpx
from botpy.message import Message
from src.ai import AIClient
@@ -619,6 +621,12 @@ class MessageHandler:
import traceback
logger.error(traceback.format_exc())
if isinstance(exc, (httpx.ReadTimeout, TimeoutError, asyncio.TimeoutError)):
await self._reply_plain(
message,
"模型响应超时,请稍后重试,或将当前模型配置的 timeout 调大(建议 120-180 秒)。",
)
return
await self._reply_plain(message, "消息处理失败,请稍后重试")
async def _handle_skills_command(self, message: Message, command: str):