Add parameter schema and defaults to ToolResource model and schemas. Implement runtime tool resolution in assistants and tools routers, ensuring proper handling of tool parameters. Update tests to validate new functionality and ensure correct integration of parameter handling in the API.
This commit is contained in:
@@ -243,6 +243,26 @@ class TestAssistantAPI:
|
||||
assert payload["sessionStartMetadata"]["systemPrompt"] == sample_assistant_data["prompt"]
|
||||
assert payload["sessionStartMetadata"]["history"]["assistantId"] == assistant_id
|
||||
|
||||
def test_runtime_config_resolves_selected_tools_into_runtime_definitions(self, client, sample_assistant_data):
|
||||
sample_assistant_data["tools"] = ["increase_volume", "calculator"]
|
||||
assistant_resp = client.post("/api/assistants", json=sample_assistant_data)
|
||||
assert assistant_resp.status_code == 200
|
||||
assistant_id = assistant_resp.json()["id"]
|
||||
|
||||
runtime_resp = client.get(f"/api/assistants/{assistant_id}/runtime-config")
|
||||
assert runtime_resp.status_code == 200
|
||||
metadata = runtime_resp.json()["sessionStartMetadata"]
|
||||
tools = metadata["tools"]
|
||||
assert isinstance(tools, list)
|
||||
assert len(tools) == 2
|
||||
|
||||
by_name = {item["function"]["name"]: item for item in tools}
|
||||
assert by_name["increase_volume"]["executor"] == "client"
|
||||
assert by_name["increase_volume"]["defaultArgs"]["step"] == 1
|
||||
assert by_name["calculator"]["executor"] == "server"
|
||||
assert by_name["calculator"]["function"]["parameters"]["type"] == "object"
|
||||
assert "expression" in by_name["calculator"]["function"]["parameters"]["properties"]
|
||||
|
||||
def test_runtime_config_text_mode_when_voice_output_disabled(self, client, sample_assistant_data):
|
||||
sample_assistant_data["voiceOutputEnabled"] = False
|
||||
assistant_resp = client.post("/api/assistants", json=sample_assistant_data)
|
||||
|
||||
Reference in New Issue
Block a user