Skip to content

Commit 3f4d725

Browse files
committed
feat: supports aihubmix
1 parent b8d2499 commit 3f4d725

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

astrbot/core/config/default.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,18 @@ class ChatProviderTemplate(TypedDict):
10291029
"proxy": "",
10301030
"custom_headers": {},
10311031
},
1032+
"AIHubMix": {
1033+
"id": "aihubmix",
1034+
"provider": "aihubmix",
1035+
"type": "aihubmix_chat_completion",
1036+
"provider_type": "chat_completion",
1037+
"enable": True,
1038+
"key": [],
1039+
"timeout": 120,
1040+
"api_base": "https://aihubmix.com/v1",
1041+
"proxy": "",
1042+
"custom_headers": {},
1043+
},
10321044
"NVIDIA": {
10331045
"id": "nvidia",
10341046
"provider": "nvidia",

astrbot/core/provider/manager.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,12 @@ def dynamic_import_provider(self, type: str) -> None:
295295
from .sources.zhipu_source import ProviderZhipu as ProviderZhipu
296296
case "groq_chat_completion":
297297
from .sources.groq_source import ProviderGroq as ProviderGroq
298+
case "xai_chat_completion":
299+
from .sources.xai_source import ProviderXAI as ProviderXAI
300+
case "aihubmix_chat_completion":
301+
from .sources.oai_aihubmix_source import (
302+
ProviderAIHubMix as ProviderAIHubMix,
303+
)
298304
case "anthropic_chat_completion":
299305
from .sources.anthropic_source import (
300306
ProviderAnthropic as ProviderAnthropic,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from ..register import register_provider_adapter
2+
from .openai_source import ProviderOpenAIOfficial
3+
4+
5+
@register_provider_adapter(
6+
"aihubmix_chat_completion", "AIHubMix Chat Completion Provider Adapter"
7+
)
8+
class ProviderAIHubMix(ProviderOpenAIOfficial):
9+
def __init__(
10+
self,
11+
provider_config: dict,
12+
provider_settings: dict,
13+
) -> None:
14+
super().__init__(provider_config, provider_settings)
15+
# Reference to: https://aihubmix.com/appstore
16+
# Use this code can enjoy 10% off prices for AIHubMix API calls.
17+
self.client._custom_headers["APP-Code"] = "KRLC5702" # type: ignore

dashboard/src/utils/providerUtils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export function getProviderIcon(type) {
3333
'microsoft': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/microsoft.svg',
3434
'vllm': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/vllm.svg',
3535
'groq': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/groq.svg',
36+
'aihubmix': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/aihubmix-color.svg',
3637
"tokenpony": "https://tokenpony.cn/tokenpony-web/logo.png",
3738
"compshare": "https://compshare.cn/favicon.ico"
3839
};

0 commit comments

Comments
 (0)