From f1e9686535c2073b616669ec17f2ce62e213d09d Mon Sep 17 00:00:00 2001 From: Ahmad Haidar Date: Mon, 3 Mar 2025 14:53:57 +0300 Subject: [PATCH 1/2] fix(agents-api): fix model=None case for chat endpoint --- .../agents_api/routers/sessions/render.py | 5 +- .../routers/utils/model_validation.py | 3 + agents-api/tests/test_model_validation.py | 3 + schemas/create_agent_request.json | 522 +++++++++--------- schemas/create_task_request.json | 522 +++++++++--------- 5 files changed, 532 insertions(+), 523 deletions(-) diff --git a/agents-api/agents_api/routers/sessions/render.py b/agents-api/agents_api/routers/sessions/render.py index 084830847..3dc9da667 100644 --- a/agents-api/agents_api/routers/sessions/render.py +++ b/agents-api/agents_api/routers/sessions/render.py @@ -59,9 +59,6 @@ async def render_chat_input( session_id: UUID, chat_input: ChatInput, ) -> tuple[list[dict], list[DocReference], list[dict] | None, dict, list[dict], ChatContext]: - if chat_input.model: - await validate_model(chat_input.model) - # check if the developer is paid if "paid" not in developer.tags: # get the session length @@ -83,6 +80,8 @@ async def render_chat_input( chat_context.merge_settings(chat_input) settings: dict = chat_context.settings or {} + await validate_model(settings.get("model")) + # Get the past messages and doc references past_messages, doc_references = await gather_messages( developer=developer, diff --git a/agents-api/agents_api/routers/utils/model_validation.py b/agents-api/agents_api/routers/utils/model_validation.py index b74567dd3..35fb7b1a5 100644 --- a/agents-api/agents_api/routers/utils/model_validation.py +++ b/agents-api/agents_api/routers/utils/model_validation.py @@ -9,6 +9,9 @@ async def validate_model(model_name: str) -> None: Validates if a given model name is available in LiteLLM. Raises HTTPException if model is not available. """ + print("*" * 100) + print(model_name) + print("*" * 100) models = await get_model_list() available_models = [model["id"] for model in models] diff --git a/agents-api/tests/test_model_validation.py b/agents-api/tests/test_model_validation.py index 40dfce359..5c660c351 100644 --- a/agents-api/tests/test_model_validation.py +++ b/agents-api/tests/test_model_validation.py @@ -26,3 +26,6 @@ async def _(): assert exc.raised.status_code == 400 assert "Model non-existent-model not available" in exc.raised.detail mock_get_models.assert_called_once() + + +# TODO: test when model is None diff --git a/schemas/create_agent_request.json b/schemas/create_agent_request.json index d3120fbc0..a2d23e306 100644 --- a/schemas/create_agent_request.json +++ b/schemas/create_agent_request.json @@ -102,7 +102,7 @@ "title": "Agent", "type": "object" }, - "ApiCallDef-Input": { + "ApiCallDef": { "description": "API call definition", "properties": { "content": { @@ -253,155 +253,6 @@ "title": "ApiCallDef", "type": "object" }, - "ApiCallDef-Output": { - "description": "API call definition", - "properties": { - "content": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Content" - }, - "cookies": { - "anyOf": [ - { - "additionalProperties": { - "type": "string" - }, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Cookies" - }, - "data": { - "anyOf": [ - { - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Data" - }, - "files": { - "anyOf": [ - { - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Files" - }, - "follow_redirects": { - "anyOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ], - "title": "Follow Redirects" - }, - "headers": { - "anyOf": [ - { - "additionalProperties": { - "type": "string" - }, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Headers" - }, - "json": { - "anyOf": [ - { - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Json" - }, - "method": { - "enum": [ - "GET", - "POST", - "PUT", - "DELETE", - "PATCH", - "HEAD", - "OPTIONS", - "CONNECT", - "TRACE" - ], - "title": "Method", - "type": "string" - }, - "params": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Params" - }, - "schema": { - "anyOf": [ - { - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Schema" - }, - "timeout": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "title": "Timeout" - }, - "url": { - "title": "Url", - "type": "string" - } - }, - "required": [ - "method", - "url" - ], - "title": "ApiCallDef", - "type": "object" - }, "ApiCallDefUpdate": { "description": "API call definition", "properties": { @@ -3734,13 +3585,20 @@ }, "recall_options": { "anyOf": [ + { + "$ref": "#/$defs/VectorDocSearch" + }, + { + "$ref": "#/$defs/TextOnlyDocSearch" + }, { "$ref": "#/$defs/HybridDocSearch" }, { "type": "null" } - ] + ], + "title": "Recall Options" }, "render_templates": { "default": true, @@ -3908,13 +3766,20 @@ }, "recall_options": { "anyOf": [ + { + "$ref": "#/$defs/VectorDocSearch" + }, + { + "$ref": "#/$defs/TextOnlyDocSearch" + }, { "$ref": "#/$defs/HybridDocSearch" }, { "type": "null" } - ] + ], + "title": "Recall Options" }, "render_templates": { "default": true, @@ -4120,7 +3985,7 @@ "api_call": { "anyOf": [ { - "$ref": "#/$defs/ApiCallDef-Output" + "$ref": "#/$defs/ApiCallDef" }, { "type": "null" @@ -4180,7 +4045,7 @@ "$ref": "#/$defs/EmailIntegrationDef" }, { - "$ref": "#/$defs/SpiderIntegrationDef-Output" + "$ref": "#/$defs/SpiderIntegrationDef" }, { "$ref": "#/$defs/WikipediaIntegrationDef" @@ -6056,7 +5921,7 @@ "HybridDocSearch": { "properties": { "alpha": { - "default": 0.75, + "default": 0.5, "maximum": 1.0, "minimum": 0.0, "title": "Alpha", @@ -6101,6 +5966,7 @@ "type": "number" }, "mode": { + "const": "hybrid", "default": "hybrid", "title": "Mode", "type": "string" @@ -6178,7 +6044,7 @@ "HybridDocSearchUpdate": { "properties": { "alpha": { - "default": 0.75, + "default": 0.5, "maximum": 1.0, "minimum": 0.0, "title": "Alpha", @@ -6223,6 +6089,7 @@ "type": "number" }, "mode": { + "const": "hybrid", "default": "hybrid", "title": "Mode", "type": "string" @@ -8007,13 +7874,20 @@ }, "recall_options": { "anyOf": [ + { + "$ref": "#/$defs/VectorDocSearchUpdate" + }, + { + "$ref": "#/$defs/TextOnlyDocSearchUpdate" + }, { "$ref": "#/$defs/HybridDocSearchUpdate" }, { "type": "null" } - ] + ], + "title": "Recall Options" }, "render_templates": { "default": true, @@ -9233,13 +9107,20 @@ }, "recall_options": { "anyOf": [ + { + "$ref": "#/$defs/VectorDocSearch" + }, + { + "$ref": "#/$defs/TextOnlyDocSearch" + }, { "$ref": "#/$defs/HybridDocSearch" }, { "type": "null" } - ] + ], + "title": "Recall Options" }, "render_templates": { "default": true, @@ -9570,7 +9451,7 @@ "title": "Source", "type": "object" }, - "SpiderFetchArguments-Input": { + "SpiderFetchArguments": { "description": "Arguments for Spider integration", "properties": { "content_type": { @@ -9608,42 +9489,6 @@ "title": "SpiderFetchArguments", "type": "object" }, - "SpiderFetchArguments-Output": { - "description": "Arguments for Spider integration", - "properties": { - "content_type": { - "default": "application/json", - "enum": [ - "application/json", - "text/csv", - "application/xml", - "application/jsonl" - ], - "title": "Content Type", - "type": "string" - }, - "params": { - "anyOf": [ - { - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Params" - }, - "url": { - "title": "Url", - "type": "string" - } - }, - "required": [ - "url" - ], - "title": "SpiderFetchArguments", - "type": "object" - }, "SpiderFetchArgumentsUpdate": { "description": "Arguments for Spider integration", "properties": { @@ -9686,63 +9531,13 @@ "title": "SpiderFetchArgumentsUpdate", "type": "object" }, - "SpiderIntegrationDef-Input": { + "SpiderIntegrationDef": { "description": "Spider integration definition", "properties": { "arguments": { "anyOf": [ { - "$ref": "#/$defs/SpiderFetchArguments-Input" - }, - { - "type": "null" - } - ] - }, - "method": { - "anyOf": [ - { - "enum": [ - "crawl", - "links", - "screenshot", - "search" - ], - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Method" - }, - "provider": { - "const": "spider", - "default": "spider", - "title": "Provider", - "type": "string" - }, - "setup": { - "anyOf": [ - { - "$ref": "#/$defs/SpiderSetup" - }, - { - "type": "null" - } - ] - } - }, - "title": "SpiderIntegrationDef", - "type": "object" - }, - "SpiderIntegrationDef-Output": { - "description": "Spider integration definition", - "properties": { - "arguments": { - "anyOf": [ - { - "$ref": "#/$defs/SpiderFetchArguments-Output" + "$ref": "#/$defs/SpiderFetchArguments" }, { "type": "null" @@ -10293,7 +10088,7 @@ "api_call": { "anyOf": [ { - "$ref": "#/$defs/ApiCallDef-Input" + "$ref": "#/$defs/ApiCallDef" }, { "type": "null" @@ -10359,7 +10154,7 @@ "$ref": "#/$defs/EmailIntegrationDef" }, { - "$ref": "#/$defs/SpiderIntegrationDef-Input" + "$ref": "#/$defs/SpiderIntegrationDef" }, { "$ref": "#/$defs/WikipediaIntegrationDef" @@ -10464,7 +10259,7 @@ "api_call": { "anyOf": [ { - "$ref": "#/$defs/ApiCallDef-Output" + "$ref": "#/$defs/ApiCallDef" }, { "type": "null" @@ -10530,7 +10325,7 @@ "$ref": "#/$defs/EmailIntegrationDef" }, { - "$ref": "#/$defs/SpiderIntegrationDef-Output" + "$ref": "#/$defs/SpiderIntegrationDef" }, { "$ref": "#/$defs/WikipediaIntegrationDef" @@ -10664,6 +10459,49 @@ "title": "TextEditor20241022DefUpdate", "type": "object" }, + "TextOnlyDocSearch": { + "properties": { + "lang": { + "default": "en-US", + "title": "Lang", + "type": "string" + }, + "limit": { + "default": 10, + "maximum": 50.0, + "minimum": 1.0, + "title": "Limit", + "type": "integer" + }, + "max_query_length": { + "default": 1000, + "maximum": 10000.0, + "minimum": 100.0, + "title": "Max Query Length", + "type": "integer" + }, + "metadata_filter": { + "default": {}, + "title": "Metadata Filter", + "type": "object" + }, + "mode": { + "const": "text", + "default": "text", + "title": "Mode", + "type": "string" + }, + "num_search_messages": { + "default": 4, + "maximum": 50.0, + "minimum": 1.0, + "title": "Num Search Messages", + "type": "integer" + } + }, + "title": "TextOnlyDocSearch", + "type": "object" + }, "TextOnlyDocSearchRequest": { "properties": { "lang": { @@ -10694,6 +10532,49 @@ "title": "TextOnlyDocSearchRequest", "type": "object" }, + "TextOnlyDocSearchUpdate": { + "properties": { + "lang": { + "default": "en-US", + "title": "Lang", + "type": "string" + }, + "limit": { + "default": 10, + "maximum": 50.0, + "minimum": 1.0, + "title": "Limit", + "type": "integer" + }, + "max_query_length": { + "default": 1000, + "maximum": 10000.0, + "minimum": 100.0, + "title": "Max Query Length", + "type": "integer" + }, + "metadata_filter": { + "default": {}, + "title": "Metadata Filter", + "type": "object" + }, + "mode": { + "const": "text", + "default": "text", + "title": "Mode", + "type": "string" + }, + "num_search_messages": { + "default": 4, + "maximum": 50.0, + "minimum": 1.0, + "title": "Num Search Messages", + "type": "integer" + } + }, + "title": "TextOnlyDocSearchUpdate", + "type": "object" + }, "Then-Input": { "description": "The steps to run if the condition is true", "properties": { @@ -10919,7 +10800,7 @@ "api_call": { "anyOf": [ { - "$ref": "#/$defs/ApiCallDef-Output" + "$ref": "#/$defs/ApiCallDef" }, { "type": "null" @@ -10991,7 +10872,7 @@ "$ref": "#/$defs/EmailIntegrationDef" }, { - "$ref": "#/$defs/SpiderIntegrationDef-Output" + "$ref": "#/$defs/SpiderIntegrationDef" }, { "$ref": "#/$defs/WikipediaIntegrationDef" @@ -11474,13 +11355,20 @@ }, "recall_options": { "anyOf": [ + { + "$ref": "#/$defs/VectorDocSearch" + }, + { + "$ref": "#/$defs/TextOnlyDocSearch" + }, { "$ref": "#/$defs/HybridDocSearch" }, { "type": "null" } - ] + ], + "title": "Recall Options" }, "render_templates": { "default": true, @@ -11530,7 +11418,7 @@ "api_call": { "anyOf": [ { - "$ref": "#/$defs/ApiCallDef-Input" + "$ref": "#/$defs/ApiCallDef" }, { "type": "null" @@ -11590,7 +11478,7 @@ "$ref": "#/$defs/EmailIntegrationDef" }, { - "$ref": "#/$defs/SpiderIntegrationDef-Input" + "$ref": "#/$defs/SpiderIntegrationDef" }, { "$ref": "#/$defs/WikipediaIntegrationDef" @@ -11805,6 +11693,63 @@ "title": "ValidationError", "type": "object" }, + "VectorDocSearch": { + "properties": { + "confidence": { + "default": 0, + "maximum": 1.0, + "minimum": -1.0, + "title": "Confidence", + "type": "number" + }, + "lang": { + "default": "en-US", + "title": "Lang", + "type": "string" + }, + "limit": { + "default": 10, + "maximum": 50.0, + "minimum": 1.0, + "title": "Limit", + "type": "integer" + }, + "max_query_length": { + "default": 1000, + "maximum": 10000.0, + "minimum": 100.0, + "title": "Max Query Length", + "type": "integer" + }, + "metadata_filter": { + "default": {}, + "title": "Metadata Filter", + "type": "object" + }, + "mmr_strength": { + "default": 0.5, + "exclusiveMaximum": 1.0, + "minimum": 0.0, + "title": "Mmr Strength", + "type": "number" + }, + "mode": { + "const": "vector", + "default": "vector", + "title": "Mode", + "type": "string" + }, + "num_search_messages": { + "default": 4, + "maximum": 50.0, + "minimum": 1.0, + "title": "Num Search Messages", + "type": "integer" + } + }, + "title": "VectorDocSearch", + "type": "object" + }, "VectorDocSearchRequest": { "properties": { "confidence": { @@ -11852,6 +11797,63 @@ "title": "VectorDocSearchRequest", "type": "object" }, + "VectorDocSearchUpdate": { + "properties": { + "confidence": { + "default": 0, + "maximum": 1.0, + "minimum": -1.0, + "title": "Confidence", + "type": "number" + }, + "lang": { + "default": "en-US", + "title": "Lang", + "type": "string" + }, + "limit": { + "default": 10, + "maximum": 50.0, + "minimum": 1.0, + "title": "Limit", + "type": "integer" + }, + "max_query_length": { + "default": 1000, + "maximum": 10000.0, + "minimum": 100.0, + "title": "Max Query Length", + "type": "integer" + }, + "metadata_filter": { + "default": {}, + "title": "Metadata Filter", + "type": "object" + }, + "mmr_strength": { + "default": 0.5, + "exclusiveMaximum": 1.0, + "minimum": 0.0, + "title": "Mmr Strength", + "type": "number" + }, + "mode": { + "const": "vector", + "default": "vector", + "title": "Mode", + "type": "string" + }, + "num_search_messages": { + "default": 4, + "maximum": 50.0, + "minimum": 1.0, + "title": "Num Search Messages", + "type": "integer" + } + }, + "title": "VectorDocSearchUpdate", + "type": "object" + }, "WaitForInputInfo": { "properties": { "info": { @@ -12610,7 +12612,7 @@ "api_call": { "anyOf": [ { - "$ref": "#/$defs/ApiCallDef-Input" + "$ref": "#/$defs/ApiCallDef" }, { "type": "null" @@ -12670,7 +12672,7 @@ "$ref": "#/$defs/EmailIntegrationDef" }, { - "$ref": "#/$defs/SpiderIntegrationDef-Input" + "$ref": "#/$defs/SpiderIntegrationDef" }, { "$ref": "#/$defs/WikipediaIntegrationDef" @@ -12775,7 +12777,7 @@ "api_call": { "anyOf": [ { - "$ref": "#/$defs/ApiCallDef-Input" + "$ref": "#/$defs/ApiCallDef" }, { "type": "null" @@ -12835,7 +12837,7 @@ "$ref": "#/$defs/EmailIntegrationDef" }, { - "$ref": "#/$defs/SpiderIntegrationDef-Input" + "$ref": "#/$defs/SpiderIntegrationDef" }, { "$ref": "#/$defs/WikipediaIntegrationDef" diff --git a/schemas/create_task_request.json b/schemas/create_task_request.json index 9994654c1..dd4100b7d 100644 --- a/schemas/create_task_request.json +++ b/schemas/create_task_request.json @@ -102,7 +102,7 @@ "title": "Agent", "type": "object" }, - "ApiCallDef-Input": { + "ApiCallDef": { "description": "API call definition", "properties": { "content": { @@ -253,155 +253,6 @@ "title": "ApiCallDef", "type": "object" }, - "ApiCallDef-Output": { - "description": "API call definition", - "properties": { - "content": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Content" - }, - "cookies": { - "anyOf": [ - { - "additionalProperties": { - "type": "string" - }, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Cookies" - }, - "data": { - "anyOf": [ - { - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Data" - }, - "files": { - "anyOf": [ - { - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Files" - }, - "follow_redirects": { - "anyOf": [ - { - "type": "boolean" - }, - { - "type": "null" - } - ], - "title": "Follow Redirects" - }, - "headers": { - "anyOf": [ - { - "additionalProperties": { - "type": "string" - }, - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Headers" - }, - "json": { - "anyOf": [ - { - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Json" - }, - "method": { - "enum": [ - "GET", - "POST", - "PUT", - "DELETE", - "PATCH", - "HEAD", - "OPTIONS", - "CONNECT", - "TRACE" - ], - "title": "Method", - "type": "string" - }, - "params": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Params" - }, - "schema": { - "anyOf": [ - { - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Schema" - }, - "timeout": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "title": "Timeout" - }, - "url": { - "title": "Url", - "type": "string" - } - }, - "required": [ - "method", - "url" - ], - "title": "ApiCallDef", - "type": "object" - }, "ApiCallDefUpdate": { "description": "API call definition", "properties": { @@ -3734,13 +3585,20 @@ }, "recall_options": { "anyOf": [ + { + "$ref": "#/$defs/VectorDocSearch" + }, + { + "$ref": "#/$defs/TextOnlyDocSearch" + }, { "$ref": "#/$defs/HybridDocSearch" }, { "type": "null" } - ] + ], + "title": "Recall Options" }, "render_templates": { "default": true, @@ -3908,13 +3766,20 @@ }, "recall_options": { "anyOf": [ + { + "$ref": "#/$defs/VectorDocSearch" + }, + { + "$ref": "#/$defs/TextOnlyDocSearch" + }, { "$ref": "#/$defs/HybridDocSearch" }, { "type": "null" } - ] + ], + "title": "Recall Options" }, "render_templates": { "default": true, @@ -4120,7 +3985,7 @@ "api_call": { "anyOf": [ { - "$ref": "#/$defs/ApiCallDef-Output" + "$ref": "#/$defs/ApiCallDef" }, { "type": "null" @@ -4180,7 +4045,7 @@ "$ref": "#/$defs/EmailIntegrationDef" }, { - "$ref": "#/$defs/SpiderIntegrationDef-Output" + "$ref": "#/$defs/SpiderIntegrationDef" }, { "$ref": "#/$defs/WikipediaIntegrationDef" @@ -6056,7 +5921,7 @@ "HybridDocSearch": { "properties": { "alpha": { - "default": 0.75, + "default": 0.5, "maximum": 1.0, "minimum": 0.0, "title": "Alpha", @@ -6101,6 +5966,7 @@ "type": "number" }, "mode": { + "const": "hybrid", "default": "hybrid", "title": "Mode", "type": "string" @@ -6178,7 +6044,7 @@ "HybridDocSearchUpdate": { "properties": { "alpha": { - "default": 0.75, + "default": 0.5, "maximum": 1.0, "minimum": 0.0, "title": "Alpha", @@ -6223,6 +6089,7 @@ "type": "number" }, "mode": { + "const": "hybrid", "default": "hybrid", "title": "Mode", "type": "string" @@ -8007,13 +7874,20 @@ }, "recall_options": { "anyOf": [ + { + "$ref": "#/$defs/VectorDocSearchUpdate" + }, + { + "$ref": "#/$defs/TextOnlyDocSearchUpdate" + }, { "$ref": "#/$defs/HybridDocSearchUpdate" }, { "type": "null" } - ] + ], + "title": "Recall Options" }, "render_templates": { "default": true, @@ -9233,13 +9107,20 @@ }, "recall_options": { "anyOf": [ + { + "$ref": "#/$defs/VectorDocSearch" + }, + { + "$ref": "#/$defs/TextOnlyDocSearch" + }, { "$ref": "#/$defs/HybridDocSearch" }, { "type": "null" } - ] + ], + "title": "Recall Options" }, "render_templates": { "default": true, @@ -9570,7 +9451,7 @@ "title": "Source", "type": "object" }, - "SpiderFetchArguments-Input": { + "SpiderFetchArguments": { "description": "Arguments for Spider integration", "properties": { "content_type": { @@ -9608,42 +9489,6 @@ "title": "SpiderFetchArguments", "type": "object" }, - "SpiderFetchArguments-Output": { - "description": "Arguments for Spider integration", - "properties": { - "content_type": { - "default": "application/json", - "enum": [ - "application/json", - "text/csv", - "application/xml", - "application/jsonl" - ], - "title": "Content Type", - "type": "string" - }, - "params": { - "anyOf": [ - { - "type": "object" - }, - { - "type": "null" - } - ], - "title": "Params" - }, - "url": { - "title": "Url", - "type": "string" - } - }, - "required": [ - "url" - ], - "title": "SpiderFetchArguments", - "type": "object" - }, "SpiderFetchArgumentsUpdate": { "description": "Arguments for Spider integration", "properties": { @@ -9686,63 +9531,13 @@ "title": "SpiderFetchArgumentsUpdate", "type": "object" }, - "SpiderIntegrationDef-Input": { + "SpiderIntegrationDef": { "description": "Spider integration definition", "properties": { "arguments": { "anyOf": [ { - "$ref": "#/$defs/SpiderFetchArguments-Input" - }, - { - "type": "null" - } - ] - }, - "method": { - "anyOf": [ - { - "enum": [ - "crawl", - "links", - "screenshot", - "search" - ], - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Method" - }, - "provider": { - "const": "spider", - "default": "spider", - "title": "Provider", - "type": "string" - }, - "setup": { - "anyOf": [ - { - "$ref": "#/$defs/SpiderSetup" - }, - { - "type": "null" - } - ] - } - }, - "title": "SpiderIntegrationDef", - "type": "object" - }, - "SpiderIntegrationDef-Output": { - "description": "Spider integration definition", - "properties": { - "arguments": { - "anyOf": [ - { - "$ref": "#/$defs/SpiderFetchArguments-Output" + "$ref": "#/$defs/SpiderFetchArguments" }, { "type": "null" @@ -10293,7 +10088,7 @@ "api_call": { "anyOf": [ { - "$ref": "#/$defs/ApiCallDef-Input" + "$ref": "#/$defs/ApiCallDef" }, { "type": "null" @@ -10359,7 +10154,7 @@ "$ref": "#/$defs/EmailIntegrationDef" }, { - "$ref": "#/$defs/SpiderIntegrationDef-Input" + "$ref": "#/$defs/SpiderIntegrationDef" }, { "$ref": "#/$defs/WikipediaIntegrationDef" @@ -10464,7 +10259,7 @@ "api_call": { "anyOf": [ { - "$ref": "#/$defs/ApiCallDef-Output" + "$ref": "#/$defs/ApiCallDef" }, { "type": "null" @@ -10530,7 +10325,7 @@ "$ref": "#/$defs/EmailIntegrationDef" }, { - "$ref": "#/$defs/SpiderIntegrationDef-Output" + "$ref": "#/$defs/SpiderIntegrationDef" }, { "$ref": "#/$defs/WikipediaIntegrationDef" @@ -10664,6 +10459,49 @@ "title": "TextEditor20241022DefUpdate", "type": "object" }, + "TextOnlyDocSearch": { + "properties": { + "lang": { + "default": "en-US", + "title": "Lang", + "type": "string" + }, + "limit": { + "default": 10, + "maximum": 50.0, + "minimum": 1.0, + "title": "Limit", + "type": "integer" + }, + "max_query_length": { + "default": 1000, + "maximum": 10000.0, + "minimum": 100.0, + "title": "Max Query Length", + "type": "integer" + }, + "metadata_filter": { + "default": {}, + "title": "Metadata Filter", + "type": "object" + }, + "mode": { + "const": "text", + "default": "text", + "title": "Mode", + "type": "string" + }, + "num_search_messages": { + "default": 4, + "maximum": 50.0, + "minimum": 1.0, + "title": "Num Search Messages", + "type": "integer" + } + }, + "title": "TextOnlyDocSearch", + "type": "object" + }, "TextOnlyDocSearchRequest": { "properties": { "lang": { @@ -10694,6 +10532,49 @@ "title": "TextOnlyDocSearchRequest", "type": "object" }, + "TextOnlyDocSearchUpdate": { + "properties": { + "lang": { + "default": "en-US", + "title": "Lang", + "type": "string" + }, + "limit": { + "default": 10, + "maximum": 50.0, + "minimum": 1.0, + "title": "Limit", + "type": "integer" + }, + "max_query_length": { + "default": 1000, + "maximum": 10000.0, + "minimum": 100.0, + "title": "Max Query Length", + "type": "integer" + }, + "metadata_filter": { + "default": {}, + "title": "Metadata Filter", + "type": "object" + }, + "mode": { + "const": "text", + "default": "text", + "title": "Mode", + "type": "string" + }, + "num_search_messages": { + "default": 4, + "maximum": 50.0, + "minimum": 1.0, + "title": "Num Search Messages", + "type": "integer" + } + }, + "title": "TextOnlyDocSearchUpdate", + "type": "object" + }, "Then-Input": { "description": "The steps to run if the condition is true", "properties": { @@ -10919,7 +10800,7 @@ "api_call": { "anyOf": [ { - "$ref": "#/$defs/ApiCallDef-Output" + "$ref": "#/$defs/ApiCallDef" }, { "type": "null" @@ -10991,7 +10872,7 @@ "$ref": "#/$defs/EmailIntegrationDef" }, { - "$ref": "#/$defs/SpiderIntegrationDef-Output" + "$ref": "#/$defs/SpiderIntegrationDef" }, { "$ref": "#/$defs/WikipediaIntegrationDef" @@ -11474,13 +11355,20 @@ }, "recall_options": { "anyOf": [ + { + "$ref": "#/$defs/VectorDocSearch" + }, + { + "$ref": "#/$defs/TextOnlyDocSearch" + }, { "$ref": "#/$defs/HybridDocSearch" }, { "type": "null" } - ] + ], + "title": "Recall Options" }, "render_templates": { "default": true, @@ -11530,7 +11418,7 @@ "api_call": { "anyOf": [ { - "$ref": "#/$defs/ApiCallDef-Input" + "$ref": "#/$defs/ApiCallDef" }, { "type": "null" @@ -11590,7 +11478,7 @@ "$ref": "#/$defs/EmailIntegrationDef" }, { - "$ref": "#/$defs/SpiderIntegrationDef-Input" + "$ref": "#/$defs/SpiderIntegrationDef" }, { "$ref": "#/$defs/WikipediaIntegrationDef" @@ -11805,6 +11693,63 @@ "title": "ValidationError", "type": "object" }, + "VectorDocSearch": { + "properties": { + "confidence": { + "default": 0, + "maximum": 1.0, + "minimum": -1.0, + "title": "Confidence", + "type": "number" + }, + "lang": { + "default": "en-US", + "title": "Lang", + "type": "string" + }, + "limit": { + "default": 10, + "maximum": 50.0, + "minimum": 1.0, + "title": "Limit", + "type": "integer" + }, + "max_query_length": { + "default": 1000, + "maximum": 10000.0, + "minimum": 100.0, + "title": "Max Query Length", + "type": "integer" + }, + "metadata_filter": { + "default": {}, + "title": "Metadata Filter", + "type": "object" + }, + "mmr_strength": { + "default": 0.5, + "exclusiveMaximum": 1.0, + "minimum": 0.0, + "title": "Mmr Strength", + "type": "number" + }, + "mode": { + "const": "vector", + "default": "vector", + "title": "Mode", + "type": "string" + }, + "num_search_messages": { + "default": 4, + "maximum": 50.0, + "minimum": 1.0, + "title": "Num Search Messages", + "type": "integer" + } + }, + "title": "VectorDocSearch", + "type": "object" + }, "VectorDocSearchRequest": { "properties": { "confidence": { @@ -11852,6 +11797,63 @@ "title": "VectorDocSearchRequest", "type": "object" }, + "VectorDocSearchUpdate": { + "properties": { + "confidence": { + "default": 0, + "maximum": 1.0, + "minimum": -1.0, + "title": "Confidence", + "type": "number" + }, + "lang": { + "default": "en-US", + "title": "Lang", + "type": "string" + }, + "limit": { + "default": 10, + "maximum": 50.0, + "minimum": 1.0, + "title": "Limit", + "type": "integer" + }, + "max_query_length": { + "default": 1000, + "maximum": 10000.0, + "minimum": 100.0, + "title": "Max Query Length", + "type": "integer" + }, + "metadata_filter": { + "default": {}, + "title": "Metadata Filter", + "type": "object" + }, + "mmr_strength": { + "default": 0.5, + "exclusiveMaximum": 1.0, + "minimum": 0.0, + "title": "Mmr Strength", + "type": "number" + }, + "mode": { + "const": "vector", + "default": "vector", + "title": "Mode", + "type": "string" + }, + "num_search_messages": { + "default": 4, + "maximum": 50.0, + "minimum": 1.0, + "title": "Num Search Messages", + "type": "integer" + } + }, + "title": "VectorDocSearchUpdate", + "type": "object" + }, "WaitForInputInfo": { "properties": { "info": { @@ -12610,7 +12612,7 @@ "api_call": { "anyOf": [ { - "$ref": "#/$defs/ApiCallDef-Input" + "$ref": "#/$defs/ApiCallDef" }, { "type": "null" @@ -12670,7 +12672,7 @@ "$ref": "#/$defs/EmailIntegrationDef" }, { - "$ref": "#/$defs/SpiderIntegrationDef-Input" + "$ref": "#/$defs/SpiderIntegrationDef" }, { "$ref": "#/$defs/WikipediaIntegrationDef" @@ -12775,7 +12777,7 @@ "api_call": { "anyOf": [ { - "$ref": "#/$defs/ApiCallDef-Input" + "$ref": "#/$defs/ApiCallDef" }, { "type": "null" @@ -12835,7 +12837,7 @@ "$ref": "#/$defs/EmailIntegrationDef" }, { - "$ref": "#/$defs/SpiderIntegrationDef-Input" + "$ref": "#/$defs/SpiderIntegrationDef" }, { "$ref": "#/$defs/WikipediaIntegrationDef" From b2599e595f49d524ad24f0c91a9ac2ab5186f1b6 Mon Sep 17 00:00:00 2001 From: Ahmad Haidar Date: Mon, 3 Mar 2025 15:06:44 +0300 Subject: [PATCH 2/2] chore(agents-api): add a test for model=None --- .../agents_api/routers/utils/model_validation.py | 5 +---- agents-api/tests/test_model_validation.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/agents-api/agents_api/routers/utils/model_validation.py b/agents-api/agents_api/routers/utils/model_validation.py index 35fb7b1a5..5b5b56f46 100644 --- a/agents-api/agents_api/routers/utils/model_validation.py +++ b/agents-api/agents_api/routers/utils/model_validation.py @@ -4,14 +4,11 @@ from ...clients.litellm import get_model_list -async def validate_model(model_name: str) -> None: +async def validate_model(model_name: str | None) -> None: """ Validates if a given model name is available in LiteLLM. Raises HTTPException if model is not available. """ - print("*" * 100) - print(model_name) - print("*" * 100) models = await get_model_list() available_models = [model["id"] for model in models] diff --git a/agents-api/tests/test_model_validation.py b/agents-api/tests/test_model_validation.py index 5c660c351..d3a875018 100644 --- a/agents-api/tests/test_model_validation.py +++ b/agents-api/tests/test_model_validation.py @@ -7,7 +7,7 @@ from tests.fixtures import SAMPLE_MODELS -@test("validate_model: succeeds when model is available") +@test("validate_model: succeeds when model is available in model list") async def _(): # Use async context manager for patching with patch("agents_api.routers.utils.model_validation.get_model_list") as mock_get_models: @@ -16,7 +16,7 @@ async def _(): mock_get_models.assert_called_once() -@test("validate_model: fails when model is unavailable") +@test("validate_model: fails when model is unavailable in model list") async def _(): with patch("agents_api.routers.utils.model_validation.get_model_list") as mock_get_models: mock_get_models.return_value = SAMPLE_MODELS @@ -28,4 +28,12 @@ async def _(): mock_get_models.assert_called_once() -# TODO: test when model is None +@test("validate_model: fails when model is None") +async def _(): + with patch("agents_api.routers.utils.model_validation.get_model_list") as mock_get_models: + mock_get_models.return_value = SAMPLE_MODELS + with raises(HTTPException) as exc: + await validate_model(None) + + assert exc.raised.status_code == 400 + assert "Model None not available" in exc.raised.detail