Commit b505de59 authored by Your Name's avatar Your Name

fix provider handle

parent ca91d563
...@@ -13,13 +13,6 @@ from typing import List, Dict, Any, Optional, AsyncGenerator, Union ...@@ -13,13 +13,6 @@ from typing import List, Dict, Any, Optional, AsyncGenerator, Union
try: try:
import litellm import litellm
# Register 'coderai' as an alias for the 'openai' provider
# This allows LiteLLM to use its internal HTTP handler for custom providers
# by mapping them to the 'openai' provider behavior
litellm.custom_provider_map = [
{"provider": "coderai", "custom_handler": litellm.openai}
]
# Register 'coderai' as an alias for the 'openai' provider # Register 'coderai' as an alias for the 'openai' provider
# This allows LiteLLM to use its internal HTTP handler for custom providers # This allows LiteLLM to use its internal HTTP handler for custom providers
# by mapping them to the 'openai' provider behavior # by mapping them to the 'openai' provider behavior
...@@ -135,7 +128,7 @@ class LiteLLMBackend: ...@@ -135,7 +128,7 @@ class LiteLLMBackend:
# Known litellm providers # Known litellm providers
known_providers = ['openai', 'anthropic', 'gemini', 'meta', 'mistral', 'cohere', known_providers = ['openai', 'anthropic', 'gemini', 'meta', 'mistral', 'cohere',
'ai21', 'bedrock', 'azure', 'ollama', 'huggingface', 'deepseek', 'ai21', 'bedrock', 'azure', 'ollama', 'huggingface', 'deepseek',
'qwen', 'sagemaker', 'vertex', 'aiplatform', 'vllm', 'tgi'] 'qwen', 'sagemaker', 'vertex', 'aiplatform', 'vllm', 'tgi', 'coderai']
# Check if there's an existing provider prefix (contains /) # Check if there's an existing provider prefix (contains /)
if '/' in resolved_model: if '/' in resolved_model:
...@@ -144,14 +137,14 @@ class LiteLLMBackend: ...@@ -144,14 +137,14 @@ class LiteLLMBackend:
if prefix in known_providers: if prefix in known_providers:
# Valid provider, reformat as openai/{provider}/{model} # Valid provider, reformat as openai/{provider}/{model}
model_part = '/'.join(parts[1:]) model_part = '/'.join(parts[1:])
result = f"openai/{prefix}/{model_part}" result = f"coderai/{prefix}/{model_part}"
print(f"DEBUG litellm: Known provider '{prefix}', returning: {result}") print(f"DEBUG litellm: Known provider '{prefix}', returning: {result}")
return result return result
# Otherwise, treat the first part as the org/provider name (not default to huggingface) # Otherwise, treat the first part as the org/provider name (not default to huggingface)
# This allows custom model paths like TeichAI/model-name to work correctly # This allows custom model paths like TeichAI/model-name to work correctly
org_name = parts[0] org_name = parts[0]
model_part = '/'.join(parts[1:]) model_part = '/'.join(parts[1:])
result = f"openai/{org_name}/{model_part}" result = f"coderai/{org_name}/{model_part}"
print(f"DEBUG litellm: Custom org/model, returning: {result}") print(f"DEBUG litellm: Custom org/model, returning: {result}")
return result return result
...@@ -195,12 +188,12 @@ class LiteLLMBackend: ...@@ -195,12 +188,12 @@ class LiteLLMBackend:
# Check for known patterns # Check for known patterns
for pattern, provider in provider_map.items(): for pattern, provider in provider_map.items():
if model_lower.startswith(pattern): if model_lower.startswith(pattern):
result = f"openai/{provider}/{resolved_model}" result = f"coderai/{provider}/{resolved_model}"
print(f"DEBUG litellm: Detected provider '{provider}', returning: {result}") print(f"DEBUG litellm: Detected provider '{provider}', returning: {result}")
return result return result
# Default: use "coderai" as provider for unknown models # Default: use "coderai" as provider for unknown models
result = f"openai/coderai/{resolved_model}" result = f"coderai/coderai/{resolved_model}"
print(f"DEBUG litellm: Unknown provider, using 'coderai', returning: {result}") print(f"DEBUG litellm: Unknown provider, using 'coderai', returning: {result}")
return result return result
......
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