mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-17 04:34:25 +00:00
test(anthropic): expect the json tool description through a shared constant
This commit is contained in:
parent
b5fa712789
commit
9b5ae73da9
4 changed files with 15 additions and 2 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue