mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
add cerebras api
This commit is contained in:
parent
ccbbb4f3f8
commit
6aaa7a75cd
3 changed files with 35 additions and 0 deletions
|
@ -452,6 +452,7 @@ openai_compatible_providers: List = [
|
||||||
"mistral",
|
"mistral",
|
||||||
"groq",
|
"groq",
|
||||||
"nvidia_nim",
|
"nvidia_nim",
|
||||||
|
"cerebras",
|
||||||
"volcengine",
|
"volcengine",
|
||||||
"codestral",
|
"codestral",
|
||||||
"deepseek",
|
"deepseek",
|
||||||
|
@ -690,6 +691,7 @@ provider_list: List = [
|
||||||
"mistral",
|
"mistral",
|
||||||
"groq",
|
"groq",
|
||||||
"nvidia_nim",
|
"nvidia_nim",
|
||||||
|
"cerebras",
|
||||||
"volcengine",
|
"volcengine",
|
||||||
"codestral",
|
"codestral",
|
||||||
"text-completion-codestral",
|
"text-completion-codestral",
|
||||||
|
@ -905,6 +907,7 @@ from .llms.openai import (
|
||||||
AzureAIStudioConfig,
|
AzureAIStudioConfig,
|
||||||
)
|
)
|
||||||
from .llms.nvidia_nim import NvidiaNimConfig
|
from .llms.nvidia_nim import NvidiaNimConfig
|
||||||
|
from .llms.cerebras.chat import CerebrasConfig
|
||||||
from .llms.fireworks_ai import FireworksAIConfig
|
from .llms.fireworks_ai import FireworksAIConfig
|
||||||
from .llms.volcengine import VolcEngineConfig
|
from .llms.volcengine import VolcEngineConfig
|
||||||
from .llms.text_completion_codestral import MistralTextCompletionConfig
|
from .llms.text_completion_codestral import MistralTextCompletionConfig
|
||||||
|
|
|
@ -390,6 +390,7 @@ async def acompletion(
|
||||||
or custom_llm_provider == "perplexity"
|
or custom_llm_provider == "perplexity"
|
||||||
or custom_llm_provider == "groq"
|
or custom_llm_provider == "groq"
|
||||||
or custom_llm_provider == "nvidia_nim"
|
or custom_llm_provider == "nvidia_nim"
|
||||||
|
or custom_llm_provider == "cerebras"
|
||||||
or custom_llm_provider == "volcengine"
|
or custom_llm_provider == "volcengine"
|
||||||
or custom_llm_provider == "codestral"
|
or custom_llm_provider == "codestral"
|
||||||
or custom_llm_provider == "text-completion-codestral"
|
or custom_llm_provider == "text-completion-codestral"
|
||||||
|
@ -1295,6 +1296,7 @@ def completion(
|
||||||
or custom_llm_provider == "perplexity"
|
or custom_llm_provider == "perplexity"
|
||||||
or custom_llm_provider == "groq"
|
or custom_llm_provider == "groq"
|
||||||
or custom_llm_provider == "nvidia_nim"
|
or custom_llm_provider == "nvidia_nim"
|
||||||
|
or custom_llm_provider == "cerebras"
|
||||||
or custom_llm_provider == "volcengine"
|
or custom_llm_provider == "volcengine"
|
||||||
or custom_llm_provider == "codestral"
|
or custom_llm_provider == "codestral"
|
||||||
or custom_llm_provider == "deepseek"
|
or custom_llm_provider == "deepseek"
|
||||||
|
@ -3144,6 +3146,7 @@ async def aembedding(*args, **kwargs) -> EmbeddingResponse:
|
||||||
or custom_llm_provider == "perplexity"
|
or custom_llm_provider == "perplexity"
|
||||||
or custom_llm_provider == "groq"
|
or custom_llm_provider == "groq"
|
||||||
or custom_llm_provider == "nvidia_nim"
|
or custom_llm_provider == "nvidia_nim"
|
||||||
|
or custom_llm_provider == "cerebras"
|
||||||
or custom_llm_provider == "volcengine"
|
or custom_llm_provider == "volcengine"
|
||||||
or custom_llm_provider == "deepseek"
|
or custom_llm_provider == "deepseek"
|
||||||
or custom_llm_provider == "fireworks_ai"
|
or custom_llm_provider == "fireworks_ai"
|
||||||
|
@ -3795,6 +3798,7 @@ async def atext_completion(
|
||||||
or custom_llm_provider == "perplexity"
|
or custom_llm_provider == "perplexity"
|
||||||
or custom_llm_provider == "groq"
|
or custom_llm_provider == "groq"
|
||||||
or custom_llm_provider == "nvidia_nim"
|
or custom_llm_provider == "nvidia_nim"
|
||||||
|
or custom_llm_provider == "cerebras"
|
||||||
or custom_llm_provider == "volcengine"
|
or custom_llm_provider == "volcengine"
|
||||||
or custom_llm_provider == "text-completion-codestral"
|
or custom_llm_provider == "text-completion-codestral"
|
||||||
or custom_llm_provider == "deepseek"
|
or custom_llm_provider == "deepseek"
|
||||||
|
|
|
@ -2854,6 +2854,7 @@ def get_optional_params(
|
||||||
and custom_llm_provider != "together_ai"
|
and custom_llm_provider != "together_ai"
|
||||||
and custom_llm_provider != "groq"
|
and custom_llm_provider != "groq"
|
||||||
and custom_llm_provider != "nvidia_nim"
|
and custom_llm_provider != "nvidia_nim"
|
||||||
|
and custom_llm_provider != "cerebras"
|
||||||
and custom_llm_provider != "volcengine"
|
and custom_llm_provider != "volcengine"
|
||||||
and custom_llm_provider != "deepseek"
|
and custom_llm_provider != "deepseek"
|
||||||
and custom_llm_provider != "codestral"
|
and custom_llm_provider != "codestral"
|
||||||
|
@ -3613,6 +3614,16 @@ def get_optional_params(
|
||||||
non_default_params=non_default_params,
|
non_default_params=non_default_params,
|
||||||
optional_params=optional_params,
|
optional_params=optional_params,
|
||||||
)
|
)
|
||||||
|
elif custom_llm_provider == "cerebras":
|
||||||
|
supported_params = get_supported_openai_params(
|
||||||
|
model=model, custom_llm_provider=custom_llm_provider
|
||||||
|
)
|
||||||
|
_check_valid_arg(supported_params=supported_params)
|
||||||
|
optional_params = litellm.CerebrasConfig().map_openai_params(
|
||||||
|
non_default_params=non_default_params,
|
||||||
|
optional_params=optional_params,
|
||||||
|
model=model,
|
||||||
|
)
|
||||||
elif custom_llm_provider == "fireworks_ai":
|
elif custom_llm_provider == "fireworks_ai":
|
||||||
supported_params = get_supported_openai_params(
|
supported_params = get_supported_openai_params(
|
||||||
model=model, custom_llm_provider=custom_llm_provider
|
model=model, custom_llm_provider=custom_llm_provider
|
||||||
|
@ -4238,6 +4249,8 @@ def get_supported_openai_params(
|
||||||
return litellm.FireworksAIConfig().get_supported_openai_params()
|
return litellm.FireworksAIConfig().get_supported_openai_params()
|
||||||
elif custom_llm_provider == "nvidia_nim":
|
elif custom_llm_provider == "nvidia_nim":
|
||||||
return litellm.NvidiaNimConfig().get_supported_openai_params(model=model)
|
return litellm.NvidiaNimConfig().get_supported_openai_params(model=model)
|
||||||
|
elif custom_llm_provider == "cerebras":
|
||||||
|
return litellm.CerebrasConfig().get_supported_openai_params(model=model)
|
||||||
elif custom_llm_provider == "volcengine":
|
elif custom_llm_provider == "volcengine":
|
||||||
return litellm.VolcEngineConfig().get_supported_openai_params(model=model)
|
return litellm.VolcEngineConfig().get_supported_openai_params(model=model)
|
||||||
elif custom_llm_provider == "groq":
|
elif custom_llm_provider == "groq":
|
||||||
|
@ -4665,6 +4678,13 @@ def get_llm_provider(
|
||||||
or "https://integrate.api.nvidia.com/v1"
|
or "https://integrate.api.nvidia.com/v1"
|
||||||
) # type: ignore
|
) # type: ignore
|
||||||
dynamic_api_key = api_key or get_secret("NVIDIA_NIM_API_KEY")
|
dynamic_api_key = api_key or get_secret("NVIDIA_NIM_API_KEY")
|
||||||
|
elif custom_llm_provider == "cerebras":
|
||||||
|
api_base = (
|
||||||
|
api_base
|
||||||
|
or get_secret("CEREBRAS_API_BASE")
|
||||||
|
or "https://api.cerebras.ai/v1"
|
||||||
|
) # type: ignore
|
||||||
|
dynamic_api_key = api_key or get_secret("CEREBRAS_API_KEY")
|
||||||
elif custom_llm_provider == "volcengine":
|
elif custom_llm_provider == "volcengine":
|
||||||
# volcengine is openai compatible, we just need to set this to custom_openai and have the api_base be https://api.endpoints.anyscale.com/v1
|
# volcengine is openai compatible, we just need to set this to custom_openai and have the api_base be https://api.endpoints.anyscale.com/v1
|
||||||
api_base = (
|
api_base = (
|
||||||
|
@ -4815,6 +4835,9 @@ def get_llm_provider(
|
||||||
elif endpoint == "https://integrate.api.nvidia.com/v1":
|
elif endpoint == "https://integrate.api.nvidia.com/v1":
|
||||||
custom_llm_provider = "nvidia_nim"
|
custom_llm_provider = "nvidia_nim"
|
||||||
dynamic_api_key = get_secret("NVIDIA_NIM_API_KEY")
|
dynamic_api_key = get_secret("NVIDIA_NIM_API_KEY")
|
||||||
|
elif endpoint == "https://api.cerebras.ai/v1":
|
||||||
|
custom_llm_provider = "cerebras"
|
||||||
|
dynamic_api_key = get_secret("CEREBRAS_API_KEY")
|
||||||
elif endpoint == "https://codestral.mistral.ai/v1":
|
elif endpoint == "https://codestral.mistral.ai/v1":
|
||||||
custom_llm_provider = "codestral"
|
custom_llm_provider = "codestral"
|
||||||
dynamic_api_key = get_secret("CODESTRAL_API_KEY")
|
dynamic_api_key = get_secret("CODESTRAL_API_KEY")
|
||||||
|
@ -5734,6 +5757,11 @@ def validate_environment(
|
||||||
keys_in_environment = True
|
keys_in_environment = True
|
||||||
else:
|
else:
|
||||||
missing_keys.append("NVIDIA_NIM_API_KEY")
|
missing_keys.append("NVIDIA_NIM_API_KEY")
|
||||||
|
elif custom_llm_provider == "cerebras":
|
||||||
|
if "CEREBRAS_API_KEY" in os.environ:
|
||||||
|
keys_in_environment = True
|
||||||
|
else:
|
||||||
|
missing_keys.append("CEREBRAS_API_KEY")
|
||||||
elif custom_llm_provider == "volcengine":
|
elif custom_llm_provider == "volcengine":
|
||||||
if "VOLCENGINE_API_KEY" in os.environ:
|
if "VOLCENGINE_API_KEY" in os.environ:
|
||||||
keys_in_environment = True
|
keys_in_environment = True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue