Skip to content

Commit a93568c

Browse files
FutureppoSoulter
andauthored
feat(provider): add LongCat LLM Provider (#7360)
* feat(longcat): 添加 LongCat 模型提供商 * chore: remove tests and add longcat logo --------- Co-authored-by: Soulter <905617992@qq.com>
1 parent d8f8462 commit a93568c

4 files changed

Lines changed: 38 additions & 0 deletions

File tree

astrbot/core/config/default.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,18 @@ class ChatProviderTemplate(TypedDict):
12431243
"proxy": "",
12441244
"custom_headers": {},
12451245
},
1246+
"LongCat": {
1247+
"id": "longcat",
1248+
"provider": "longcat",
1249+
"type": "longcat_chat_completion",
1250+
"provider_type": "chat_completion",
1251+
"enable": True,
1252+
"key": [],
1253+
"api_base": "https://api.longcat.chat/openai",
1254+
"timeout": 120,
1255+
"proxy": "",
1256+
"custom_headers": {},
1257+
},
12461258
"AIHubMix": {
12471259
"id": "aihubmix",
12481260
"provider": "aihubmix",

astrbot/core/provider/manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ def dynamic_import_provider(self, type: str) -> None:
361361
from .sources.openai_source import (
362362
ProviderOpenAIOfficial as ProviderOpenAIOfficial,
363363
)
364+
case "longcat_chat_completion":
365+
from .sources.longcat_source import ProviderLongCat as ProviderLongCat
364366
case "zhipu_chat_completion":
365367
from .sources.zhipu_source import ProviderZhipu as ProviderZhipu
366368
case "groq_chat_completion":
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from ..register import register_provider_adapter
2+
from .openai_source import ProviderOpenAIOfficial
3+
4+
5+
@register_provider_adapter(
6+
"longcat_chat_completion", "LongCat Chat Completion Provider Adapter"
7+
)
8+
class ProviderLongCat(ProviderOpenAIOfficial):
9+
def __init__(
10+
self,
11+
provider_config: dict,
12+
provider_settings: dict,
13+
) -> None:
14+
api_base = (provider_config.get("api_base", "") or "").strip()
15+
if not api_base:
16+
provider_config["api_base"] = "https://api.longcat.chat/openai/v1"
17+
else:
18+
normalized_api_base = api_base.rstrip("/")
19+
if normalized_api_base.endswith("/openai"):
20+
normalized_api_base = f"{normalized_api_base}/v1"
21+
provider_config["api_base"] = normalized_api_base
22+
23+
super().__init__(provider_config, provider_settings)

dashboard/src/utils/providerUtils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export function getProviderIcon(type) {
2323
'moonshot': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/kimi.svg',
2424
'kimi': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/kimi.svg',
2525
'kimi-code': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/kimi.svg',
26+
'kimi-code': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/longcat-color.svg',
2627
'ppio': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/ppio.svg',
2728
'dify': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/dify-color.svg',
2829
"coze": "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@1.66.0/icons/coze.svg",

0 commit comments

Comments
 (0)