From ca3d3b2a66527c0c609a48fc8158acaac72e1df4 Mon Sep 17 00:00:00 2001 From: "Junyan Qin (Chin)" Date: Thu, 25 Sep 2025 16:15:22 +0800 Subject: [PATCH] feat: supports for tokenpony.cn (#1688) --- README.md | 1 + .../modelmgr/requesters/tokenpony.svg | 1 + .../modelmgr/requesters/tokenpony.yaml | 31 +++++++++++++++++++ .../modelmgr/requesters/tokenponychatcmpl.py | 17 ++++++++++ 4 files changed, 50 insertions(+) create mode 100644 pkg/provider/modelmgr/requesters/tokenpony.svg create mode 100644 pkg/provider/modelmgr/requesters/tokenpony.yaml create mode 100644 pkg/provider/modelmgr/requesters/tokenponychatcmpl.py diff --git a/README.md b/README.md index 012f8ad2..4973023b 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ docker compose up -d | [LMStudio](https://lmstudio.ai/) | ✅ | 本地大模型运行平台 | | [GiteeAI](https://ai.gitee.com/) | ✅ | 大模型接口聚合平台 | | [SiliconFlow](https://siliconflow.cn/) | ✅ | 大模型聚合平台 | +| [小马算力](https://www.tokenpony.cn/453z1) | ✅ | 大模型聚合平台 | | [阿里云百炼](https://bailian.console.aliyun.com/) | ✅ | 大模型聚合平台, LLMOps 平台 | | [火山方舟](https://console.volcengine.com/ark/region:ark+cn-beijing/model?vendor=Bytedance&view=LIST_VIEW) | ✅ | 大模型聚合平台, LLMOps 平台 | | [ModelScope](https://modelscope.cn/docs/model-service/API-Inference/intro) | ✅ | 大模型聚合平台 | diff --git a/pkg/provider/modelmgr/requesters/tokenpony.svg b/pkg/provider/modelmgr/requesters/tokenpony.svg new file mode 100644 index 00000000..2bbe118b --- /dev/null +++ b/pkg/provider/modelmgr/requesters/tokenpony.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pkg/provider/modelmgr/requesters/tokenpony.yaml b/pkg/provider/modelmgr/requesters/tokenpony.yaml new file mode 100644 index 00000000..363583b0 --- /dev/null +++ b/pkg/provider/modelmgr/requesters/tokenpony.yaml @@ -0,0 +1,31 @@ +apiVersion: v1 +kind: LLMAPIRequester +metadata: + name: tokenpony-chat-completions + label: + en_US: TokenPony + zh_Hans: 小马算力 + icon: tokenpony.svg +spec: + config: + - name: base_url + label: + en_US: Base URL + zh_Hans: 基础 URL + type: string + required: true + default: "https://api.tokenpony.cn/v1" + - name: timeout + label: + en_US: Timeout + zh_Hans: 超时时间 + type: integer + required: true + default: 120 + support_type: + - llm + - text-embedding +execution: + python: + path: ./tokenponychatcmpl.py + attr: TokenPonyChatCompletions \ No newline at end of file diff --git a/pkg/provider/modelmgr/requesters/tokenponychatcmpl.py b/pkg/provider/modelmgr/requesters/tokenponychatcmpl.py new file mode 100644 index 00000000..92311454 --- /dev/null +++ b/pkg/provider/modelmgr/requesters/tokenponychatcmpl.py @@ -0,0 +1,17 @@ +from __future__ import annotations + +import typing +import openai + +from . import chatcmpl + + +class TokenPonyChatCompletions(chatcmpl.OpenAIChatCompletions): + """TokenPony ChatCompletion API 请求器""" + + client: openai.AsyncClient + + default_config: dict[str, typing.Any] = { + 'base_url': 'https://api.tokenpony.cn/v1', + 'timeout': 120, + }