From b98de29b07bd0186d1196479754d09b55e55a0ef Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Wed, 20 Aug 2025 23:33:35 +0800 Subject: [PATCH] feat: add shengsuanyun requester --- .../modelmgr/requesters/shengsuanyun.py | 32 ++++++++++++++++ .../modelmgr/requesters/shengsuanyun.svg | 1 + .../modelmgr/requesters/shengsuanyun.yaml | 38 +++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 pkg/provider/modelmgr/requesters/shengsuanyun.py create mode 100644 pkg/provider/modelmgr/requesters/shengsuanyun.svg create mode 100644 pkg/provider/modelmgr/requesters/shengsuanyun.yaml diff --git a/pkg/provider/modelmgr/requesters/shengsuanyun.py b/pkg/provider/modelmgr/requesters/shengsuanyun.py new file mode 100644 index 00000000..9146621d --- /dev/null +++ b/pkg/provider/modelmgr/requesters/shengsuanyun.py @@ -0,0 +1,32 @@ +from __future__ import annotations + +import openai +import typing + +from . import chatcmpl +import openai.types.chat.chat_completion as chat_completion + + +class ShengSuanYunChatCompletions(chatcmpl.OpenAIChatCompletions): + """胜算云 ChatCompletion API 请求器""" + + client: openai.AsyncClient + + default_config: dict[str, typing.Any] = { + 'base_url': 'https://router.shengsuanyun.com/api/v1', + 'timeout': 120, + } + + async def _req( + self, + args: dict, + extra_body: dict = {}, + ) -> chat_completion.ChatCompletion: + return await self.client.chat.completions.create( + **args, + extra_body=extra_body, + extra_headers={ + 'HTTP-Referer': 'https://langbot.app', + 'X-Title': 'LangBot', + }, + ) diff --git a/pkg/provider/modelmgr/requesters/shengsuanyun.svg b/pkg/provider/modelmgr/requesters/shengsuanyun.svg new file mode 100644 index 00000000..d3f672aa --- /dev/null +++ b/pkg/provider/modelmgr/requesters/shengsuanyun.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pkg/provider/modelmgr/requesters/shengsuanyun.yaml b/pkg/provider/modelmgr/requesters/shengsuanyun.yaml new file mode 100644 index 00000000..6668b677 --- /dev/null +++ b/pkg/provider/modelmgr/requesters/shengsuanyun.yaml @@ -0,0 +1,38 @@ +apiVersion: v1 +kind: LLMAPIRequester +metadata: + name: shengsuanyun-chat-completions + label: + en_US: ShengSuanYun + zh_Hans: 胜算云 + icon: shengsuanyun.svg +spec: + config: + - name: base_url + label: + en_US: Base URL + zh_Hans: 基础 URL + type: string + required: true + default: "https://router.shengsuanyun.com/api/v1" + - name: args + label: + en_US: Args + zh_Hans: 附加参数 + type: object + required: true + default: {} + - name: timeout + label: + en_US: Timeout + zh_Hans: 超时时间 + type: int + required: true + default: 120 + support_type: + - llm + - text-embedding +execution: + python: + path: ./shengsuanyun.py + attr: ShengSuanYunChatCompletions \ No newline at end of file