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 handling and model interactions, ensuring better user feedback and robustness.

This commit is contained in:
Mimikko-zeus
2026-03-03 14:25:21 +08:00
parent 7d7a4b8f54
commit 4a2666b1f2
5 changed files with 114 additions and 20 deletions

View File

@@ -37,3 +37,9 @@ def test_extract_forced_tool_name_ambiguous_prefix_returns_none():
forced = AIClient._extract_forced_tool_name(message, tools)
assert forced is None
def test_extract_prefix_limit_from_user_message():
assert AIClient._extract_prefix_limit("直接返回前100字") == 100
assert AIClient._extract_prefix_limit("前 256 字") == 256
assert AIClient._extract_prefix_limit("返回全文") is None