Commit 26b84ba4 authored by Your Name's avatar Your Name

Add debug logging to LiteLLM alias resolution

parent cd1040bb
...@@ -104,11 +104,15 @@ class LiteLLMBackend: ...@@ -104,11 +104,15 @@ class LiteLLMBackend:
Returns: Returns:
Normalized model name with provider prefix Normalized model name with provider prefix
""" """
print(f"DEBUG litellm: normalize_model_name input: {model}")
# First, resolve alias to actual model name if we have a model manager # First, resolve alias to actual model name if we have a model manager
resolved_model = self._resolve_model_alias(model) resolved_model = self._resolve_model_alias(model)
print(f"DEBUG litellm: After alias resolution: {resolved_model}")
# If already has a provider prefix (contains /), return as-is # If already has a provider prefix (contains /), return as-is
if '/' in resolved_model: if '/' in resolved_model:
print(f"DEBUG litellm: Model has provider prefix, returning: {resolved_model}")
return resolved_model return resolved_model
# Common model name patterns and their providers # Common model name patterns and their providers
...@@ -154,7 +158,9 @@ class LiteLLMBackend: ...@@ -154,7 +158,9 @@ class LiteLLMBackend:
return f"{provider}{resolved_model}" return f"{provider}{resolved_model}"
# Default: assume OpenAI-compatible local model # Default: assume OpenAI-compatible local model
return f"openai/{resolved_model}" result = f"openai/{resolved_model}"
print(f"DEBUG litellm: Using default provider, returning: {result}")
return result
def _resolve_model_alias(self, model: str) -> str: def _resolve_model_alias(self, model: str) -> str:
""" """
...@@ -170,11 +176,13 @@ class LiteLLMBackend: ...@@ -170,11 +176,13 @@ class LiteLLMBackend:
Resolved actual model name Resolved actual model name
""" """
if not self.model_manager: if not self.model_manager:
print(f"DEBUG litellm: No model_manager, returning model as-is: {model}")
return model return model
# Check if model is "default" or empty - use default_model # Check if model is "default" or empty - use default_model
if not model or model == "default": if not model or model == "default":
default_model = getattr(self.model_manager, 'default_model', None) default_model = getattr(self.model_manager, 'default_model', None)
print(f"DEBUG litellm: Resolving 'default' alias to: {default_model}")
if default_model: if default_model:
return default_model return default_model
return model return model
...@@ -182,20 +190,21 @@ class LiteLLMBackend: ...@@ -182,20 +190,21 @@ class LiteLLMBackend:
# Check if model is "image" - get first image model # Check if model is "image" - get first image model
if model == "image": if model == "image":
image_models = getattr(self.model_manager, 'image_models', []) image_models = getattr(self.model_manager, 'image_models', [])
if image_models: resolved = image_models[0] if image_models else model
return image_models[0] print(f"DEBUG litellm: Resolving 'image' alias to: {resolved}")
return model return resolved
# Check if model is "audio" - get first audio model # Check if model is "audio" - get first audio model
if model == "audio": if model == "audio":
audio_models = getattr(self.model_manager, 'audio_models', []) audio_models = getattr(self.model_manager, 'audio_models', [])
if audio_models: resolved = audio_models[0] if audio_models else model
return audio_models[0] print(f"DEBUG litellm: Resolving 'audio' alias to: {resolved}")
return model return resolved
# Check if model is "tts" - get tts model # Check if model is "tts" - get tts model
if model == "tts": if model == "tts":
tts_model = getattr(self.model_manager, 'tts_model', None) tts_model = getattr(self.model_manager, 'tts_model', None)
print(f"DEBUG litellm: Resolving 'tts' alias to: {tts_model}")
if tts_model: if tts_model:
return tts_model return tts_model
return model return model
...@@ -203,8 +212,11 @@ class LiteLLMBackend: ...@@ -203,8 +212,11 @@ class LiteLLMBackend:
# Check custom aliases registered via --model-alias # Check custom aliases registered via --model-alias
model_aliases = getattr(self.model_manager, 'model_aliases', {}) model_aliases = getattr(self.model_manager, 'model_aliases', {})
if model in model_aliases: if model in model_aliases:
return model_aliases[model] resolved = model_aliases[model]
print(f"DEBUG litellm: Resolving alias '{model}' to: {resolved}")
return resolved
print(f"DEBUG litellm: Model '{model}' is not an alias, returning as-is")
return model return model
def _convert_messages(self, messages: List[Dict]) -> List[Dict]: def _convert_messages(self, messages: List[Dict]) -> List[Dict]:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment