(Feat) - Add support for structured output on bedrock/nova models + add util litellm.supports_tool_choice (#8264)

* fix supports_tool_choice

* TestBedrockNovaJson

* use supports_tool_choice

* fix supports_tool_choice

* add supports_tool_choice param

* script to add fields to model cost map

* test_supports_tool_choice

* test_supports_tool_choice

* fix supports tool choice check

* test_supports_tool_choice_simple_tests

* fix supports_tool_choice check

* fix supports_tool_choice bedrock

* test_supports_tool_choice

* test_supports_tool_choice

* fix bedrock/eu-west-3/mistral.mistral-large-2402-v1:0

* ci/cd run again

* test_supports_tool_choice_simple_tests

* TestGoogleAIStudioGemini temp - remove to run ci/cd

* test_aaalangfuse_logging_metadata

* TestGoogleAIStudioGemini

* test_check_provider_match

* remove add param to map
This commit is contained in:
Ishaan Jaff 2025-02-04 21:47:16 -08:00 committed by GitHub
parent c743475aba
commit 3a6349d871
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 226 additions and 9 deletions

View file

@ -1938,6 +1938,15 @@ def supports_function_calling(
)
def supports_tool_choice(model: str, custom_llm_provider: Optional[str] = None) -> bool:
"""
Check if the given model supports `tool_choice` and return a boolean value.
"""
return _supports_factory(
model=model, custom_llm_provider=custom_llm_provider, key="supports_tool_choice"
)
def _supports_factory(model: str, custom_llm_provider: Optional[str], key: str) -> bool:
"""
Check if the given model supports function calling and return a boolean value.
@ -4018,7 +4027,7 @@ def _check_provider_match(model_info: dict, custom_llm_provider: Optional[str])
"litellm_provider"
].startswith("fireworks_ai"):
return True
elif custom_llm_provider == "bedrock" and model_info[
elif custom_llm_provider.startswith("bedrock") and model_info[
"litellm_provider"
].startswith("bedrock"):
return True
@ -4189,6 +4198,7 @@ def _get_model_info_helper( # noqa: PLR0915
supports_system_messages=None,
supports_response_schema=None,
supports_function_calling=None,
supports_tool_choice=None,
supports_assistant_prefill=None,
supports_prompt_caching=None,
supports_pdf_input=None,
@ -4333,6 +4343,7 @@ def _get_model_info_helper( # noqa: PLR0915
supports_function_calling=_model_info.get(
"supports_function_calling", False
),
supports_tool_choice=_model_info.get("supports_tool_choice", False),
supports_assistant_prefill=_model_info.get(
"supports_assistant_prefill", False
),
@ -4411,6 +4422,7 @@ def get_model_info(model: str, custom_llm_provider: Optional[str] = None) -> Mod
supports_response_schema: Optional[bool]
supports_vision: Optional[bool]
supports_function_calling: Optional[bool]
supports_tool_choice: Optional[bool]
supports_prompt_caching: Optional[bool]
supports_audio_input: Optional[bool]
supports_audio_output: Optional[bool]