diff --git a/litellm/__init__.py b/litellm/__init__.py index f6be2bc6f00..9d00d14086f 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -1013,6 +1013,7 @@ from .llms.openai_like.chat.handler import OpenAILikeChatConfig from .llms.aiohttp_openai.chat.transformation import AiohttpOpenAIChatConfig from .llms.galadriel.chat.transformation import GaladrielChatConfig from .llms.github.chat.transformation import GithubChatConfig +from .llms.compactifai.chat.transformation import CompactifAIChatConfig from .llms.empower.chat.transformation import EmpowerChatConfig from .llms.huggingface.chat.transformation import HuggingFaceChatConfig from .llms.huggingface.embedding.transformation import HuggingFaceEmbeddingConfig diff --git a/litellm/litellm_core_utils/get_llm_provider_logic.py b/litellm/litellm_core_utils/get_llm_provider_logic.py index d5009fb0ca6..5aa29e1250e 100644 --- a/litellm/litellm_core_utils/get_llm_provider_logic.py +++ b/litellm/litellm_core_utils/get_llm_provider_logic.py @@ -372,6 +372,8 @@ def get_llm_provider( # noqa: PLR0915 custom_llm_provider = "cometapi" elif model.startswith("oci/"): custom_llm_provider = "oci" + elif model.startswith("compactifai/"): + custom_llm_provider = "compactifai" if not custom_llm_provider: if litellm.suppress_debug_info is False: print() # noqa diff --git a/litellm/main.py b/litellm/main.py index 6c81d3eded9..fa52771028b 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -2547,6 +2547,36 @@ def completion( # type: ignore # noqa: PLR0915 encoding=encoding, stream=stream, ) + elif custom_llm_provider == "compactifai": + api_key = ( + api_key + or get_secret_str("COMPACTIFAI_API_KEY") + or litellm.api_key + ) + + api_base = ( + api_base + or "https://api.compactif.ai/v1" + ) + + ## COMPLETION CALL + response = base_llm_http_handler.completion( + model=model, + messages=messages, + headers=headers, + model_response=model_response, + api_key=api_key, + api_base=api_base, + acompletion=acompletion, + logging_obj=logging, + optional_params=optional_params, + litellm_params=litellm_params, + timeout=timeout, + client=client, + custom_llm_provider=custom_llm_provider, + encoding=encoding, + stream=stream, + ) elif custom_llm_provider == "oobabooga": custom_llm_provider = "oobabooga" model_response = oobabooga.completion( diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 7f6ab8e7d08..d12afb523bb 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -2327,6 +2327,7 @@ class LlmProviders(str, Enum): DATABRICKS = "databricks" EMPOWER = "empower" GITHUB = "github" + COMPACTIFAI = "compactifai" CUSTOM = "custom" LITELLM_PROXY = "litellm_proxy" HOSTED_VLLM = "hosted_vllm" diff --git a/litellm/utils.py b/litellm/utils.py index 0d2fe5d4d64..7236e0c6afe 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -6931,6 +6931,8 @@ class ProviderConfigManager: return litellm.EmpowerChatConfig() elif litellm.LlmProviders.GITHUB == provider: return litellm.GithubChatConfig() + elif litellm.LlmProviders.COMPACTIFAI == provider: + return litellm.CompactifAIChatConfig() elif litellm.LlmProviders.GITHUB_COPILOT == provider: return litellm.GithubCopilotConfig() elif (