diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index 8602250cf..21758149a 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -1029,6 +1029,18 @@ CONFIG_METADATA_2 = { "proxy": "", "custom_headers": {}, }, + "AIHubMix": { + "id": "aihubmix", + "provider": "aihubmix", + "type": "aihubmix_chat_completion", + "provider_type": "chat_completion", + "enable": True, + "key": [], + "timeout": 120, + "api_base": "https://aihubmix.com/v1", + "proxy": "", + "custom_headers": {}, + }, "NVIDIA": { "id": "nvidia", "provider": "nvidia", diff --git a/astrbot/core/provider/manager.py b/astrbot/core/provider/manager.py index ff0bb303d..38700d5e8 100644 --- a/astrbot/core/provider/manager.py +++ b/astrbot/core/provider/manager.py @@ -295,6 +295,12 @@ class ProviderManager: from .sources.zhipu_source import ProviderZhipu as ProviderZhipu case "groq_chat_completion": from .sources.groq_source import ProviderGroq as ProviderGroq + case "xai_chat_completion": + from .sources.xai_source import ProviderXAI as ProviderXAI + case "aihubmix_chat_completion": + from .sources.oai_aihubmix_source import ( + ProviderAIHubMix as ProviderAIHubMix, + ) case "anthropic_chat_completion": from .sources.anthropic_source import ( ProviderAnthropic as ProviderAnthropic, diff --git a/astrbot/core/provider/sources/oai_aihubmix_source.py b/astrbot/core/provider/sources/oai_aihubmix_source.py new file mode 100644 index 000000000..1572f6ecd --- /dev/null +++ b/astrbot/core/provider/sources/oai_aihubmix_source.py @@ -0,0 +1,17 @@ +from ..register import register_provider_adapter +from .openai_source import ProviderOpenAIOfficial + + +@register_provider_adapter( + "aihubmix_chat_completion", "AIHubMix Chat Completion Provider Adapter" +) +class ProviderAIHubMix(ProviderOpenAIOfficial): + def __init__( + self, + provider_config: dict, + provider_settings: dict, + ) -> None: + super().__init__(provider_config, provider_settings) + # Reference to: https://aihubmix.com/appstore + # Use this code can enjoy 10% off prices for AIHubMix API calls. + self.client._custom_headers["APP-Code"] = "KRLC5702" # type: ignore diff --git a/dashboard/src/utils/providerUtils.js b/dashboard/src/utils/providerUtils.js index 93a3ad547..594f68e36 100644 --- a/dashboard/src/utils/providerUtils.js +++ b/dashboard/src/utils/providerUtils.js @@ -33,6 +33,7 @@ export function getProviderIcon(type) { 'microsoft': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/microsoft.svg', 'vllm': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/vllm.svg', 'groq': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/groq.svg', + 'aihubmix': 'https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/aihubmix-color.svg', "tokenpony": "https://tokenpony.cn/tokenpony-web/logo.png", "compshare": "https://compshare.cn/favicon.ico" };