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:
39
tests/test_ai_client_forced_tool.py
Normal file
39
tests/test_ai_client_forced_tool.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""Tests for AIClient forced tool name extraction."""
|
||||
|
||||
from src.ai.client import AIClient
|
||||
|
||||
|
||||
def test_extract_forced_tool_name_full_name():
|
||||
tools = [
|
||||
"humanizer_zh.read_skill_doc",
|
||||
"skills_creator.create_skill",
|
||||
]
|
||||
message = "please call tool humanizer_zh.read_skill_doc and return first 100 chars"
|
||||
|
||||
forced = AIClient._extract_forced_tool_name(message, tools)
|
||||
|
||||
assert forced == "humanizer_zh.read_skill_doc"
|
||||
|
||||
|
||||
def test_extract_forced_tool_name_unique_prefix():
|
||||
tools = [
|
||||
"humanizer_zh.read_skill_doc",
|
||||
"skills_creator.create_skill",
|
||||
]
|
||||
message = "please call tool humanizer_zh only"
|
||||
|
||||
forced = AIClient._extract_forced_tool_name(message, tools)
|
||||
|
||||
assert forced == "humanizer_zh.read_skill_doc"
|
||||
|
||||
|
||||
def test_extract_forced_tool_name_ambiguous_prefix_returns_none():
|
||||
tools = [
|
||||
"skills_creator.create_skill",
|
||||
"skills_creator.reload_skill",
|
||||
]
|
||||
message = "please call tool skills_creator"
|
||||
|
||||
forced = AIClient._extract_forced_tool_name(message, tools)
|
||||
|
||||
assert forced is None
|
||||
Reference in New Issue
Block a user