mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
feat: add HPC-AI model provider support
Made-with: Cursor
This commit is contained in:
parent
437341c9b5
commit
f0ea81acce
19 changed files with 342 additions and 0 deletions
|
|
@ -22,6 +22,9 @@ ANTHROPIC_API_KEY = ""
|
|||
INFISICAL_TOKEN = ""
|
||||
# Novita AI
|
||||
NOVITA_API_KEY = ""
|
||||
# HPC-AI (OpenAI-compatible inference)
|
||||
HPC_AI_API_KEY = ""
|
||||
HPC_AI_API_BASE = ""
|
||||
# INFINITY
|
||||
INFINITY_API_KEY = ""
|
||||
|
||||
|
|
|
|||
86
docs/my-website/docs/providers/hpc_ai.md
Normal file
86
docs/my-website/docs/providers/hpc_ai.md
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
# HPC-AI
|
||||
|
||||
[HPC-AI](https://api.hpc-ai.com) provides an OpenAI-compatible inference API at `https://api.hpc-ai.com/inference/v1`.
|
||||
|
||||
:::tip
|
||||
|
||||
Use the `hpc_ai/` prefix with the upstream model id (for example `hpc_ai/minimax/minimax-m2.5`). LiteLLM strips the prefix and forwards the remainder as the OpenAI `model` field.
|
||||
|
||||
:::
|
||||
|
||||
## API Key
|
||||
|
||||
```python
|
||||
import os
|
||||
|
||||
os.environ["HPC_AI_API_KEY"] = "your-api-key"
|
||||
```
|
||||
|
||||
Optional: override the base URL (defaults to `https://api.hpc-ai.com/inference/v1`).
|
||||
|
||||
```python
|
||||
os.environ["HPC_AI_API_BASE"] = "https://api.hpc-ai.com/inference/v1"
|
||||
```
|
||||
|
||||
If you use another env name such as `HPC_AI_BASE_URL`, map it to `api_base` in your LiteLLM call or proxy `litellm_params`; LiteLLM reads `HPC_AI_API_BASE` by default.
|
||||
|
||||
## Sample Usage: Chat completion
|
||||
|
||||
```python
|
||||
from litellm import completion
|
||||
import os
|
||||
|
||||
os.environ["HPC_AI_API_KEY"] = "your-api-key"
|
||||
response = completion(
|
||||
model="hpc_ai/minimax/minimax-m2.5",
|
||||
messages=[{"role": "user", "content": "Hello!"}],
|
||||
max_tokens=256,
|
||||
)
|
||||
print(response)
|
||||
```
|
||||
|
||||
## Sample Usage: Streaming
|
||||
|
||||
```python
|
||||
from litellm import completion
|
||||
import os
|
||||
|
||||
os.environ["HPC_AI_API_KEY"] = "your-api-key"
|
||||
response = completion(
|
||||
model="hpc_ai/moonshotai/kimi-k2.5",
|
||||
messages=[{"role": "user", "content": "Hello!"}],
|
||||
stream=True,
|
||||
)
|
||||
|
||||
for chunk in response:
|
||||
print(chunk)
|
||||
```
|
||||
|
||||
## Usage with LiteLLM Proxy Server
|
||||
|
||||
1. Add a model to your `config.yaml`:
|
||||
|
||||
```yaml
|
||||
model_list:
|
||||
- model_name: hpc-ai-minimax
|
||||
litellm_params:
|
||||
model: hpc_ai/minimax/minimax-m2.5
|
||||
api_key: os.environ/HPC_AI_API_KEY
|
||||
```
|
||||
|
||||
2. Start the proxy:
|
||||
|
||||
```bash
|
||||
litellm --config /path/to/config.yaml
|
||||
```
|
||||
|
||||
3. Send requests to the proxy using your alias (`hpc-ai-minimax` in the example above).
|
||||
|
||||
## Supported models (examples)
|
||||
|
||||
| LiteLLM model id | Notes |
|
||||
| ---------------- | ----- |
|
||||
| `hpc_ai/minimax/minimax-m2.5` | MiniMax M2.5 |
|
||||
| `hpc_ai/moonshotai/kimi-k2.5` | Kimi K2.5 |
|
||||
|
||||
Pricing in `model_prices_and_context_window.json` may use placeholder token costs; set real rates when your billing API is available.
|
||||
|
|
@ -943,6 +943,7 @@ const sidebars = {
|
|||
"providers/moonshot",
|
||||
"providers/morph",
|
||||
"providers/nebius",
|
||||
"providers/hpc_ai",
|
||||
"providers/nlp_cloud",
|
||||
"providers/nano-gpt",
|
||||
"providers/novita",
|
||||
|
|
|
|||
|
|
@ -254,6 +254,7 @@ novita_api_key: Optional[str] = None
|
|||
snowflake_key: Optional[str] = None
|
||||
gradient_ai_api_key: Optional[str] = None
|
||||
nebius_key: Optional[str] = None
|
||||
hpc_ai_key: Optional[str] = None
|
||||
wandb_key: Optional[str] = None
|
||||
heroku_key: Optional[str] = None
|
||||
cometapi_key: Optional[str] = None
|
||||
|
|
@ -569,6 +570,7 @@ llama_models: Set = set()
|
|||
nscale_models: Set = set()
|
||||
nebius_models: Set = set()
|
||||
nebius_embedding_models: Set = set()
|
||||
hpc_ai_models: Set = set()
|
||||
aiml_models: Set = set()
|
||||
deepgram_models: Set = set()
|
||||
elevenlabs_models: Set = set()
|
||||
|
|
@ -795,6 +797,8 @@ def add_known_models(model_cost_map: Optional[Dict] = None):
|
|||
nebius_models.add(key)
|
||||
elif value.get("litellm_provider") == "nebius-embedding-models":
|
||||
nebius_embedding_models.add(key)
|
||||
elif value.get("litellm_provider") == "hpc_ai":
|
||||
hpc_ai_models.add(key)
|
||||
elif value.get("litellm_provider") == "aiml":
|
||||
aiml_models.add(key)
|
||||
elif value.get("litellm_provider") == "assemblyai":
|
||||
|
|
@ -947,6 +951,7 @@ model_list = list(
|
|||
| sambanova_models
|
||||
| azure_text_models
|
||||
| novita_models
|
||||
| hpc_ai_models
|
||||
| assemblyai_models
|
||||
| jina_ai_models
|
||||
| snowflake_models
|
||||
|
|
@ -1043,6 +1048,7 @@ models_by_provider: dict = {
|
|||
"sambanova": sambanova_models | sambanova_embedding_models,
|
||||
"novita": novita_models,
|
||||
"nebius": nebius_models | nebius_embedding_models,
|
||||
"hpc_ai": hpc_ai_models,
|
||||
"aiml": aiml_models,
|
||||
"assemblyai": assemblyai_models,
|
||||
"jina_ai": jina_ai_models,
|
||||
|
|
@ -1826,6 +1832,7 @@ if TYPE_CHECKING:
|
|||
GigaChatEmbeddingConfig as GigaChatEmbeddingConfig,
|
||||
)
|
||||
from .llms.nebius.chat.transformation import NebiusConfig as NebiusConfig
|
||||
from .llms.hpc_ai.chat.transformation import HpcAiConfig as HpcAiConfig
|
||||
from .llms.wandb.chat.transformation import WandbConfig as WandbConfig
|
||||
from .llms.dashscope.chat.transformation import (
|
||||
DashScopeChatConfig as DashScopeChatConfig,
|
||||
|
|
|
|||
|
|
@ -295,6 +295,7 @@ LLM_CONFIG_NAMES = (
|
|||
"ManusResponsesAPIConfig",
|
||||
"GithubCopilotEmbeddingConfig",
|
||||
"NebiusConfig",
|
||||
"HpcAiConfig",
|
||||
"WandbConfig",
|
||||
"GigaChatConfig",
|
||||
"GigaChatEmbeddingConfig",
|
||||
|
|
@ -1115,6 +1116,7 @@ _LLM_CONFIGS_IMPORT_MAP = {
|
|||
"ChatGPTResponsesAPIConfig",
|
||||
),
|
||||
"NebiusConfig": (".llms.nebius.chat.transformation", "NebiusConfig"),
|
||||
"HpcAiConfig": (".llms.hpc_ai.chat.transformation", "HpcAiConfig"),
|
||||
"WandbConfig": (".llms.wandb.chat.transformation", "WandbConfig"),
|
||||
"GigaChatConfig": (".llms.gigachat.chat.transformation", "GigaChatConfig"),
|
||||
"GigaChatEmbeddingConfig": (
|
||||
|
|
|
|||
|
|
@ -558,6 +558,7 @@ LITELLM_CHAT_PROVIDERS = [
|
|||
"featherless_ai",
|
||||
"nscale",
|
||||
"nebius",
|
||||
"hpc_ai",
|
||||
"dashscope",
|
||||
"moonshot",
|
||||
"publicai",
|
||||
|
|
@ -713,6 +714,7 @@ openai_compatible_endpoints: List = [
|
|||
"api.featherless.ai/v1",
|
||||
"inference.api.nscale.com/v1",
|
||||
"api.studio.nebius.ai/v1",
|
||||
"api.hpc-ai.com/inference/v1",
|
||||
"https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
|
||||
"https://api.moonshot.ai/v1",
|
||||
"https://api.publicai.co/v1",
|
||||
|
|
@ -773,6 +775,7 @@ openai_compatible_providers: List = [
|
|||
"featherless_ai",
|
||||
"nscale",
|
||||
"nebius",
|
||||
"hpc_ai",
|
||||
"dashscope",
|
||||
"moonshot",
|
||||
"v0",
|
||||
|
|
|
|||
|
|
@ -324,6 +324,9 @@ def get_llm_provider( # noqa: PLR0915
|
|||
elif endpoint == "https://api.inference.wandb.ai/v1":
|
||||
custom_llm_provider = "wandb"
|
||||
dynamic_api_key = get_secret_str("WANDB_API_KEY")
|
||||
elif endpoint == "api.hpc-ai.com/inference/v1":
|
||||
custom_llm_provider = "hpc_ai"
|
||||
dynamic_api_key = get_secret_str("HPC_AI_API_KEY")
|
||||
|
||||
if api_base is not None and not isinstance(api_base, str):
|
||||
raise Exception(
|
||||
|
|
@ -619,6 +622,13 @@ def _get_openai_compatible_provider_info( # noqa: PLR0915
|
|||
or "https://api.studio.nebius.ai/v1"
|
||||
) # type: ignore
|
||||
dynamic_api_key = api_key or get_secret_str("NEBIUS_API_KEY")
|
||||
elif custom_llm_provider == "hpc_ai":
|
||||
(
|
||||
api_base,
|
||||
dynamic_api_key,
|
||||
) = litellm.HpcAiConfig()._get_openai_compatible_provider_info(
|
||||
api_base, api_key
|
||||
)
|
||||
elif custom_llm_provider == "ollama":
|
||||
api_base = (
|
||||
api_base or get_secret("OLLAMA_API_BASE") or "http://localhost:11434"
|
||||
|
|
|
|||
|
|
@ -170,6 +170,9 @@ def get_supported_openai_params( # noqa: PLR0915
|
|||
elif custom_llm_provider == "nebius":
|
||||
if request_type == "chat_completion":
|
||||
return litellm.NebiusConfig().get_supported_openai_params(model=model)
|
||||
elif custom_llm_provider == "hpc_ai":
|
||||
if request_type == "chat_completion":
|
||||
return litellm.HpcAiConfig().get_supported_openai_params(model=model)
|
||||
elif custom_llm_provider == "wandb":
|
||||
if request_type == "chat_completion":
|
||||
return litellm.WandbConfig().get_supported_openai_params(model=model)
|
||||
|
|
|
|||
39
litellm/llms/hpc_ai/chat/transformation.py
Normal file
39
litellm/llms/hpc_ai/chat/transformation.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
"""
|
||||
HPC-AI Chat Completions API — OpenAI-compatible endpoint.
|
||||
|
||||
Reference: https://api.hpc-ai.com/inference/v1
|
||||
"""
|
||||
|
||||
from typing import Optional, Tuple
|
||||
|
||||
from litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfig
|
||||
from litellm.secret_managers.main import get_secret_str
|
||||
|
||||
|
||||
class HpcAiConfig(OpenAIGPTConfig):
|
||||
def map_openai_params(
|
||||
self,
|
||||
non_default_params: dict,
|
||||
optional_params: dict,
|
||||
model: str,
|
||||
drop_params: bool,
|
||||
) -> dict:
|
||||
"""Map max_completion_tokens to max_tokens for OpenAI-compatible API."""
|
||||
supported_openai_params = self.get_supported_openai_params(model=model)
|
||||
for param, value in non_default_params.items():
|
||||
if param == "max_completion_tokens":
|
||||
optional_params["max_tokens"] = value
|
||||
elif param in supported_openai_params:
|
||||
optional_params[param] = value
|
||||
return optional_params
|
||||
|
||||
def _get_openai_compatible_provider_info(
|
||||
self, api_base: Optional[str], api_key: Optional[str]
|
||||
) -> Tuple[Optional[str], Optional[str]]:
|
||||
api_base = (
|
||||
api_base
|
||||
or get_secret_str("HPC_AI_API_BASE")
|
||||
or "https://api.hpc-ai.com/inference/v1"
|
||||
)
|
||||
dynamic_api_key = api_key or get_secret_str("HPC_AI_API_KEY")
|
||||
return api_base, dynamic_api_key
|
||||
5
litellm/proxy/_experimental/out/assets/logos/hpc_ai.svg
Normal file
5
litellm/proxy/_experimental/out/assets/logos/hpc_ai.svg
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg fill="#000000" viewBox="-2 -2 28 28" role="img" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="12" cy="12" r="14" fill="white" />
|
||||
<path d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
|
@ -1792,6 +1792,34 @@
|
|||
],
|
||||
"default_model_placeholder": "gpt-3.5-turbo"
|
||||
},
|
||||
{
|
||||
"provider": "HPC_AI",
|
||||
"provider_display_name": "HPC-AI",
|
||||
"litellm_provider": "hpc_ai",
|
||||
"credential_fields": [
|
||||
{
|
||||
"key": "api_base",
|
||||
"label": "API Base",
|
||||
"placeholder": null,
|
||||
"tooltip": null,
|
||||
"required": false,
|
||||
"field_type": "text",
|
||||
"options": null,
|
||||
"default_value": null
|
||||
},
|
||||
{
|
||||
"key": "api_key",
|
||||
"label": "API Key",
|
||||
"placeholder": null,
|
||||
"tooltip": null,
|
||||
"required": false,
|
||||
"field_type": "password",
|
||||
"options": null,
|
||||
"default_value": null
|
||||
}
|
||||
],
|
||||
"default_model_placeholder": "hpc_ai/minimax/minimax-m2.5"
|
||||
},
|
||||
{
|
||||
"provider": "NLP_CLOUD",
|
||||
"provider_display_name": "Nlp Cloud",
|
||||
|
|
|
|||
|
|
@ -3227,6 +3227,7 @@ class LlmProviders(str, Enum):
|
|||
LM_STUDIO = "lm_studio"
|
||||
GALADRIEL = "galadriel"
|
||||
NEBIUS = "nebius"
|
||||
HPC_AI = "hpc_ai"
|
||||
INFINITY = "infinity"
|
||||
DEEPGRAM = "deepgram"
|
||||
ELEVENLABS = "elevenlabs"
|
||||
|
|
|
|||
|
|
@ -4638,6 +4638,17 @@ def get_optional_params( # noqa: PLR0915
|
|||
else False
|
||||
),
|
||||
)
|
||||
elif custom_llm_provider == "hpc_ai":
|
||||
optional_params = litellm.HpcAiConfig().map_openai_params(
|
||||
non_default_params=non_default_params,
|
||||
optional_params=optional_params,
|
||||
model=model,
|
||||
drop_params=(
|
||||
drop_params
|
||||
if drop_params is not None and isinstance(drop_params, bool)
|
||||
else False
|
||||
),
|
||||
)
|
||||
elif custom_llm_provider == "azure":
|
||||
if litellm.AzureOpenAIO1Config().is_o_series_model(model=model):
|
||||
optional_params = litellm.AzureOpenAIO1Config().map_openai_params(
|
||||
|
|
@ -5131,6 +5142,9 @@ def get_api_key(llm_provider: str, dynamic_api_key: Optional[str]):
|
|||
# nebius
|
||||
elif llm_provider == "nebius":
|
||||
api_key = api_key or litellm.nebius_key or get_secret("NEBIUS_API_KEY")
|
||||
# hpc_ai
|
||||
elif llm_provider == "hpc_ai":
|
||||
api_key = api_key or litellm.hpc_ai_key or get_secret("HPC_AI_API_KEY")
|
||||
# wandb
|
||||
elif llm_provider == "wandb":
|
||||
api_key = api_key or litellm.wandb_key or get_secret("WANDB_API_KEY")
|
||||
|
|
@ -6436,6 +6450,11 @@ def validate_environment( # noqa: PLR0915
|
|||
keys_in_environment = True
|
||||
else:
|
||||
missing_keys.append("NEBIUS_API_KEY")
|
||||
elif custom_llm_provider == "hpc_ai":
|
||||
if "HPC_AI_API_KEY" in os.environ:
|
||||
keys_in_environment = True
|
||||
else:
|
||||
missing_keys.append("HPC_AI_API_KEY")
|
||||
elif custom_llm_provider == "wandb":
|
||||
if "WANDB_API_KEY" in os.environ:
|
||||
keys_in_environment = True
|
||||
|
|
@ -6558,6 +6577,11 @@ def validate_environment( # noqa: PLR0915
|
|||
keys_in_environment = True
|
||||
else:
|
||||
missing_keys.append("NEBIUS_API_KEY")
|
||||
elif model in litellm.hpc_ai_models:
|
||||
if "HPC_AI_API_KEY" in os.environ:
|
||||
keys_in_environment = True
|
||||
else:
|
||||
missing_keys.append("HPC_AI_API_KEY")
|
||||
elif model in litellm.wandb_models:
|
||||
if "WANDB_API_KEY" in os.environ:
|
||||
keys_in_environment = True
|
||||
|
|
@ -8082,6 +8106,7 @@ class ProviderConfigManager:
|
|||
LlmProviders.FEATHERLESS_AI: (lambda: litellm.FeatherlessAIConfig(), False),
|
||||
LlmProviders.NOVITA: (lambda: litellm.NovitaConfig(), False),
|
||||
LlmProviders.NEBIUS: (lambda: litellm.NebiusConfig(), False),
|
||||
LlmProviders.HPC_AI: (lambda: litellm.HpcAiConfig(), False),
|
||||
LlmProviders.WANDB: (lambda: litellm.WandbConfig(), False),
|
||||
LlmProviders.DASHSCOPE: (lambda: litellm.DashScopeChatConfig(), False),
|
||||
LlmProviders.MOONSHOT: (lambda: litellm.MoonshotChatConfig(), False),
|
||||
|
|
|
|||
|
|
@ -20188,6 +20188,28 @@
|
|||
"/v1/images/generations"
|
||||
]
|
||||
},
|
||||
"hpc_ai/minimax/minimax-m2.5": {
|
||||
"max_tokens": 262144,
|
||||
"max_input_tokens": 262144,
|
||||
"max_output_tokens": 262144,
|
||||
"input_cost_per_token": 0.0,
|
||||
"output_cost_per_token": 0.0,
|
||||
"litellm_provider": "hpc_ai",
|
||||
"mode": "chat",
|
||||
"supports_function_calling": true,
|
||||
"source": "https://api.hpc-ai.com/inference/v1"
|
||||
},
|
||||
"hpc_ai/moonshotai/kimi-k2.5": {
|
||||
"max_tokens": 262144,
|
||||
"max_input_tokens": 262144,
|
||||
"max_output_tokens": 262144,
|
||||
"input_cost_per_token": 0.0,
|
||||
"output_cost_per_token": 0.0,
|
||||
"litellm_provider": "hpc_ai",
|
||||
"mode": "chat",
|
||||
"supports_function_calling": true,
|
||||
"source": "https://api.hpc-ai.com/inference/v1"
|
||||
},
|
||||
"hyperbolic/NousResearch/Hermes-3-Llama-3.1-70B": {
|
||||
"input_cost_per_token": 1.2e-07,
|
||||
"litellm_provider": "hyperbolic",
|
||||
|
|
|
|||
|
|
@ -1503,6 +1503,24 @@
|
|||
"interactions": true
|
||||
}
|
||||
},
|
||||
"hpc_ai": {
|
||||
"display_name": "HPC-AI (`hpc_ai`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/hpc_ai",
|
||||
"endpoints": {
|
||||
"chat_completions": true,
|
||||
"messages": true,
|
||||
"responses": false,
|
||||
"embeddings": false,
|
||||
"image_generations": false,
|
||||
"audio_transcriptions": false,
|
||||
"audio_speech": false,
|
||||
"moderations": false,
|
||||
"batches": false,
|
||||
"rerank": false,
|
||||
"a2a": true,
|
||||
"interactions": true
|
||||
}
|
||||
},
|
||||
"nlp_cloud": {
|
||||
"display_name": "NLP Cloud (`nlp_cloud`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/nlp_cloud",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
"""
|
||||
Unit tests for HPC-AI OpenAI-compatible configuration.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.abspath("../../../../.."))
|
||||
|
||||
import pytest
|
||||
|
||||
import litellm
|
||||
from litellm import completion
|
||||
from litellm.llms.hpc_ai.chat.transformation import HpcAiConfig
|
||||
|
||||
|
||||
class TestHpcAiConfig:
|
||||
def test_validate_environment_sets_auth_header(self):
|
||||
config = HpcAiConfig()
|
||||
headers = {}
|
||||
api_key = "fake-hpc-ai-key"
|
||||
result = config.validate_environment(
|
||||
headers=headers,
|
||||
model="hpc_ai/minimax/minimax-m2.5",
|
||||
messages=[{"role": "user", "content": "Hey"}],
|
||||
optional_params={},
|
||||
litellm_params={},
|
||||
api_key=api_key,
|
||||
api_base=None,
|
||||
)
|
||||
assert result["Authorization"] == f"Bearer {api_key}"
|
||||
assert result["Content-Type"] == "application/json"
|
||||
|
||||
@pytest.mark.respx()
|
||||
def test_hpc_ai_completion_mock(self, respx_mock):
|
||||
litellm.disable_aiohttp_transport = True
|
||||
|
||||
api_key = "fake-hpc-ai-key"
|
||||
api_base = "https://api.hpc-ai.com/inference/v1"
|
||||
model = "hpc_ai/minimax/minimax-m2.5"
|
||||
model_name = "minimax/minimax-m2.5"
|
||||
|
||||
respx_mock.post(f"{api_base}/chat/completions").respond(
|
||||
json={
|
||||
"id": "chatcmpl-hpc-1",
|
||||
"object": "chat.completion",
|
||||
"created": 1677652288,
|
||||
"model": model_name,
|
||||
"choices": [
|
||||
{
|
||||
"index": 0,
|
||||
"message": {
|
||||
"role": "assistant",
|
||||
"content": "Hello from HPC-AI.",
|
||||
},
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
],
|
||||
"usage": {
|
||||
"prompt_tokens": 5,
|
||||
"completion_tokens": 8,
|
||||
"total_tokens": 13,
|
||||
},
|
||||
},
|
||||
status_code=200,
|
||||
)
|
||||
|
||||
response = completion(
|
||||
model=model,
|
||||
messages=[{"role": "user", "content": "Hello"}],
|
||||
api_key=api_key,
|
||||
api_base=api_base,
|
||||
)
|
||||
|
||||
assert response.choices[0].message.content == "Hello from HPC-AI."
|
||||
5
ui/litellm-dashboard/public/assets/logos/hpc_ai.svg
Normal file
5
ui/litellm-dashboard/public/assets/logos/hpc_ai.svg
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg fill="#000000" viewBox="-2 -2 28 28" role="img" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="12" cy="12" r="14" fill="white" />
|
||||
<path d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
|
@ -144,6 +144,10 @@ describe("provider_info_helpers", () => {
|
|||
expect(getPlaceholder(Providers.DeepInfra)).toBe("deepinfra/<any-model-on-deepinfra>");
|
||||
});
|
||||
|
||||
it("should return hpc_ai placeholder for HPC_AI provider", () => {
|
||||
expect(getPlaceholder(Providers.HPC_AI)).toBe("hpc_ai/minimax/minimax-m2.5");
|
||||
});
|
||||
|
||||
it("should return fal_ai placeholder for FalAI provider", () => {
|
||||
expect(getPlaceholder(Providers.FalAI)).toBe("fal_ai/fal-ai/flux-pro/v1.1-ultra");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ export enum Providers {
|
|||
GradientAI = "GradientAI",
|
||||
Groq = "Groq",
|
||||
HEROKU = "Heroku",
|
||||
HPC_AI = "HPC-AI",
|
||||
Hosted_Vllm = "vllm",
|
||||
HUGGINGFACE = "Huggingface",
|
||||
HYPERBOLIC = "Hyperbolic",
|
||||
|
|
@ -151,6 +152,7 @@ export const provider_map: Record<string, string> = {
|
|||
GradientAI: "gradient_ai",
|
||||
Groq: "groq",
|
||||
HEROKU: "heroku",
|
||||
HPC_AI: "hpc_ai",
|
||||
Hosted_Vllm: "hosted_vllm",
|
||||
HUGGINGFACE: "huggingface",
|
||||
HYPERBOLIC: "hyperbolic",
|
||||
|
|
@ -251,6 +253,7 @@ export const providerLogoMap: Record<string, string> = {
|
|||
[Providers.Google_AI_Studio]: `${asset_logos_folder}google.svg`,
|
||||
[Providers.GradientAI]: `${asset_logos_folder}gradientai.svg`,
|
||||
[Providers.Groq]: `${asset_logos_folder}groq.svg`,
|
||||
[Providers.HPC_AI]: `${asset_logos_folder}hpc_ai.svg`,
|
||||
[Providers.Hosted_Vllm]: `${asset_logos_folder}vllm.png`,
|
||||
[Providers.HUGGINGFACE]: `${asset_logos_folder}huggingface.svg`,
|
||||
[Providers.HYPERBOLIC]: `${asset_logos_folder}hyperbolic.svg`,
|
||||
|
|
@ -358,6 +361,8 @@ export const getPlaceholder = (selectedProvider: string): string => {
|
|||
return "volcengine/<any-model-on-volcengine>";
|
||||
} else if (selectedProvider == Providers.DeepInfra) {
|
||||
return "deepinfra/<any-model-on-deepinfra>";
|
||||
} else if (selectedProvider === Providers.HPC_AI) {
|
||||
return "hpc_ai/minimax/minimax-m2.5";
|
||||
} else if (selectedProvider == Providers.FalAI) {
|
||||
return "fal_ai/fal-ai/flux-pro/v1.1-ultra";
|
||||
} else if (selectedProvider == Providers.RunwayML) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue