diff --git a/litellm/constants.py b/litellm/constants.py index 38d16d61d7b..88c2123476c 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -1586,6 +1586,9 @@ OPENAI_FINISH_REASONS: Final = [ ] HUMANLOOP_PROMPT_CACHE_TTL_SECONDS: Final = int(os.getenv("HUMANLOOP_PROMPT_CACHE_TTL_SECONDS", 60)) # 1 minute RESPONSE_FORMAT_TOOL_NAME = "json_tool_call" # default tool name used when converting response format to tool call +RESPONSE_FORMAT_TOOL_DESCRIPTION: Final = ( + "Return the final answer as this structured object, filling every required field." +) ########################### Logging Callback Constants ########################### AZURE_STORAGE_MSFT_VERSION: Final = "2019-07-07" diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index e328cc66f08..fefa40bd91f 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -20,6 +20,7 @@ from litellm.constants import ( DEFAULT_REASONING_EFFORT_MEDIUM_THINKING_BUDGET, DEFAULT_REASONING_EFFORT_MINIMAL_THINKING_BUDGET, DEFAULT_REASONING_EFFORT_XHIGH_THINKING_BUDGET, + RESPONSE_FORMAT_TOOL_DESCRIPTION, RESPONSE_FORMAT_TOOL_NAME, ) from litellm.litellm_core_utils.core_helpers import map_finish_reason @@ -1754,7 +1755,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): _tool: Final = AnthropicMessagesTool( name=RESPONSE_FORMAT_TOOL_NAME, - description="Return the final answer as this structured object, filling every required field.", + description=RESPONSE_FORMAT_TOOL_DESCRIPTION, input_schema=_input_schema, ) return _tool diff --git a/tests/unit/llms/databricks/chat/test_databricks_chat_transformation.py b/tests/unit/llms/databricks/chat/test_databricks_chat_transformation.py index c6e0ecd2b41..c66efe21749 100644 --- a/tests/unit/llms/databricks/chat/test_databricks_chat_transformation.py +++ b/tests/unit/llms/databricks/chat/test_databricks_chat_transformation.py @@ -16,6 +16,7 @@ from litellm.constants import ( DEFAULT_REASONING_EFFORT_HIGH_THINKING_BUDGET, DEFAULT_REASONING_EFFORT_LOW_THINKING_BUDGET, DEFAULT_REASONING_EFFORT_MEDIUM_THINKING_BUDGET, + RESPONSE_FORMAT_TOOL_DESCRIPTION, ) from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler from litellm.llms.databricks.chat.transformation import ( @@ -2143,6 +2144,7 @@ def test_databricks_claude_json_schema_preserves_refs_in_tool_parameters() -> No "function": { "name": "json_tool_call", "parameters": JSON_SCHEMA_RESPONSE_FORMAT["json_schema"]["schema"], + "description": RESPONSE_FORMAT_TOOL_DESCRIPTION, }, } ] diff --git a/tests/unit/llms/vertex_ai/test_vertex.py b/tests/unit/llms/vertex_ai/test_vertex.py index 044a07859f9..c5aaa010a96 100644 --- a/tests/unit/llms/vertex_ai/test_vertex.py +++ b/tests/unit/llms/vertex_ai/test_vertex.py @@ -22,6 +22,7 @@ import pytest import litellm from litellm import Router, get_optional_params +from litellm.constants import RESPONSE_FORMAT_TOOL_DESCRIPTION from litellm.llms.vertex_ai.gemini.transformation import _process_gemini_media from litellm.types.llms.vertex_ai import BlobType @@ -2692,7 +2693,13 @@ def test_gemini_pro_json_schema_args_sent_httpx( request_body: Final = json.loads(route.calls[0].request.content) if "claude" in model: assert request_body["tool_choice"] == {"type": "tool", "name": "json_tool_call"} - assert request_body["tools"] == [{"name": "json_tool_call", "input_schema": _RECIPES_SCHEMA}] + assert request_body["tools"] == [ + { + "name": "json_tool_call", + "description": RESPONSE_FORMAT_TOOL_DESCRIPTION, + "input_schema": _RECIPES_SCHEMA, + } + ] else: assert request_body["generationConfig"]["response_mime_type"] == "application/json" assert request_body["generationConfig"]["response_json_schema"] == _RECIPES_SCHEMA