Skip to content

Commit e0dacfe

Browse files
committed
Wire up Llamafile
1 parent 141bceb commit e0dacfe

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

litellm/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
from litellm.litellm_core_utils.logging_callback_manager import LoggingCallbackManager
7373
import httpx
7474
import dotenv
75-
from enum import Enum
7675

7776
litellm_mode = os.getenv("LITELLM_MODE", "DEV") # "PRODUCTION", "DEV"
7877
if litellm_mode == "DEV":
@@ -1012,6 +1011,7 @@ def add_known_models():
10121011
from .llms.azure.chat.gpt_transformation import AzureOpenAIConfig
10131012
from .llms.azure.completion.transformation import AzureOpenAITextConfig
10141013
from .llms.hosted_vllm.chat.transformation import HostedVLLMChatConfig
1014+
from .llms.llamafile.chat.transformation import LlamafileChatConfig
10151015
from .llms.litellm_proxy.chat.transformation import LiteLLMProxyChatConfig
10161016
from .llms.vllm.completion.transformation import VLLMConfig
10171017
from .llms.deepseek.chat.transformation import DeepSeekChatConfig

litellm/litellm_core_utils/get_llm_provider_logic.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def get_llm_provider( # noqa: PLR0915
101101
102102
Return model, custom_llm_provider, dynamic_api_key, api_base
103103
"""
104-
105104
try:
106105
## IF LITELLM PARAMS GIVEN ##
107106
if litellm_params is not None:
@@ -477,6 +476,12 @@ def _get_openai_compatible_provider_info( # noqa: PLR0915
477476
) = litellm.HostedVLLMChatConfig()._get_openai_compatible_provider_info(
478477
api_base, api_key
479478
)
479+
elif custom_llm_provider == "llamafile":
480+
# llamafile is OpenAI compatible.
481+
(api_base, dynamic_api_key) = litellm.LlamafileChatConfig()._get_openai_compatible_provider_info(
482+
api_base,
483+
api_key
484+
)
480485
elif custom_llm_provider == "lm_studio":
481486
# lm_studio is openai compatible, we just need to set this to custom_openai
482487
(

litellm/main.py

+1
Original file line numberDiff line numberDiff line change
@@ -3578,6 +3578,7 @@ def embedding( # noqa: PLR0915
35783578
custom_llm_provider == "openai_like"
35793579
or custom_llm_provider == "jina_ai"
35803580
or custom_llm_provider == "hosted_vllm"
3581+
or custom_llm_provider == "llamafile"
35813582
or custom_llm_provider == "lm_studio"
35823583
):
35833584
api_base = (

litellm/utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -6455,6 +6455,8 @@ def get_provider_chat_config( # noqa: PLR0915
64556455
return litellm.AiohttpOpenAIChatConfig()
64566456
elif litellm.LlmProviders.HOSTED_VLLM == provider:
64576457
return litellm.HostedVLLMChatConfig()
6458+
elif litellm.LlmProviders.LLAMAFILE == provider:
6459+
return litellm.LlamafileChatConfig()
64586460
elif litellm.LlmProviders.LM_STUDIO == provider:
64596461
return litellm.LMStudioChatConfig()
64606462
elif litellm.LlmProviders.GALADRIEL == provider:

0 commit comments

Comments
 (0)