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:
@@ -313,9 +313,9 @@ def test_openai_model_falls_back_to_functions_for_legacy_sdk(monkeypatch):
|
||||
sent = model.client.completions.last_params
|
||||
assert model._supports_tools is False
|
||||
assert model._supports_functions is True
|
||||
assert sent["function_call"] == "auto"
|
||||
assert isinstance(sent["functions"], list) and sent["functions"]
|
||||
assert sent["functions"][0]["name"] == "demo_tool"
|
||||
assert sent["tools"] == tools
|
||||
assert sent["function_call"] is None
|
||||
assert sent["functions"] is None
|
||||
assert result.tool_calls is not None
|
||||
assert result.tool_calls[0]["function"]["name"] == "demo_tool"
|
||||
|
||||
@@ -334,7 +334,8 @@ def test_openai_model_forces_function_call_for_legacy_sdk(monkeypatch):
|
||||
)
|
||||
|
||||
sent = model.client.completions.last_params
|
||||
assert sent["function_call"] == {"name": "demo_tool"}
|
||||
assert sent["tool_choice"]["type"] == "function"
|
||||
assert sent["tool_choice"]["function"]["name"] == "demo_tool"
|
||||
|
||||
|
||||
def test_openai_model_formats_tool_messages_for_legacy_sdk(monkeypatch):
|
||||
|
||||
Reference in New Issue
Block a user