mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix: address type annotation and None check suggestions
- Update model parameter type to Optional[str] in both helper functions - Update return types to Tuple[Optional[str], Optional[str]] - Add explicit None check before `model in litellm.cohere_chat_models` - Add explicit None check before `_is_anthropic_text_model(model)` Addresses Greptile review suggestions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
9ba77b9466
commit
dad56bfc1d
1 changed files with 6 additions and 5 deletions
|
|
@ -34,8 +34,8 @@ def _is_azure_claude_model(model: str) -> bool:
|
|||
|
||||
|
||||
def handle_cohere_chat_model_custom_llm_provider(
|
||||
model: str, custom_llm_provider: Optional[str] = None
|
||||
) -> Tuple[str, Optional[str]]:
|
||||
model: Optional[str], custom_llm_provider: Optional[str] = None
|
||||
) -> Tuple[Optional[str], Optional[str]]:
|
||||
"""
|
||||
if user sets model = "cohere/command-r" -> use custom_llm_provider = "cohere_chat"
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ def handle_cohere_chat_model_custom_llm_provider(
|
|||
"""
|
||||
|
||||
if custom_llm_provider:
|
||||
if custom_llm_provider == "cohere" and model in litellm.cohere_chat_models:
|
||||
if custom_llm_provider == "cohere" and model and model in litellm.cohere_chat_models:
|
||||
return model, "cohere_chat"
|
||||
|
||||
if model and "/" in model:
|
||||
|
|
@ -64,8 +64,8 @@ def handle_cohere_chat_model_custom_llm_provider(
|
|||
|
||||
|
||||
def handle_anthropic_text_model_custom_llm_provider(
|
||||
model: str, custom_llm_provider: Optional[str] = None
|
||||
) -> Tuple[str, Optional[str]]:
|
||||
model: Optional[str], custom_llm_provider: Optional[str] = None
|
||||
) -> Tuple[Optional[str], Optional[str]]:
|
||||
"""
|
||||
if user sets model = "anthropic/claude-2" -> use custom_llm_provider = "anthropic_text"
|
||||
|
||||
|
|
@ -80,6 +80,7 @@ def handle_anthropic_text_model_custom_llm_provider(
|
|||
if custom_llm_provider:
|
||||
if (
|
||||
custom_llm_provider == "anthropic"
|
||||
and model
|
||||
and litellm.AnthropicTextConfig._is_anthropic_text_model(model)
|
||||
):
|
||||
return model, "anthropic_text"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue