fix(allowed_tools): keep completion under the type checker's complexity limit after merging main

This commit is contained in:
mateo-berri 2026-10-28 19:16:18 -07:00
parent 83353bbaeb
commit 3ae4e86fd7
2 changed files with 5 additions and 6 deletions

View file

@ -124,12 +124,12 @@ def is_allowed_tools_choice(tool_choice: object) -> bool:
return False
def _accepts_allowed_tools(custom_llm_provider: str, model: str, base_model: str | None) -> bool:
def _accepts_allowed_tools(custom_llm_provider: str, model: str, base_model: object) -> bool:
match custom_llm_provider:
case "azure_ai":
from litellm.llms.azure_ai.common_utils import azure_ai_serves_openai_chat_model
return azure_ai_serves_openai_chat_model(model, base_model)
return azure_ai_serves_openai_chat_model(model, base_model if isinstance(base_model, str) else None)
case _:
return custom_llm_provider in PROVIDERS_ACCEPTING_ALLOWED_TOOLS
@ -140,7 +140,7 @@ def tool_choice_for_provider(
custom_llm_provider: str,
model: str,
drop_params: bool,
base_model: str | None = None,
base_model: object = None,
) -> _ToolChoiceT | Mapping[str, JsonValue] | None:
if not is_allowed_tools_choice(tool_choice):
return tool_choice

View file

@ -5726,7 +5726,6 @@ def completion(
drop_unsupported_reasoning: Final = (
litellm.drop_params is True or normalize_drop_params(routing_kwargs.get("drop_params")) is True
)
drops_tool_choice: Final = drop_policy(routing_kwargs).drops("tool_choice")
reasoning_model_group: Final = model_group_from_metadata(
routing_kwargs.get("metadata"), routing_kwargs.get("litellm_metadata")
)
@ -5878,8 +5877,8 @@ def completion(
_OPAQUE_VALUE_ADAPTER.validate_python(tool_choice),
custom_llm_provider=custom_llm_provider,
model=model,
drop_params=drops_tool_choice,
base_model=base_model if isinstance(base_model, str) else None,
drop_params=drop_policy(routing_kwargs).drops("tool_choice"),
base_model=_OPAQUE_VALUE_ADAPTER.validate_python(base_model),
),
"max_retries": max_retries,
"logprobs": logprobs,