mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
Add: chat completion transformation for minmax
This commit is contained in:
parent
38cf66df01
commit
b1b8d19d97
5 changed files with 52 additions and 1 deletions
|
|
@ -1482,6 +1482,7 @@ if TYPE_CHECKING:
|
|||
from .llms.bytez.chat.transformation import BytezChatConfig as BytezChatConfig
|
||||
from .llms.compactifai.chat.transformation import CompactifAIChatConfig as CompactifAIChatConfig
|
||||
from .llms.empower.chat.transformation import EmpowerChatConfig as EmpowerChatConfig
|
||||
from .llms.minimax.chat.transformation import MinimaxChatConfig as MinimaxChatConfig
|
||||
from .llms.aiohttp_openai.chat.transformation import AiohttpOpenAIChatConfig as AiohttpOpenAIChatConfig
|
||||
from .llms.huggingface.chat.transformation import HuggingFaceChatConfig as HuggingFaceChatConfig
|
||||
from .llms.huggingface.embedding.transformation import HuggingFaceEmbeddingConfig as HuggingFaceEmbeddingConfig
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ LLM_CONFIG_NAMES = (
|
|||
"BytezChatConfig",
|
||||
"CompactifAIChatConfig",
|
||||
"EmpowerChatConfig",
|
||||
"MinimaxChatConfig",
|
||||
"AiohttpOpenAIChatConfig",
|
||||
"HuggingFaceChatConfig",
|
||||
"HuggingFaceEmbeddingConfig",
|
||||
|
|
@ -750,6 +751,14 @@ def _lazy_import_llm_configs(name: str) -> Any: # noqa: PLR0915
|
|||
_globals["EmpowerChatConfig"] = _EmpowerChatConfig
|
||||
return _EmpowerChatConfig
|
||||
|
||||
if name == "MinimaxChatConfig":
|
||||
from .llms.minimax.chat.transformation import (
|
||||
MinimaxChatConfig as _MinimaxChatConfig,
|
||||
)
|
||||
|
||||
_globals["MinimaxChatConfig"] = _MinimaxChatConfig
|
||||
return _MinimaxChatConfig
|
||||
|
||||
if name == "AiohttpOpenAIChatConfig":
|
||||
from .llms.aiohttp_openai.chat.transformation import (
|
||||
AiohttpOpenAIChatConfig as _AiohttpOpenAIChatConfig,
|
||||
|
|
|
|||
|
|
@ -270,6 +270,9 @@ def get_llm_provider( # noqa: PLR0915
|
|||
elif endpoint == "api.minimax.io/anthropic" or endpoint == "api.minimaxi.com/anthropic":
|
||||
custom_llm_provider = "minimax"
|
||||
dynamic_api_key = get_secret_str("MINIMAX_API_KEY")
|
||||
elif endpoint == "api.minimax.io/v1" or endpoint == "api.minimaxi.com/v1":
|
||||
custom_llm_provider = "minimax"
|
||||
dynamic_api_key = get_secret_str("MINIMAX_API_KEY")
|
||||
elif endpoint == "platform.publicai.co/v1":
|
||||
custom_llm_provider = "publicai"
|
||||
dynamic_api_key = get_secret_str("PUBLICAI_API_KEY")
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ from litellm.constants import (
|
|||
DEFAULT_MOCK_RESPONSE_PROMPT_TOKEN_COUNT,
|
||||
)
|
||||
from litellm.exceptions import LiteLLMUnknownProvider
|
||||
from litellm.llms.openai_like.json_loader import JSONProviderRegistry
|
||||
from litellm.integrations.custom_logger import CustomLogger
|
||||
from litellm.litellm_core_utils.asyncify import run_async_function
|
||||
from litellm.litellm_core_utils.audio_utils.utils import (
|
||||
|
|
@ -98,6 +97,7 @@ from litellm.llms.base_llm.base_model_iterator import (
|
|||
from litellm.llms.bedrock.common_utils import BedrockModelInfo
|
||||
from litellm.llms.cohere.common_utils import CohereModelInfo
|
||||
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler
|
||||
from litellm.llms.openai_like.json_loader import JSONProviderRegistry
|
||||
from litellm.llms.vertex_ai.common_utils import (
|
||||
VertexAIModelRoute,
|
||||
get_vertex_ai_model_route,
|
||||
|
|
@ -2247,6 +2247,42 @@ def completion( # type: ignore # noqa: PLR0915
|
|||
logging.post_call(
|
||||
input=messages, api_key=api_key, original_response=response
|
||||
)
|
||||
elif custom_llm_provider == "minimax":
|
||||
api_key = (
|
||||
api_key
|
||||
or get_secret_str("MINIMAX_API_KEY")
|
||||
or litellm.api_key
|
||||
)
|
||||
|
||||
api_base = (
|
||||
api_base
|
||||
or litellm.api_base
|
||||
or get_secret_str("MINIMAX_API_BASE")
|
||||
or "https://api.minimax.io/v1"
|
||||
)
|
||||
|
||||
response = base_llm_http_handler.completion(
|
||||
model=model,
|
||||
messages=messages,
|
||||
api_base=api_base,
|
||||
custom_llm_provider=custom_llm_provider,
|
||||
model_response=model_response,
|
||||
encoding=_get_encoding(),
|
||||
logging_obj=logging,
|
||||
optional_params=optional_params,
|
||||
timeout=timeout,
|
||||
litellm_params=litellm_params,
|
||||
shared_session=shared_session,
|
||||
acompletion=acompletion,
|
||||
stream=stream,
|
||||
api_key=api_key,
|
||||
headers=headers,
|
||||
client=client,
|
||||
provider_config=provider_config,
|
||||
)
|
||||
logging.post_call(
|
||||
input=messages, api_key=api_key, original_response=response
|
||||
)
|
||||
elif (
|
||||
model in litellm.open_ai_chat_completion_models
|
||||
or custom_llm_provider == "custom_openai"
|
||||
|
|
|
|||
|
|
@ -7224,6 +7224,8 @@ class ProviderConfigManager:
|
|||
return litellm.IBMWatsonXAIConfig()
|
||||
elif litellm.LlmProviders.EMPOWER == provider:
|
||||
return litellm.EmpowerChatConfig()
|
||||
elif litellm.LlmProviders.MINIMAX == provider:
|
||||
return litellm.MinimaxChatConfig()
|
||||
elif litellm.LlmProviders.GITHUB == provider:
|
||||
return litellm.GithubChatConfig()
|
||||
elif litellm.LlmProviders.COMPACTIFAI == provider:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue