chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
No files matched your search
@@ -0,0 +1,127 @@
|
||||
// Package providers registers the Academy managed model service.
|
||||
//
|
||||
// unverified: this is a first-party endpoint with no published API
|
||||
// reference — https://weknora.weixin.qq.com/docs documents the Academy
|
||||
// product, not the model gateway's wire protocol. Every fact below is taken
|
||||
// from this repository's own clients rather than from vendor documentation,
|
||||
// and is cited accordingly:
|
||||
// - one host serves chat, embedding, rerank and VLM. Chat completions and
|
||||
// VLM live at /api/v1/chat/completions rather than the OpenAI default
|
||||
// path (internal/models/vlm/academycloud.go), embeddings at
|
||||
// /api/v1/embeddings (internal/models/embedding/academycloud.go) and
|
||||
// rerank at /api/v1/rerank (internal/models/rerank/academycloud.go).
|
||||
// Only the chat path goes through the Endpoint hook; the other three
|
||||
// clients build their own URLs;
|
||||
// - requests are signed with the tenant's AppID / AppSecret through
|
||||
// modelutils.Sign (internal/models/utils/signer.go), which sends
|
||||
// X-APPID, X-API-Key, X-Request-ID, X-Timestamp, X-Nonce and an
|
||||
// X-Signature that is the MD5 of the RFC3986-encoded, key-sorted
|
||||
// parameter string including the MD5 of the body. There is no bearer
|
||||
// key, hence the AuthSigned style and a fresh request id per call;
|
||||
// - credentials are provisioned through the dedicated initialization
|
||||
// endpoint (internal/handler/academycloud.go), so Validate performs no
|
||||
// key check here;
|
||||
// - the model names the product provisions are chat, embedding, rerank and
|
||||
// vlm (frontend/src/utils/academyCloudModels.ts). models.json is left
|
||||
// empty on purpose: no context window, output cap or price is published
|
||||
// for them, and the embedding dimension is probed at runtime through
|
||||
// GET /api/v1/models/academycloud/status.
|
||||
//
|
||||
// unverified: SupportsMultiContent is kept false so chat messages are
|
||||
// flattened to plain text, but nothing documents that restriction and the
|
||||
// VLM client posts image_url parts to the very same /api/v1/chat/completions
|
||||
// path, so it may only apply to the chat model. The value is left as-is
|
||||
// because the transport test pins it.
|
||||
//
|
||||
// unverified: PromptCacheAccounting is kept false; the gateway is not
|
||||
// documented to report prompt-cache counters, and none have been observed.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"academy/internal/models/api"
|
||||
modelutils "academy/internal/models/utils"
|
||||
"academy/internal/types"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
//go:embed assets/academycloud.svg
|
||||
var academyCloudIcon []byte
|
||||
|
||||
// AcademyCloudID is the provider identifier stored on model rows.
|
||||
const AcademyCloudID = "academycloud"
|
||||
|
||||
// AcademyCloudBaseURL is the single service entry point; per-capability paths are
|
||||
// appended by the Endpoint hook and the embedding / rerank clients.
|
||||
const AcademyCloudBaseURL = "https://weknora.weixin.qq.com"
|
||||
|
||||
func newAcademyCloudProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: AcademyCloudID,
|
||||
Name: "Academy Cloud",
|
||||
Names: map[string]string{"zh-CN": "Academy 云服务"},
|
||||
Description: "Academy managed models: chat, embedding, rerank, vlm",
|
||||
Descriptions: map[string]string{"zh-CN": "Academy云服务,模型:chat, embedding, rerank, vlm"},
|
||||
Website: AcademyCloudBaseURL,
|
||||
Icon: academyCloudIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 1,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthSigned,
|
||||
URLPatterns: []string{"weknora.weixin.qq.com"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: AcademyCloudBaseURL,
|
||||
types.ModelTypeEmbedding: AcademyCloudBaseURL,
|
||||
types.ModelTypeRerank: AcademyCloudBaseURL,
|
||||
types.ModelTypeVLLM: AcademyCloudBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeRerank,
|
||||
types.ModelTypeVLLM,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
// The OpenAI body on the service's own path, signed like the
|
||||
// rest of it.
|
||||
Path: api.Ptr("/api/v1/embeddings"),
|
||||
DimensionsField: api.Ptr("dimensions"),
|
||||
RequestTimeout: api.Ptr(60),
|
||||
},
|
||||
Rerank: api.RerankCompat{
|
||||
Path: api.Ptr("/api/v1/rerank"),
|
||||
// The only rerank vendor that has ever had a client deadline
|
||||
// here. Without it a hung endpoint holds the retrieval stage
|
||||
// for as long as the caller's context allows.
|
||||
RequestTimeout: api.Ptr(60),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
SupportsMultiContent: api.Ptr(false),
|
||||
PromptCacheAccounting: api.Ptr(false),
|
||||
},
|
||||
},
|
||||
Signer: func(creds api.Credentials) api.AuthFunc {
|
||||
return func(req *http.Request, body []byte) {
|
||||
headers := modelutils.Sign(creds.AppID, creds.AppSecret, uuid.NewString(), string(body))
|
||||
for k, v := range headers {
|
||||
req.Header.Set(k, v)
|
||||
}
|
||||
}
|
||||
},
|
||||
Endpoint: func(r EndpointRequest) (string, map[string]string) {
|
||||
switch r.ModelType {
|
||||
case types.ModelTypeEmbedding, types.ModelTypeRerank, types.ModelTypeASR:
|
||||
// Those clients build their own paths; fall back.
|
||||
return "", nil
|
||||
}
|
||||
return strings.TrimRight(r.BaseURL, "/") + "/api/v1/chat/completions", nil
|
||||
},
|
||||
// AppID / AppSecret are written by the dedicated initialization
|
||||
// endpoint; only structural checks happen there.
|
||||
Validate: func(_ *Config) error { return nil },
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
// Package providers registers Alibaba Cloud Model Studio (Bailian / DashScope)
|
||||
// through its OpenAI-compatible mode.
|
||||
//
|
||||
// Facts (https://help.aliyun.com/zh/model-studio/qwen-api-via-openai-chat-completions,
|
||||
// https://help.aliyun.com/zh/model-studio/deep-thinking and
|
||||
// https://help.aliyun.com/zh/model-studio/base-url):
|
||||
// - the OpenAI-compatible Beijing base URL is
|
||||
// https://dashscope.aliyuncs.com/compatible-mode/v1. The Base URL page
|
||||
// still lists it and adds region twins (dashscope-intl / dashscope-us /
|
||||
// cn-hongkong.dashscope) plus workspace-exclusive hosts
|
||||
// ({WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1) that it
|
||||
// recommends for production. The workspace hosts need an id we do not
|
||||
// have, so the dashscope host stays the default;
|
||||
// - the same hosts expose an Anthropic Messages facade under
|
||||
// /apps/anthropic and the DashScope-native API under /api/v1. This
|
||||
// package configures OpenAI Chat Completions, which is what the model
|
||||
// pages document first;
|
||||
// - output cap is `max_completion_tokens` ("模型输出的最大长度,包含思维链和
|
||||
// 模型回答"). The parameter table marks `max_tokens` 即将废弃 and names
|
||||
// this field its successor. `max_tokens` is still accepted today, but
|
||||
// following a vendor that has announced a replacement is the cheaper
|
||||
// side of the bet: the deprecated field disappears on DashScope's
|
||||
// schedule, the successor does not;
|
||||
// - hybrid-thinking models (Qwen3 / Qwen3.x, qwen-plus / -max / -turbo /
|
||||
// -flash, DeepSeek V3 / V4, Kimi K2, GLM-5) are switched with
|
||||
// `enable_thinking` and budgeted with `thinking_budget` (max token count
|
||||
// of the chain of thought; the default is the model's own maximum).
|
||||
// Per-model defaults differ, and the docs require the switch to be sent
|
||||
// explicitly whenever it deviates from that default, so those families
|
||||
// carry thinking_always_send in models.json;
|
||||
// - with `enable_thinking: true` the commercial Qwen models only support
|
||||
// streaming ("模型开启思考模式时仅支持增量流式输出"), so the hybrid
|
||||
// families also carry thinking_disable_on_non_stream;
|
||||
// - always-on reasoners (仅思考模式): qwq-plus, deepseek-r1 /
|
||||
// deepseek-r1-0528, qwen3.8-2.4t-a95b, qwen3.7-max-preview,
|
||||
// qwen3.7-max-2026-05-17, qwen3-next-80b-a3b-thinking. Those carry
|
||||
// "off": null;
|
||||
// - `reasoning_effort` IS accepted in the compatible mode, but only on some
|
||||
// families: qwen3.8 takes low | medium | xhigh (default xhigh; "不支持
|
||||
// reasoning_effort 与 thinking_budget 同时设置,同时设置会报错", which
|
||||
// those entries carry as thinking_budget_excludes_effort so the budget
|
||||
// yields to the level), DeepSeek-V4 takes high | max
|
||||
// (plus low on the dated -0813 / -0731 snapshots), glm-5.3 takes
|
||||
// low | high | max. It is therefore off at the vendor level and enabled
|
||||
// per entry;
|
||||
// - explicit prompt caching uses Anthropic-style `cache_control`
|
||||
// ({"type": "ephemeral"}) and usage reports
|
||||
// `prompt_tokens_details.cached_tokens` plus
|
||||
// `cache_creation.ephemeral_5m_input_tokens`;
|
||||
// - tool_choice takes the full OpenAI set (none / auto / required / named
|
||||
// function), and parallel_tool_calls, response_format
|
||||
// (text | json_object | json_schema), stream_options.include_usage, seed,
|
||||
// temperature and top_p are all documented, so the protocol defaults
|
||||
// stand;
|
||||
// - embeddings are OpenAI-compatible under the same base
|
||||
// (/compatible-mode/v1/embeddings); text-embedding-v4 and -v3 default to
|
||||
// 1024 dimensions (https://help.aliyun.com/zh/model-studio/embedding);
|
||||
// - rerank is a separate DashScope-native endpoint
|
||||
// (/api/v1/services/rerank/text-rerank/text-rerank).
|
||||
//
|
||||
// qwen3-rerank is also documented on a second, flat endpoint
|
||||
// (/compatible-api/v1/reranks: query / documents at the top level, results
|
||||
// with no `output` object), but the native text-rerank endpoint serves it too
|
||||
// and returns the same scores (verified against the live API in #3558), so it
|
||||
// stays on the native protocol like gte-rerank-v2 and qwen3.7-text-rerank.
|
||||
// A dedicated package for the flat shape is only needed if a model ever ships
|
||||
// on that endpoint alone (https://help.aliyun.com/zh/model-studio/text-rerank-api).
|
||||
//
|
||||
// unverified: no page states whether `prompt_cache_key` is accepted, so the
|
||||
// protocol default (not sent) is kept.
|
||||
//
|
||||
// unverified: the context windows, max output tokens and prices of the Qwen
|
||||
// entries in models.json come from the Model Studio model pages, which the
|
||||
// public docs render behind a console table we cannot quote; they are left as
|
||||
// they were. The same holds for kimi-k3 / kimi-k2.6 / glm-5.3 hosted here and
|
||||
// for qwq-32b's "off": null, which the 仅思考模式 list does not spell out.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"strings"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/aliyun.svg
|
||||
var aliyunIcon []byte
|
||||
|
||||
// AliyunID is the provider identifier stored on model rows.
|
||||
const AliyunID = "aliyun"
|
||||
|
||||
// AliyunBaseURL is the OpenAI-compatible mode used for chat, embedding and VLM.
|
||||
const AliyunBaseURL = "https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||
|
||||
// AliyunRerankBaseURL is the DashScope-native text rerank endpoint.
|
||||
const AliyunRerankBaseURL = "https://dashscope.aliyuncs.com/api/v1/services/rerank/text-rerank/text-rerank"
|
||||
|
||||
// AliyunAnthropicBaseURL is the documented Anthropic Messages facade. It is not the
|
||||
// default for this vendor; operators who want it configure it explicitly.
|
||||
const AliyunAnthropicBaseURL = "https://dashscope.aliyuncs.com/apps/anthropic"
|
||||
|
||||
// AliyunMultimodalEmbeddingPath is the native multimodal embedding method
|
||||
// (https://help.aliyun.com/zh/model-studio/multimodal-embedding-api-reference).
|
||||
const AliyunMultimodalEmbeddingPath = "/api/v1/services/embeddings/multimodal-embedding/multimodal-embedding"
|
||||
|
||||
func newAliyunProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: AliyunID,
|
||||
Name: "Alibaba Cloud DashScope",
|
||||
Names: map[string]string{"zh-CN": "阿里云 DashScope"},
|
||||
Description: "qwen-plus, qwen3.8-max, deepseek-v4-pro, text-embedding-v4, gte-rerank-v2, etc.",
|
||||
Website: "https://bailian.console.aliyun.com",
|
||||
Icon: aliyunIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 10,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"dashscope.aliyuncs.com"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: AliyunBaseURL,
|
||||
types.ModelTypeEmbedding: AliyunBaseURL,
|
||||
types.ModelTypeRerank: AliyunRerankBaseURL,
|
||||
types.ModelTypeVLLM: AliyunBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeRerank,
|
||||
types.ModelTypeVLLM,
|
||||
types.ModelTypeASR,
|
||||
},
|
||||
RerankAPI: api.RerankDashScope,
|
||||
// Text and multimodal embeddings live under different roots of the
|
||||
// same host — /compatible-mode/v1 and /api/v1 — and a row stores one
|
||||
// base URL for both, so the request is placed from the host. A base
|
||||
// URL without either root is taken as the host itself, which keeps a
|
||||
// workspace or international domain instead of replacing it with the
|
||||
// Beijing default as the pre-catalog client did.
|
||||
Endpoint: func(r EndpointRequest) (string, map[string]string) {
|
||||
if r.ModelType != types.ModelTypeEmbedding {
|
||||
return "", nil
|
||||
}
|
||||
root := strings.TrimRight(r.BaseURL, "/")
|
||||
for _, marker := range []string{"/compatible-mode", "/api/v1"} {
|
||||
if i := strings.Index(root, marker); i >= 0 {
|
||||
root = root[:i]
|
||||
}
|
||||
}
|
||||
if r.EmbeddingAPI == api.EmbeddingDashScope {
|
||||
return root + AliyunMultimodalEmbeddingPath, nil
|
||||
}
|
||||
return root + "/compatible-mode/v1/embeddings", nil
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
// ASR: qwen3-asr-flash is the one recognition model callable with
|
||||
// the audio in the request, on the compatible chat endpoint as a
|
||||
// base64 data URI; its catalog entry declares that. Every other
|
||||
// ASR name falls to a catch-all entry that refuses it: Paraformer,
|
||||
// Fun-ASR and the *-filetrans models are asynchronous tasks that
|
||||
// take a public file URL, which no protocol here can send
|
||||
// (https://help.aliyun.com/zh/model-studio/qwen-asr-api-reference).
|
||||
// Text models: the OpenAI-compatible endpoint
|
||||
// (https://help.aliyun.com/zh/model-studio/embedding-interfaces-compatible-with-openai),
|
||||
// which takes model, input, dimensions and encoding_format.
|
||||
// Multimodal models "不支持OpenAI兼容接口" and override the protocol
|
||||
// in models.json. The native APIs' text_type / instruct are not
|
||||
// declared: both change the document vectors
|
||||
// (Tencent/WeKnora#1401).
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
SendEncodingFormat: api.Ptr(true),
|
||||
DimensionsField: api.Ptr("dimensions"),
|
||||
},
|
||||
Rerank: api.RerankCompat{
|
||||
SendReturnDocs: api.Ptr(true),
|
||||
// 500 documents per request for the native text-rerank models.
|
||||
// The query (4,000 tokens) and per-document limits are stated in
|
||||
// tokens, which a rune count cannot express, so they are not
|
||||
// declared.
|
||||
MaxDocuments: api.Ptr(500),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
// Explicit although it matches the protocol default, because
|
||||
// this vendor's own parameter table deprecates the other
|
||||
// field and the choice should be visible here.
|
||||
MaxTokensField: api.Ptr("max_completion_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatEnableThinking),
|
||||
ThinkingBudgetField: api.Ptr("thinking_budget"),
|
||||
CacheControlFormat: api.Ptr("anthropic"),
|
||||
// usage carries prompt_tokens_details.cached_tokens and
|
||||
// cache_creation.ephemeral_5m_input_tokens.
|
||||
PromptCacheAccounting: api.Ptr(true),
|
||||
// reasoning_effort exists but only on the families that enable
|
||||
// it per entry (qwen3.8, DeepSeek-V4, glm-5.3).
|
||||
SupportsReasoningEffort: api.Ptr(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
// Package providers registers Anthropic's native Messages API.
|
||||
//
|
||||
// Facts (https://platform.claude.com/docs/en/api/messages — docs.anthropic.com
|
||||
// now redirects there):
|
||||
// - authentication is the `x-api-key` header plus `anthropic-version`,
|
||||
// still 2023-06-01 in every current example;
|
||||
// - `max_tokens` is mandatory (the protocol default of 4096 applies when
|
||||
// the caller sets no budget);
|
||||
// - `output_config.effort` takes low | medium | high | xhigh | max and
|
||||
// nothing else — there is no "minimal" rung, so the vendor level map
|
||||
// folds minimal onto low
|
||||
// (https://platform.claude.com/docs/en/build-with-claude/effort).
|
||||
// `max` is listed for Fable 5.1 / Fable 5 / Opus 5 / Opus 4.8 / Opus 4.7 /
|
||||
// Opus 4.6 / Sonnet 5 / Sonnet 4.6; `xhigh` for the same set minus
|
||||
// Opus 4.6 and Sonnet 4.6, which is why those two map xhigh onto max;
|
||||
// - Claude 4.7 and later reject `thinking: {"type": "enabled"}` with a 400
|
||||
// and must use `{"type": "adaptive"}`; it is deprecated but still
|
||||
// accepted on the 4.6 generation, and it is the only mode on 4.5 and
|
||||
// earlier
|
||||
// (https://platform.claude.com/docs/en/build-with-claude/thinking-troubleshooting#supported-models);
|
||||
// - only Fable 5.1 / Fable 5 (and the limited-availability Mythos models)
|
||||
// are "always on" and reject `thinking: {"type": "disabled"}`, so only
|
||||
// those entries carry "off": null. Opus 5, Opus 4.8 and Opus 4.7 accept
|
||||
// "disabled" (Opus 5 at effort high or below, which is what a caller
|
||||
// asking for "off" gets because effort and off are mutually exclusive
|
||||
// here);
|
||||
// - Claude Opus 4.5 is the one extended-thinking-only model that also
|
||||
// accepts `output_config.effort`, so it carries supports_effort with
|
||||
// budget mode;
|
||||
// - temperature and top_p cannot be sent alongside thinking, and Claude
|
||||
// Opus 4.7 and later (Opus 4.8, Opus 5, Fable 5 / 5.1) and Sonnet 5
|
||||
// reject non-default sampling values, so those entries carry
|
||||
// supports_temperature: false and supports_top_p: false and send no
|
||||
// sampling field at all
|
||||
// (https://platform.claude.com/docs/en/docs/about-claude/model-deprecations); prompt
|
||||
// caching uses `cache_control` breakpoints (including on tools), offers
|
||||
// a 1h TTL and reports cache usage;
|
||||
// - interleaved thinking still uses the `interleaved-thinking-2025-05-14`
|
||||
// beta header, and only in manual budget mode: adaptive models interleave
|
||||
// on their own and the Claude API ignores the header there.
|
||||
//
|
||||
// Unverified: Claude Mythos 5.1 / Mythos 5 / Mythos Preview are documented
|
||||
// but limited-availability, so they are left out of the catalog.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/anthropic.svg
|
||||
var anthropicIcon []byte
|
||||
|
||||
// AnthropicID is the provider identifier stored on model rows.
|
||||
const AnthropicID = "anthropic"
|
||||
|
||||
// AnthropicBaseURL is the documented first-party endpoint.
|
||||
const AnthropicBaseURL = "https://api.anthropic.com/v1"
|
||||
|
||||
func newAnthropicProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: AnthropicID,
|
||||
Name: "Anthropic",
|
||||
Names: map[string]string{"zh-CN": "Anthropic"},
|
||||
Description: "Claude models via the native Anthropic Messages API: " +
|
||||
"claude-opus-5, claude-sonnet-5, claude-haiku-4-5, etc.",
|
||||
Website: "https://console.anthropic.com",
|
||||
Icon: anthropicIcon,
|
||||
API: api.APIAnthropicMessages,
|
||||
Order: 32,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthXAPIKey,
|
||||
URLPatterns: []string{"api.anthropic.com"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: AnthropicBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
},
|
||||
// Protocol defaults (budget-mode thinking, 2023-06-01 version) apply
|
||||
// at vendor level; adaptive-effort models override per entry.
|
||||
Compat: VendorCompat{},
|
||||
// Anthropic's effort ladder has no "minimal" rung; fold it onto low
|
||||
// for every model so a caller asking for minimal never sends a value
|
||||
// the Messages API rejects.
|
||||
ThinkingLevels: api.ThinkingLevelMap{api.ReasoningMinimal: api.StringPtr("low")},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><rect width="24" height="24" rx="5" fill="#07C160"/><text x="12" y="16" font-family="sans-serif" font-weight="700" font-size="10" fill="#FFFFFF" text-anchor="middle">WK</text></svg>
|
||||
|
After Width: | Height: | Size: 265 B |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>AlibabaCloud</title><path d="M14.752 4.64h5.274C22.242 4.64 24 6.475 24 8.691V15.8a3.947 3.947 0 01-3.974 3.975h-5.274l1.299-1.835 3.822-1.222c.688-.23 1.146-.918 1.146-1.605v-5.81c0-.687-.458-1.375-1.146-1.605L16.05 6.475l-1.3-1.835zM2.98 15.111c0 .688.46 1.376 1.147 1.606l3.822 1.146 1.3 1.835H3.974A3.947 3.947 0 010 15.723V8.69c0-2.216 1.758-4.05 3.975-4.05h5.273L7.95 6.474 4.127 7.697c-.688.23-1.146.918-1.146 1.606v5.808z" fill="#FF6A00"></path><path d="M16.051 11.213H8.025v1.835h8.026v-1.835z" fill="#FF6A00"></path></svg>
|
||||
|
After Width: | Height: | Size: 656 B |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Claude</title><path d="M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z" fill="#D97757" fill-rule="nonzero"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Azure</title><path d="M7.242 1.613A1.11 1.11 0 018.295.857h6.977L8.03 22.316a1.11 1.11 0 01-1.052.755h-5.43a1.11 1.11 0 01-1.053-1.466L7.242 1.613z" fill="url(#lobe-icons-azure-0-_R_0_)"></path><path d="M18.397 15.296H7.4a.51.51 0 00-.347.882l7.066 6.595c.206.192.477.298.758.298h6.226l-2.706-7.775z" fill="#0078D4"></path><path d="M15.272.857H7.497L0 23.071h7.775l1.596-4.73 5.068 4.73h6.665l-2.707-7.775h-7.998L15.272.857z" fill="url(#lobe-icons-azure-1-_R_0_)"></path><path d="M17.193 1.613a1.11 1.11 0 00-1.052-.756h-7.81.035c.477 0 .9.304 1.052.756l6.748 19.992a1.11 1.11 0 01-1.052 1.466h-.12 7.895a1.11 1.11 0 001.052-1.466L17.193 1.613z" fill="url(#lobe-icons-azure-2-_R_0_)"></path><defs><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-azure-0-_R_0_" x1="8.247" x2="1.002" y1="1.626" y2="23.03"><stop stop-color="#114A8B"></stop><stop offset="1" stop-color="#0669BC"></stop></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-azure-1-_R_0_" x1="14.042" x2="12.324" y1="15.302" y2="15.888"><stop stop-opacity=".3"></stop><stop offset=".071" stop-opacity=".2"></stop><stop offset=".321" stop-opacity=".1"></stop><stop offset=".623" stop-opacity=".05"></stop><stop offset="1" stop-opacity="0"></stop></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-azure-2-_R_0_" x1="12.841" x2="20.793" y1="1.626" y2="22.814"><stop stop-color="#3CCBF4"></stop><stop offset="1" stop-color="#2892DF"></stop></linearGradient></defs></svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>DeepSeek</title><path d="M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526 5.526 0 01-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 00-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 01-.465.137 9.597 9.597 0 00-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 001.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 011.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 01.415-.287.302.302 0 01.2.288.306.306 0 01-.31.307.303.303 0 01-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 01-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 01.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 01-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z" fill="#4D6BFE"></path></svg>
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Gemini</title><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="#3186FF"></path><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="url(#lobe-icons-gemini-0-_R_0_)"></path><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="url(#lobe-icons-gemini-1-_R_0_)"></path><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="url(#lobe-icons-gemini-2-_R_0_)"></path><defs><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-gemini-0-_R_0_" x1="7" x2="11" y1="15.5" y2="12"><stop stop-color="#08B962"></stop><stop offset="1" stop-color="#08B962" stop-opacity="0"></stop></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-gemini-1-_R_0_" x1="8" x2="11.5" y1="5.5" y2="11"><stop stop-color="#F94543"></stop><stop offset="1" stop-color="#F94543" stop-opacity="0"></stop></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-gemini-2-_R_0_" x1="3.5" x2="17.5" y1="13.5" y2="12"><stop stop-color="#FABC12"></stop><stop offset=".46" stop-color="#FABC12" stop-opacity="0"></stop></linearGradient></defs></svg>
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#64748B" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8.5 7.5 3.5 12l5 4.5"/><path d="M15.5 7.5 20.5 12l-5 4.5"/><path d="M13.5 5.5 10.5 18.5"/></svg>
|
||||
|
After Width: | Height: | Size: 283 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><rect width="24" height="24" rx="5" fill="#0F766E"/><text x="12" y="16" font-family="sans-serif" font-weight="700" font-size="10" fill="#FFFFFF" text-anchor="middle">GS</text></svg>
|
||||
|
After Width: | Height: | Size: 265 B |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Hunyuan</title><circle cx="12" cy="12" fill="#0055E9" r="12"></circle><path d="M12 0c.518 0 1.028.033 1.528.096A6.188 6.188 0 0112.12 12.28l-.12.001c-2.99 0-5.242 2.179-5.554 5.11-.223 2.086.353 4.412 2.242 6.146C3.672 22.1 0 17.479 0 12 0 5.373 5.373 0 12 0z" fill="#A8DFF5"></path><path d="M5.286 5a2.438 2.438 0 01.682 3.38c-3.962 5.966-3.215 10.743 2.648 15.136C3.636 22.056 0 17.452 0 12c0-1.787.39-3.482 1.09-5.006.253-.435.525-.872.817-1.311A2.438 2.438 0 015.286 5z" fill="#0055E9"></path><path d="M12.98.04c.272.021.543.053.81.093.583.106 1.117.254 1.538.44 6.638 2.927 8.07 10.052 1.748 15.642a4.125 4.125 0 01-5.822-.358c-1.51-1.706-1.3-4.184.357-5.822.858-.848 3.108-1.223 4.045-2.441 1.257-1.634 2.122-6.009-2.523-7.506L12.98.039z" fill="#00BCFF"></path><path d="M13.528.096A6.187 6.187 0 0112 12.281a5.75 5.75 0 00-1.71.255c.147-.905.595-1.784 1.321-2.501.858-.848 3.108-1.223 4.045-2.441 1.27-1.651 2.14-6.104-2.676-7.554.184.014.367.033.548.056z" fill="#ECECEE"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1 @@
|
||||
<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Jina</title><path d="M6.608 21.416a4.608 4.608 0 100-9.217 4.608 4.608 0 000 9.217zM20.894 2.015c.614 0 1.106.492 1.106 1.106v9.002c0 5.13-4.148 9.309-9.217 9.37v-9.355l-.03-9.032c0-.614.491-1.106 1.106-1.106h7.158l-.123.015z"></path></svg>
|
||||
|
After Width: | Height: | Size: 404 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><rect width="24" height="24" rx="5" fill="#2B6CB0"/><text x="12" y="16" font-family="sans-serif" font-weight="700" font-size="10" fill="#FFFFFF" text-anchor="middle">LL</text></svg>
|
||||
|
After Width: | Height: | Size: 265 B |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>TencentCloud</title><path d="M20.0483 17.1416C19.6945 17.4914 18.987 18.0161 17.7488 18.0161C17.2182 18.0161 16.5991 18.0161 16.3338 18.0161C15.98 18.0161 13.3268 18.0161 10.143 18.0161C12.4424 15.8298 14.3881 13.9932 14.565 13.8183C14.7419 13.6434 15.1841 13.2061 15.6263 12.8563C16.5107 12.0692 17.2182 11.9817 17.8373 11.9817C18.7217 11.9817 19.4292 12.3316 20.0483 12.8563C21.2864 13.9932 21.2864 16.0047 20.0483 17.1416ZM21.5518 11.457C20.6674 10.495 19.3408 9.88281 17.9257 9.88281C16.6875 9.88281 15.6263 10.3201 14.6534 11.0197C14.2997 11.3695 13.769 11.7194 13.3268 12.2441C12.9731 12.5939 5.36719 19.9401 5.36719 19.9401C5.80939 20.0276 6.34003 20.0276 6.78223 20.0276C7.22443 20.0276 16.0685 20.0276 16.4222 20.0276C17.1298 20.0276 17.6604 20.0276 18.191 19.9401C19.3408 19.8527 20.4905 19.4154 21.4633 18.5409C23.4975 16.6168 23.4975 13.381 21.5518 11.457Z" fill="#00A3FF"></path><path d="M9.1701 10.9323C8.19726 10.2326 7.22442 9.88281 6.07469 9.88281C4.65965 9.88281 3.33304 10.495 2.44864 11.457C0.502952 13.4685 0.502952 16.6168 2.53708 18.6283C3.42148 19.4154 4.30589 19.8527 5.36717 19.9401L7.4013 18.0161C7.04754 18.0161 6.60533 18.0161 6.25157 18.0161C5.10185 17.9287 4.39433 17.5789 3.95212 17.1416C2.71396 15.9172 2.71396 13.9932 3.86368 12.7688C4.48277 12.1566 5.19029 11.8943 6.07469 11.8943C6.60533 11.8943 7.4013 11.9817 8.19726 12.7688C8.55102 13.1186 9.52386 13.8183 9.87763 14.1681H9.96607L11.2927 12.8563V12.7688C10.6736 12.1566 9.70075 11.3695 9.1701 10.9323Z" fill="#00C8DC"></path><path d="M18.4564 8.74536C17.4836 6.12171 14.9188 4.28516 12.0003 4.28516C8.5511 4.28516 5.80945 6.82135 5.27881 9.96973C5.54413 9.96973 5.80945 9.88228 6.16321 9.88228C6.51697 9.88228 6.95917 9.96973 7.31294 9.96973C7.75514 7.78336 9.70082 6.20917 12.0003 6.20917C13.946 6.20917 15.6263 7.34608 16.4223 9.00773C16.4223 9.00773 16.5107 9.09518 16.5107 9.00773C17.1298 8.92027 17.8373 8.74536 18.4564 8.74536C18.4564 8.83282 18.4564 8.83282 18.4564 8.74536Z" fill="#006EFF"></path></svg>
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1 @@
|
||||
<svg fill="currentColor" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>LongCat</title><path clip-rule="evenodd" d="M.507 19.883a.507.507 0 01-.489-.642L4.29 3.745a1.013 1.013 0 011.533-.578l5.622 3.687a1.013 1.013 0 001.11 0L18.2 3.165a1.013 1.013 0 011.532.58l4.25 15.497a.506.506 0 01-.49.64H18.07a6.297 6.297 0 001.53-4.115v-.177a6.09 6.09 0 00-1.513-4.017l-.697-3.495a.438.438 0 00-.694-.266L14.07 9.781a.748.748 0 01-.654.121 5.156 5.156 0 00-2.833 0 .746.746 0 01-.653-.121L7.302 7.81a.435.435 0 00-.688.269l-.675 3.652a5.36 5.36 0 00-1.539 3.76v.333c0 1.474.527 2.9 1.488 4.02l.032.038H.507z" fill="#29E154" fill-rule="evenodd"></path><path d="M9.213 16.843h1.52v-3.546h-1.29l-.23 3.546zm5.573 0h-1.52v-3.546h1.29l.23 3.546z"></path></svg>
|
||||
|
After Width: | Height: | Size: 819 B |
@@ -0,0 +1 @@
|
||||
<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>XiaomiMiMo</title><path d="M.958 15.936a.459.459 0 01.459.44v2.729a.46.46 0 01-.918 0v-2.729a.459.459 0 01.459-.44zm4.814-2.035a.46.46 0 01.553.45v4.754a.458.458 0 11-.918 0V15.48L3.74 17.202a.462.462 0 01-.655.016.462.462 0 01-.065-.082L.628 14.67a.459.459 0 01.658-.637l2.124 2.187 2.127-2.188a.46.46 0 01.235-.13zm2.068.004a.46.46 0 01.458.445v4.755a.46.46 0 01-.458.458.459.459 0 01-.458-.458V14.35a.459.459 0 01.458-.445zm1.973 2.014a.46.46 0 01.46.457v2.729a.46.46 0 01-.784.324.46.46 0 01-.134-.324v-2.729a.46.46 0 01.458-.458zm.002-2.045a.458.458 0 01.328.157l2.127 2.19 2.125-2.19a.459.459 0 01.784.318v4.756a.46.46 0 01-.455.458.46.46 0 01-.458-.458V15.48l-1.667 1.723a.46.46 0 01-.65.008l-.005-.005c0-.002-.002-.002-.004-.003l-2.455-2.534a.46.46 0 01-.008-.667.461.461 0 01.338-.128zm6.797 1.206a.46.46 0 01.53.651A1.966 1.966 0 0019.81 18.4a.462.462 0 01.623.18.46.46 0 01-.181.624 2.863 2.863 0 01-1.38.353l-.142-.004a2.88 2.88 0 01-2.393-4.263.461.461 0 01.274-.21zm.864-.931a2.884 2.884 0 013.915 3.914.46.46 0 01-.402.24l-.057-.004a.458.458 0 01-.164-.055.46.46 0 01-.182-.622 1.967 1.967 0 00-2.669-2.67.459.459 0 11-.441-.803zM9.59 6.368c1.481 0 1.696 1.202 1.696 1.654v2.648h-.917v-.432c-.26.346-.792.535-1.36.535-.133 0-1.289-.03-1.384-1.136-.082-.932.675-1.61 2.053-1.61h.691c0-.563-.367-.886-.983-.886-.44.013-.864.174-1.2.458l-.36-.664c.484-.379 1.012-.567 1.764-.567zm4.427.1c1.263 0 2.082.97 2.083 2.15 0 1.181-.824 2.154-2.083 2.154-1.26 0-2.084-.972-2.084-2.152 0-1.18.82-2.153 2.084-2.153zm6.801.015c.68 0 1.202.465 1.197 1.548v2.642H21.1V8.29c0-.312-.002-.98-.63-.98s-.628.667-.628.838v2.524h-.89V8.148c0-.17-.001-.838-.63-.838-.628 0-.628.668-.628.98v2.383h-.917v-4.03h.917V7a1.22 1.22 0 01.947-.516c.398 0 .76.193.982.686a1.321 1.321 0 011.195-.686zm-18.093.872l1.457-1.772H5.32L3.311 8.07l2.14 2.602H4.24L2.725 8.796 1.21 10.672H0L2.138 8.07.13 5.583h1.138l1.458 1.772zm4.149 3.317h-.916V6.644h.916v4.028zm16.99 0h-.916V6.644h.916v4.028zM9.925 8.71c-1.055 0-1.359.412-1.326.742.032.329.324.537.757.537a1.013 1.013 0 001.014-.968l.002-.31h-.447zM14.018 7.3c-.663 0-1.184.487-1.184 1.32 0 .832.52 1.32 1.184 1.32.662 0 1.182-.49 1.182-1.32 0-.832-.52-1.32-1.182-1.32zM6.417 5.001a.568.568 0 01.587.582.588.588 0 01-1.175 0A.57.57 0 016.417 5zm16.991 0a.57.57 0 01.592.582.588.588 0 01-1.174 0 .57.57 0 01.357-.542.572.572 0 01.225-.04z"></path></svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Minimax</title><defs><linearGradient id="lobe-icons-minimax-_R_0_" x1="0%" x2="100.182%" y1="50.057%" y2="50.057%"><stop offset="0%" stop-color="#E2167E"></stop><stop offset="100%" stop-color="#FE603C"></stop></linearGradient></defs><path d="M16.278 2c1.156 0 2.093.927 2.093 2.07v12.501a.74.74 0 00.744.709.74.74 0 00.743-.709V9.099a2.06 2.06 0 012.071-2.049A2.06 2.06 0 0124 9.1v6.561a.649.649 0 01-.652.645.649.649 0 01-.653-.645V9.1a.762.762 0 00-.766-.758.762.762 0 00-.766.758v7.472a2.037 2.037 0 01-2.048 2.026 2.037 2.037 0 01-2.048-2.026v-12.5a.785.785 0 00-.788-.753.785.785 0 00-.789.752l-.001 15.904A2.037 2.037 0 0113.441 22a2.037 2.037 0 01-2.048-2.026V18.04c0-.356.292-.645.652-.645.36 0 .652.289.652.645v1.934c0 .263.142.506.372.638.23.131.514.131.744 0a.734.734 0 00.372-.638V4.07c0-1.143.937-2.07 2.093-2.07zm-5.674 0c1.156 0 2.093.927 2.093 2.07v11.523a.648.648 0 01-.652.645.648.648 0 01-.652-.645V4.07a.785.785 0 00-.789-.78.785.785 0 00-.789.78v14.013a2.06 2.06 0 01-2.07 2.048 2.06 2.06 0 01-2.071-2.048V9.1a.762.762 0 00-.766-.758.762.762 0 00-.766.758v3.8a2.06 2.06 0 01-2.071 2.049A2.06 2.06 0 010 12.9v-1.378c0-.357.292-.646.652-.646.36 0 .653.29.653.646V12.9c0 .418.343.757.766.757s.766-.339.766-.757V9.099a2.06 2.06 0 012.07-2.048 2.06 2.06 0 012.071 2.048v8.984c0 .419.343.758.767.758.423 0 .766-.339.766-.758V4.07c0-1.143.937-2.07 2.093-2.07z" fill="url(#lobe-icons-minimax-_R_0_)" fill-rule="nonzero"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>ModelScope</title><path d="M0 7.967h2.667v2.667H0zM8 10.633h2.667V13.3H8z" fill="#36CED0"></path><path d="M0 10.633h2.667V13.3H0zM2.667 13.3h2.666v2.667H8v2.666H2.667V13.3zM2.667 5.3H8v2.667H5.333v2.666H2.667V5.3zM10.667 13.3h2.667v2.667h-2.667z" fill="#624AFF"></path><path d="M24 7.967h-2.667v2.667H24zM16 10.633h-2.667V13.3H16z" fill="#36CED0"></path><path d="M24 10.633h-2.667V13.3H24zM21.333 13.3h-2.666v2.667H16v2.666h5.333V13.3zM21.333 5.3H16v2.667h2.667v2.666h2.666V5.3z" fill="#624AFF"></path></svg>
|
||||
|
After Width: | Height: | Size: 632 B |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Kimi</title><path d="M21.846 0a1.923 1.923 0 110 3.846H20.15a.226.226 0 01-.227-.226V1.923C19.923.861 20.784 0 21.846 0z" fill="#1783FF"></path><path d="M11.065 11.199l7.257-7.2c.137-.136.06-.41-.116-.41H14.3a.164.164 0 00-.117.051l-7.82 7.756c-.122.12-.302.013-.302-.179V3.82c0-.127-.083-.23-.185-.23H3.186c-.103 0-.186.103-.186.23V19.77c0 .128.083.23.186.23h2.69c.103 0 .186-.102.186-.23v-3.25c0-.069.025-.135.069-.178l2.424-2.406a.158.158 0 01.205-.023l6.484 4.772a7.677 7.677 0 003.453 1.283c.108.012.2-.095.2-.23v-3.06c0-.117-.07-.212-.164-.227a5.028 5.028 0 01-2.027-.807l-5.613-4.064c-.117-.078-.132-.279-.028-.381z" fill="#1783FF"></path></svg>
|
||||
|
After Width: | Height: | Size: 776 B |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Novita AI</title><path clip-rule="evenodd" d="M9.167 4.17v5.665L0 19.003h9.167v-5.666l5.666 5.666H24L9.167 4.17z" fill="#23D57C" fill-rule="evenodd"></path></svg>
|
||||
|
After Width: | Height: | Size: 286 B |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Nvidia</title><path d="M10.212 8.976V7.62c.127-.01.256-.017.388-.021 3.596-.117 5.957 3.184 5.957 3.184s-2.548 3.647-5.282 3.647a3.227 3.227 0 01-1.063-.175v-4.109c1.4.174 1.681.812 2.523 2.258l1.873-1.627a4.905 4.905 0 00-3.67-1.846 6.594 6.594 0 00-.729.044m0-4.476v2.025c.13-.01.259-.019.388-.024 5.002-.174 8.261 4.226 8.261 4.226s-3.743 4.69-7.643 4.69c-.338 0-.675-.031-1.007-.092v1.25c.278.038.558.057.838.057 3.629 0 6.253-1.91 8.794-4.169.421.347 2.146 1.193 2.501 1.564-2.416 2.083-8.048 3.763-11.24 3.763-.308 0-.603-.02-.894-.048V19.5H24v-15H10.21zm0 9.756v1.068c-3.356-.616-4.287-4.21-4.287-4.21a7.173 7.173 0 014.287-2.138v1.172h-.005a3.182 3.182 0 00-2.502 1.178s.615 2.276 2.507 2.931m-5.961-3.3c1.436-1.935 3.604-3.148 5.961-3.336V6.523C5.81 6.887 2 10.723 2 10.723s2.158 6.427 8.21 7.015v-1.166C5.77 16 4.25 10.958 4.25 10.958h-.002z" fill="#74B71B" fill-rule="nonzero"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>OpenAI</title><path d="M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
@@ -0,0 +1 @@
|
||||
<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>OpenRouter</title><path d="M18.654 3.87a5.087 5.087 0 110 10.174L23.7 19.09c.64.641.187 1.737-.72 1.737H8.48a8.479 8.479 0 010-16.958h10.175zM8.479 7.26a5.087 5.087 0 100 10.176 5.087 5.087 0 000-10.175z"></path></svg>
|
||||
|
After Width: | Height: | Size: 382 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none"><path d="M12 2.5 3.5 17h17L12 2.5Z" fill="#007F55"/><path d="M12 7.5 7 16h10l-5-8.5Z" fill="#F1FFF8"/><path d="M12 12 9.6 16h4.8L12 12Z" fill="#007F55"/><path d="M12 16v5" stroke="#007F55" stroke-width="2" stroke-linecap="round"/></svg>
|
||||
|
After Width: | Height: | Size: 332 B |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>BaiduCloud</title><path d="M21.715 5.61l-3.983 2.31a.903.903 0 01-.896 0L12.44 5.384a.903.903 0 00-.897 0L7.156 7.92a.903.903 0 01-.896 0L2.276 5.617 12.002 0l9.713 5.61z" fill="#5BCA87"></path><path d="M18.641 9.467a.89.89 0 00-.438.77v5.072a.896.896 0 01-.445.77l-4.428 2.51a.884.884 0 00-.445.777v4.607l4.429-2.536 5.31-3.047V7.157l-3.983 2.31z" fill="#EC5D3E"></path><path d="M10.98 18.941a.936.936 0 00-.305-.352l-4.429-2.516a.903.903 0 01-.431-.764v-5.078a.89.89 0 00-.452-.757l-.451-.26L1.38 7.158V18.39l5.311 3.047L11.126 24v-4.608a.881.881 0 00-.146-.45z" fill="#2464F5"></path></svg>
|
||||
|
After Width: | Height: | Size: 717 B |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Qiniu</title><path d="M23.111 4.6a.914.914 0 00-.861.161A13.443 13.443 0 017.947 8.897L7.38 6.831a1.076 1.076 0 00-1.211-.698l.27 2.18c-1.816-.827-2.313-.946-3.587-2.45C2.674 5.729 1.263 4.472.89 4.6a11.906 11.906 0 005.892 6.497l.738 5.97s.33 2.286 2.473 2.286h4.586c2.144 0 2.474-2.286 2.474-2.286l.518-4.28c-1.393-.11-2.268.857-2.546 1.814-.465 1.614-.465 1.716-.557 1.998-.188.575-.806.644-.806.644h-2.753s-.617-.07-.806-.644c-.12-.371-.727-2.54-1.335-4.74A11.877 11.877 0 0023.11 4.599V4.6z" fill="#06AEEF"></path></svg>
|
||||
|
After Width: | Height: | Size: 649 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><rect width="24" height="24" rx="5" fill="#111827"/><text x="12" y="16" font-family="sans-serif" font-weight="700" font-size="10" fill="#FFFFFF" text-anchor="middle">RQ</text></svg>
|
||||
|
After Width: | Height: | Size: 265 B |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>SiliconCloud</title><path clip-rule="evenodd" d="M22.956 6.521H12.522c-.577 0-1.044.468-1.044 1.044v3.13c0 .577-.466 1.044-1.043 1.044H1.044c-.577 0-1.044.467-1.044 1.044v4.174C0 17.533.467 18 1.044 18h10.434c.577 0 1.044-.467 1.044-1.043v-3.13c0-.578.466-1.044 1.043-1.044h9.391c.577 0 1.044-.467 1.044-1.044V7.565c0-.576-.467-1.044-1.044-1.044z" fill="#6E29F6" fill-rule="evenodd"></path></svg>
|
||||
|
After Width: | Height: | Size: 520 B |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Volcengine</title><path d="M19.44 10.153l-2.936 11.586a.215.215 0 00.214.261h5.87a.215.215 0 00.214-.261l-2.95-11.586a.214.214 0 00-.412 0zM3.28 12.778l-2.275 8.96A.214.214 0 001.22 22h4.532a.212.212 0 00.214-.165.214.214 0 000-.097l-2.276-8.96a.214.214 0 00-.41 0z" fill="#00E5E5"></path><path d="M7.29 5.359L3.148 21.738a.215.215 0 00.203.261h8.29a.214.214 0 00.215-.261L7.7 5.358a.214.214 0 00-.41 0z" fill="#006EFF"></path><path d="M14.44.15a.214.214 0 00-.41 0L8.366 21.739a.214.214 0 00.214.261H19.9a.216.216 0 00.171-.078.214.214 0 00.044-.183L14.439.15z" fill="#006EFF"></path><path d="M10.278 7.741L6.685 21.736a.214.214 0 00.214.264h7.17a.215.215 0 00.214-.264L10.688 7.741a.214.214 0 00-.41 0z" fill="#00E5E5"></path></svg>
|
||||
|
After Width: | Height: | Size: 858 B |
@@ -0,0 +1 @@
|
||||
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Zhipu</title><path d="M11.991 23.503a.24.24 0 00-.244.248.24.24 0 00.244.249.24.24 0 00.245-.249.24.24 0 00-.22-.247l-.025-.001zM9.671 5.365a1.697 1.697 0 011.099 2.132l-.071.172-.016.04-.018.054c-.07.16-.104.32-.104.498-.035.71.47 1.279 1.186 1.314h.366c1.309.053 2.338 1.173 2.286 2.523-.052 1.332-1.152 2.38-2.478 2.327h-.174c-.715.018-1.274.64-1.239 1.368 0 .124.018.23.053.337.209.373.54.658.96.8.75.23 1.517-.125 1.9-.782l.018-.035c.402-.64 1.17-.96 1.92-.711.854.284 1.378 1.226 1.099 2.167a1.661 1.661 0 01-2.077 1.102 1.711 1.711 0 01-.907-.711l-.017-.035c-.2-.323-.463-.58-.851-.711l-.056-.018a1.646 1.646 0 00-1.954.746 1.66 1.66 0 01-1.065.764 1.677 1.677 0 01-1.989-1.279c-.209-.906.332-1.83 1.257-2.043a1.51 1.51 0 01.296-.035h.018c.68-.071 1.151-.622 1.116-1.333a1.307 1.307 0 00-.227-.693 2.515 2.515 0 01-.366-1.403 2.39 2.39 0 01.366-1.208c.14-.195.21-.444.227-.693.018-.71-.506-1.261-1.186-1.332l-.07-.018a1.43 1.43 0 01-.299-.07l-.05-.019a1.7 1.7 0 01-1.047-2.114 1.68 1.68 0 012.094-1.101zm-5.575 10.11c.26-.264.639-.367.994-.27.355.096.633.379.728.74.095.362-.007.748-.267 1.013-.402.41-1.053.41-1.455 0a1.062 1.062 0 010-1.482zm14.845-.294c.359-.09.738.024.992.297.254.274.344.665.237 1.025-.107.36-.396.634-.756.718-.551.128-1.1-.22-1.23-.781a1.05 1.05 0 01.757-1.26zm-.064-4.39c.314.32.49.753.49 1.206 0 .452-.176.886-.49 1.206-.315.32-.74.5-1.185.5-.444 0-.87-.18-1.184-.5a1.727 1.727 0 010-2.412 1.654 1.654 0 012.369 0zm-11.243.163c.364.484.447 1.128.218 1.691a1.665 1.665 0 01-2.188.923c-.855-.36-1.26-1.358-.907-2.228a1.68 1.68 0 011.33-1.038c.593-.08 1.183.169 1.547.652zm11.545-4.221c.368 0 .708.2.892.524.184.324.184.724 0 1.048a1.026 1.026 0 01-.892.524c-.568 0-1.03-.47-1.03-1.048 0-.579.462-1.048 1.03-1.048zm-14.358 0c.368 0 .707.2.891.524.184.324.184.724 0 1.048a1.026 1.026 0 01-.891.524c-.569 0-1.03-.47-1.03-1.048 0-.579.461-1.048 1.03-1.048zm10.031-1.475c.925 0 1.675.764 1.675 1.706s-.75 1.705-1.675 1.705-1.674-.763-1.674-1.705c0-.942.75-1.706 1.674-1.706zm-2.626-.684c.362-.082.653-.356.761-.718a1.062 1.062 0 00-.238-1.028 1.017 1.017 0 00-.996-.294c-.547.14-.881.7-.752 1.257.13.558.675.907 1.225.783zm0 16.876c.359-.087.644-.36.75-.72a1.062 1.062 0 00-.237-1.019 1.018 1.018 0 00-.985-.301 1.037 1.037 0 00-.762.717c-.108.361-.017.754.239 1.028.245.263.606.377.953.305l.043-.01zM17.19 3.5a.631.631 0 00.628-.64c0-.355-.279-.64-.628-.64a.631.631 0 00-.628.64c0 .355.28.64.628.64zm-10.38 0a.631.631 0 00.628-.64c0-.355-.28-.64-.628-.64a.631.631 0 00-.628.64c0 .355.279.64.628.64zm-5.182 7.852a.631.631 0 00-.628.64c0 .354.28.639.628.639a.63.63 0 00.627-.606l.001-.034a.62.62 0 00-.628-.64zm5.182 9.13a.631.631 0 00-.628.64c0 .355.279.64.628.64a.631.631 0 00.628-.64c0-.355-.28-.64-.628-.64zm10.38.018a.631.631 0 00-.628.64c0 .355.28.64.628.64a.631.631 0 00.628-.64c0-.355-.279-.64-.628-.64zm5.182-9.148a.631.631 0 00-.628.64c0 .354.279.639.628.639a.631.631 0 00.628-.64c0-.355-.28-.64-.628-.64zm-.384-4.992a.24.24 0 00.244-.249.24.24 0 00-.244-.249.24.24 0 00-.244.249c0 .142.122.249.244.249zM11.991.497a.24.24 0 00.245-.248A.24.24 0 0011.99 0a.24.24 0 00-.244.249c0 .133.108.236.223.247l.021.001zM2.011 6.36a.24.24 0 00.245-.249.24.24 0 00-.244-.249.24.24 0 00-.244.249.24.24 0 00.244.249zm0 11.263a.24.24 0 00-.243.248.24.24 0 00.244.249.24.24 0 00.244-.249.252.252 0 00-.244-.248zm19.995-.018a.24.24 0 00-.245.248.24.24 0 00.245.25.24.24 0 00.244-.25.252.252 0 00-.244-.248z" fill="#3859FF" fill-rule="nonzero"></path></svg>
|
||||
|
After Width: | Height: | Size: 3.5 KiB |
@@ -0,0 +1,199 @@
|
||||
// Package providers registers Azure OpenAI (Azure AI Foundry).
|
||||
//
|
||||
// Facts (https://learn.microsoft.com/azure/ai-foundry/openai/api-version-lifecycle
|
||||
// and https://learn.microsoft.com/azure/ai-foundry/openai/how-to/reasoning):
|
||||
// - there are two request shapes. The v1 shape,
|
||||
// https://{resource}.openai.azure.com/openai/v1/chat/completions with the
|
||||
// deployment name in the body's `model` field, is the current GA data
|
||||
// plane and takes no api-version at all: "api-version is no longer a
|
||||
// required parameter with the v1 GA API". Every example on the reasoning
|
||||
// how-to page (last updated 2026-09-16) uses it. The legacy shape,
|
||||
// .../openai/deployments/{deployment}/chat/completions?api-version=...,
|
||||
// is still served but its newest GA api-version is 2024-10-21, which
|
||||
// predates `max_completion_tokens` (2024-09-01-preview) and
|
||||
// `reasoning_effort` (2024-12-01-preview) — so a reasoning deployment
|
||||
// cannot work on it. The Endpoint hook therefore emits the v1 shape by
|
||||
// default and only falls back to the legacy shape when the operator
|
||||
// explicitly fills the api_version extra field;
|
||||
// - authentication is the `api-key` header, not a bearer token (Entra AzureOpenaiID
|
||||
// bearer tokens are the other documented option and are not modelled);
|
||||
// - the model name stored on the row is the deployment name, so the
|
||||
// catalog only carries family patterns (gpt-6*, gpt-5*, o1*, o3*, o4*,
|
||||
// ...) that mirror the OpenAI vendor: reasoning deployments use
|
||||
// `max_completion_tokens`, `reasoning_effort`, the developer role, and
|
||||
// reject temperature, top_p, presence_penalty, frequency_penalty,
|
||||
// logprobs, top_logprobs, logit_bias and max_tokens;
|
||||
// - `reasoning_effort` accepts none | minimal | low | medium | high |
|
||||
// xhigh | max, model-dependent; `xhigh` is limited to GPT-6, GPT-5.6,
|
||||
// GPT-5.5, GPT-5.4 and gpt-5.1-codex-max, `max` to GPT-6 and GPT-5.6 on
|
||||
// the Responses API only, and `minimal` to the original GPT-5 models.
|
||||
// Because a deployment name says nothing about which model backs it, the
|
||||
// family patterns stay on the conservative subset. The exception is a
|
||||
// deployment named exactly gpt-5, gpt-5-mini or gpt-5-nano, which is
|
||||
// overwhelmingly the model of that name: those three carry their own
|
||||
// entries mirroring the openai vendor, because the original GPT-5 trio
|
||||
// supports "Reasoning.effort ... minimal, low, medium, and high"
|
||||
// (https://developers.openai.com/api/docs/models/gpt-5) and rejects
|
||||
// `none`, unlike GPT-5.1 and later, which the gpt-5* pattern covers;
|
||||
// - `store: false`, `prompt_cache_key` and cached-token usage behave as
|
||||
// on api.openai.com.
|
||||
//
|
||||
// # The one path rule
|
||||
//
|
||||
// A stored row picks its data plane from `extra_config.api_version` alone,
|
||||
// and chat, VLM and embedding all apply the same rule to the same row:
|
||||
//
|
||||
// api_version empty -> {base}/openai/v1{path}, no api-version, the
|
||||
// deployment name travelling in the body's
|
||||
// `model` field;
|
||||
// api_version non-empty -> {base}/openai/deployments/{deployment}{path}
|
||||
// ?api-version={value}.
|
||||
//
|
||||
// Chat and VLM reach this through the Endpoint hook below (VLM is built on
|
||||
// the chat client); embedding applies it in azureEmbeddingURL in
|
||||
// internal/models/embedding/azure_openai.go, which calls this same hook.
|
||||
//
|
||||
// The v1 default is not a guess. The v1 API reference is published at
|
||||
// "API Version: v1" with server {endpoint}/openai/v1 and covers the paths
|
||||
// this vendor uses, embeddings included
|
||||
// (https://learn.microsoft.com/rest/api/microsoft-foundry/azureopenai/embeddings:
|
||||
// "POST {endpoint}/openai/v1/embeddings", with `api-version` marked
|
||||
// "Required: No" and defaulting to v1). The lifecycle page's prerequisites
|
||||
// for the v1 API are only a subscription, a Foundry or Azure OpenAI resource
|
||||
// in a supported region, and at least one model deployment — there is no
|
||||
// resource-level switch to flip, and `base_url` is documented to accept the
|
||||
// https://{resource}.openai.azure.com/openai/v1/ form. The dated path is not
|
||||
// a parallel modern option: 2024-10-21 is still the newest GA api-version
|
||||
// there, so the reasoning surface this vendor advertises
|
||||
// (`max_completion_tokens`, 2024-09-01-preview; `reasoning_effort`,
|
||||
// 2024-12-01-preview) exists on no GA dated version at all.
|
||||
//
|
||||
// Behaviour change for existing rows: before the catalog, a row with no
|
||||
// api_version used the dated deployments path (the Go SDK's built-in Azure
|
||||
// default for chat and VLM, a hard-coded 2024-10-21 for embedding). Those
|
||||
// rows now use /openai/v1. This is deliberate and documented in
|
||||
// website-docs/03-features/06-models.md; an operator whose gateway only
|
||||
// serves the dated path (an API Management front end, a sovereign cloud)
|
||||
// restores the exact previous shape by filling the api_version extra field.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"academy/internal/models"
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/azure_openai.svg
|
||||
var azureOpenaiIcon []byte
|
||||
|
||||
// AzureOpenaiID is the provider identifier stored on model rows.
|
||||
const AzureOpenaiID = "azure_openai"
|
||||
|
||||
// AzureOpenaiBaseURL is the resource endpoint template; the operator replaces
|
||||
// {resource} with their own resource name.
|
||||
const AzureOpenaiBaseURL = "https://{resource}.openai.azure.com"
|
||||
|
||||
// AzureOpenaiLegacyAPIVersion is the newest GA api-version of the dated data-plane
|
||||
// inference spec. It is only used when the operator explicitly asks for the
|
||||
// legacy deployments path; it predates reasoning_effort, so reasoning
|
||||
// deployments need a preview version such as 2025-04-01-preview instead.
|
||||
const AzureOpenaiLegacyAPIVersion = "2024-10-21"
|
||||
|
||||
func newAzureOpenaiProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: AzureOpenaiID,
|
||||
Name: "Azure OpenAI",
|
||||
Names: map[string]string{"zh-CN": "Azure OpenAI"},
|
||||
Description: "gpt-4o, gpt-5, o3, text-embedding-3-large deployments, etc.",
|
||||
Website: "https://ai.azure.com",
|
||||
Icon: azureOpenaiIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 31,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthAPIKeyHeader,
|
||||
URLPatterns: []string{"openai.azure.com"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: AzureOpenaiBaseURL,
|
||||
types.ModelTypeEmbedding: AzureOpenaiBaseURL,
|
||||
types.ModelTypeVLLM: AzureOpenaiBaseURL,
|
||||
},
|
||||
// ASR is deliberately absent. The ASR client now resolves through
|
||||
// this vendor (api-key header, Endpoint hook below), but the only
|
||||
// v1 reference for audio is the preview one —
|
||||
// POST {endpoint}/openai/v1/audio/transcriptions?api-version=preview
|
||||
// (https://learn.microsoft.com/en-us/azure/foundry/openai/reference-preview-latest)
|
||||
// — while the hook sends a row without api_version to the v1 path
|
||||
// with no version at all. Until that is verified against a live
|
||||
// resource, advertising the type would let the picker create a row
|
||||
// that may fail at first use. A row with an explicit api_version
|
||||
// would take the documented deployments path.
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeVLLM,
|
||||
},
|
||||
ExtraFields: []ExtraField{
|
||||
{
|
||||
Key: models.ExtraAPIVersion,
|
||||
Label: "API Version (legacy deployments path)",
|
||||
Labels: map[string]string{"zh-CN": "API 版本(旧版 deployments 路径)"},
|
||||
Type: "string",
|
||||
Required: false,
|
||||
// Empty means the v1 GA data plane, which takes no
|
||||
// api-version. A value switches back to the dated
|
||||
// /openai/deployments/... path.
|
||||
Placeholder: "leave empty for /openai/v1, or e.g. 2025-04-01-preview",
|
||||
Placeholders: map[string]string{
|
||||
"zh-CN": "留空走 /openai/v1,或填如 2025-04-01-preview",
|
||||
},
|
||||
},
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
// The same body as OpenAI's; the Endpoint hook below supplies the
|
||||
// v1 or deployments URL.
|
||||
SendEncodingFormat: api.Ptr(true),
|
||||
DimensionsField: api.Ptr("dimensions"),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatOpenAI),
|
||||
SupportsReasoningEffort: api.Ptr(true),
|
||||
SupportsDeveloperRole: api.Ptr(true),
|
||||
SupportsStore: api.Ptr(true),
|
||||
PromptCacheKey: api.Ptr(true),
|
||||
PromptCacheAccounting: api.Ptr(true),
|
||||
},
|
||||
},
|
||||
Endpoint: func(r EndpointRequest) (string, map[string]string) {
|
||||
var path string
|
||||
switch r.ModelType {
|
||||
case types.ModelTypeEmbedding:
|
||||
path = "/embeddings"
|
||||
case types.ModelTypeASR:
|
||||
path = "/audio/transcriptions"
|
||||
default:
|
||||
if r.API == api.APIOpenAIResponses {
|
||||
path = "/responses"
|
||||
} else {
|
||||
path = "/chat/completions"
|
||||
}
|
||||
}
|
||||
root := strings.TrimRight(r.BaseURL, "/")
|
||||
// An explicit api-version selects the legacy deployments path;
|
||||
// otherwise use the v1 GA data plane, which carries the
|
||||
// deployment name in the body instead of the URL.
|
||||
if version := strings.TrimSpace(r.Extra[models.ExtraAPIVersion]); version != "" {
|
||||
legacy := root + "/openai/deployments/" + url.PathEscape(r.Model) + path
|
||||
return legacy, map[string]string{"api-version": version}
|
||||
}
|
||||
if strings.HasSuffix(root, "/openai/v1") {
|
||||
return root + path, nil
|
||||
}
|
||||
return root + "/openai/v1" + path, nil
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package providers
|
||||
|
||||
import "academy/internal/models/internal/configcopy"
|
||||
|
||||
// Builtins returns independent provider definitions without registering global state.
|
||||
func Builtins() []*Definition {
|
||||
return configcopy.Clone([]*Definition{
|
||||
newAliyunProvider(),
|
||||
newAnthropicProvider(),
|
||||
newAzureOpenaiProvider(),
|
||||
newCohereProvider(),
|
||||
newDeepseekProvider(),
|
||||
newGeminiProvider(),
|
||||
newGenericProvider(),
|
||||
newGpustackProvider(),
|
||||
newHuggingFaceTEIProvider(),
|
||||
newHunyuanProvider(),
|
||||
newJinaProvider(),
|
||||
newLitellmProvider(),
|
||||
newLkeapProvider(),
|
||||
newLongcatProvider(),
|
||||
newMimoProvider(),
|
||||
newMinimaxProvider(),
|
||||
newModelscopeProvider(),
|
||||
newMoonshotProvider(),
|
||||
newNovitaProvider(),
|
||||
newNvidiaProvider(),
|
||||
newOpenaiProvider(),
|
||||
newOpenrouterProvider(),
|
||||
newPineconeProvider(),
|
||||
newQianfanProvider(),
|
||||
newQiniuProvider(),
|
||||
newRequestyProvider(),
|
||||
newSiliconflowProvider(),
|
||||
newVolcengineProvider(),
|
||||
newAcademyCloudProvider(),
|
||||
newZhipuProvider(),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Package providers registers Cohere's hosted text rerank API.
|
||||
// https://docs.cohere.com/v2/reference/rerank
|
||||
package providers
|
||||
|
||||
import (
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// CohereID identifies Cohere in stored model configurations.
|
||||
const CohereID = "cohere"
|
||||
|
||||
// CohereRerankBaseURL serves Cohere's v2 rerank API.
|
||||
const CohereRerankBaseURL = "https://api.cohere.com/v2"
|
||||
|
||||
func newCohereProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: CohereID, Name: "Cohere",
|
||||
Description: "Cohere text reranking (rerank-v4.0-pro, rerank-v4.0-fast, rerank-v3.5)",
|
||||
Website: "https://cohere.com", Icon: genericIcon,
|
||||
API: api.APIOpenAICompletions, RerankAPI: api.RerankCohere,
|
||||
Order: 57, RequiresAuth: true, Auth: AuthBearer,
|
||||
URLPatterns: []string{"api.cohere.com"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{types.ModelTypeRerank: CohereRerankBaseURL},
|
||||
ModelTypes: []types.ModelType{types.ModelTypeRerank},
|
||||
Compat: VendorCompat{Rerank: api.RerankCompat{
|
||||
// The reference recommends no more than 1,000 documents per
|
||||
// request; use that as our batch size, not a claimed hard limit.
|
||||
// Omitting top_n returns all results. v2 does not need echoed
|
||||
// documents: the caller restores their text by result index.
|
||||
MaxDocuments: api.Ptr(1000),
|
||||
}},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package providers_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/models/providers"
|
||||
modelruntime "academy/internal/models/runtime"
|
||||
"academy/internal/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCohereRerankCatalog(t *testing.T) {
|
||||
v, ok := modelruntime.Get("cohere")
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, []types.ModelType{types.ModelTypeRerank}, v.ModelTypes)
|
||||
assert.Equal(t, "https://api.cohere.com/v2", v.GetDefaultURL(types.ModelTypeRerank))
|
||||
assert.Equal(t, "cohere", modelruntime.DetectByURL("https://api.cohere.com/v2/rerank"))
|
||||
assert.Error(t, v.ValidateConfig(&providers.Config{ModelName: "rerank-v4.0-pro"}))
|
||||
assert.NoError(t, v.ValidateConfig(&providers.Config{ModelName: "rerank-v4.0-pro", APIKey: "k"}))
|
||||
for _, model := range []string{"rerank-v4.0-pro", "rerank-v4.0-fast", "rerank-v3.5"} {
|
||||
r, err := modelruntime.Resolve(modelruntime.Ref{
|
||||
Provider: "cohere", Model: model, ModelType: types.ModelTypeRerank,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.True(t, r.Cataloged, model)
|
||||
assert.Equal(t, api.RerankCohere, r.RerankAPI)
|
||||
assert.Equal(t, 1000, r.Rerank.MaxDocuments)
|
||||
assert.Equal(t, api.ScoreProbability, r.Rerank.ScoreScale)
|
||||
assert.False(t, r.Rerank.SendTopN)
|
||||
assert.False(t, r.Rerank.SendReturnDocs)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package providers
|
||||
|
||||
import "academy/internal/models/api"
|
||||
|
||||
// VendorCompat carries a vendor's defaults for every protocol it may speak.
|
||||
type VendorCompat struct {
|
||||
OpenAICompletions api.OpenAICompletionsCompat `json:"openai_completions,omitempty"`
|
||||
OpenAIResponses api.OpenAIResponsesCompat `json:"openai_responses,omitempty"`
|
||||
AnthropicMessages api.AnthropicMessagesCompat `json:"anthropic_messages,omitempty"`
|
||||
GoogleGenerativeAI api.GoogleGenerativeAICompat `json:"google_generative_ai,omitempty"`
|
||||
// Rerank is the rerank protocol overlay. It has no per-protocol variants:
|
||||
// a vendor serves exactly one rerank dialect.
|
||||
Rerank api.RerankCompat `json:"rerank,omitempty"`
|
||||
// Embeddings is the embedding protocol overlay, likewise one per vendor.
|
||||
Embeddings api.EmbeddingsCompat `json:"embeddings,omitempty"`
|
||||
// Transcriptions is the speech-to-text overlay, likewise one per vendor.
|
||||
Transcriptions api.TranscriptionsCompat `json:"transcriptions,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
// Package providers registers DeepSeek's first-party API.
|
||||
//
|
||||
// Facts (https://api-docs.deepseek.com/api/create-chat-completion and
|
||||
// https://api-docs.deepseek.com/guides/thinking_mode):
|
||||
// - output cap is `max_tokens`, "between 1 and 384K (393216)"; the default
|
||||
// is 8K without thinking, 64K with it, 128K at `reasoning_effort: max`.
|
||||
// `max_completion_tokens` is not part of the reference;
|
||||
// - thinking is switched with `thinking: {"type": "enabled"|"disabled"}`
|
||||
// (the documented default is `enabled`) and graded with
|
||||
// `reasoning_effort`, whose values are none | low | high | max. `none`
|
||||
// is the effort spelling of "off"; on this OpenAI surface the protocol
|
||||
// switches thinking off with `thinking.type = disabled` instead, which
|
||||
// is what the reference documents;
|
||||
// - temperature (0..2) "has no effect in thinking mode" but is still
|
||||
// accepted, so sampling parameters keep being sent; `top_p` only takes
|
||||
// effect in thinking mode, where values below 0.95 are treated as 0.95;
|
||||
// presence_penalty / frequency_penalty are "no longer supported" and are
|
||||
// silently dropped by the vendor;
|
||||
// - tool_choice lists none / auto / required / a named function, but the
|
||||
// reference adds that "required and named tool choices are not supported
|
||||
// in thinking mode; the API returns a 400 error". Thinking is the
|
||||
// documented default, and the compat model cannot make the restriction
|
||||
// conditional on it, so only none / auto are ever sent;
|
||||
// - assistant turns must replay `reasoning_content` when the request
|
||||
// carries `tools`; without `tools` the vendor ignores it;
|
||||
// - usage reports `prompt_cache_hit_tokens` / `prompt_cache_miss_tokens`
|
||||
// next to `prompt_tokens_details.cached_tokens`;
|
||||
// - DeepSeek also serves an Anthropic Messages surface at
|
||||
// https://api.deepseek.com/anthropic and a Responses surface on the same
|
||||
// host (https://api-docs.deepseek.com/guides/anthropic_api and
|
||||
// .../guides/responses_api). The documented default, and what this
|
||||
// package configures, is OpenAI Chat Completions.
|
||||
//
|
||||
// unverified: the current docs give the base URL as https://api.deepseek.com
|
||||
// with no version segment; the /v1 alias this package uses (and that
|
||||
// provider.DeepSeekBaseURL and stored model rows carry) is no longer spelled
|
||||
// out in them, and nothing documents it being rejected, so it is kept.
|
||||
//
|
||||
// Prices in models.json are the USD off-peak rates of
|
||||
// https://api-docs.deepseek.com/quick_start/pricing (peak is exactly 2x);
|
||||
// `cost.input` is the cache-miss rate and `cost.cache_read` the cache-hit one.
|
||||
//
|
||||
// unverified: `parallel_tool_calls`, `prompt_cache_key` and
|
||||
// `stream_options.include_usage` semantics beyond the field itself are not
|
||||
// described in the reference; the protocol defaults are kept.
|
||||
//
|
||||
// unverified: deepseek-v4-pro carries a per-model override that lifts
|
||||
// minimal / low to `high`. The reference enumerates low / high / max for the
|
||||
// API as a whole without restricting them per model, so the override is kept
|
||||
// but nothing documents it.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/deepseek.svg
|
||||
var deepseekIcon []byte
|
||||
|
||||
// DeepseekID is the provider identifier stored on model rows.
|
||||
const DeepseekID = "deepseek"
|
||||
|
||||
// DeepseekBaseURL is the documented first-party endpoint.
|
||||
const DeepseekBaseURL = "https://api.deepseek.com/v1"
|
||||
|
||||
func newDeepseekProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: DeepseekID,
|
||||
Name: "DeepSeek",
|
||||
Names: map[string]string{"zh-CN": "DeepSeek 深度求索"},
|
||||
Description: "deepseek-flash, deepseek-v4-pro",
|
||||
Website: "https://platform.deepseek.com",
|
||||
Icon: deepseekIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 30,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"api.deepseek.com"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: DeepseekBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{types.ModelTypeKnowledgeQA},
|
||||
Compat: VendorCompat{
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
MaxTokensField: api.Ptr("max_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatThinkingType),
|
||||
SupportsReasoningEffort: api.Ptr(true),
|
||||
PromptCacheAccounting: api.Ptr(true),
|
||||
SupportsStore: api.Ptr(false),
|
||||
// `required` and named functions 400 while thinking is on,
|
||||
// which is the default on every current model.
|
||||
ToolChoiceModes: []string{"none", "auto"},
|
||||
},
|
||||
},
|
||||
// DeepSeek grades effort as low / high / max (plus `none`, which the
|
||||
// protocol expresses as thinking.type=disabled): medium clamps up to
|
||||
// high, minimal down to low, xhigh up to max.
|
||||
ThinkingLevels: api.ThinkingLevelMap{
|
||||
api.ReasoningMinimal: api.StringPtr("low"),
|
||||
api.ReasoningLow: api.StringPtr("low"),
|
||||
api.ReasoningMedium: api.StringPtr("high"),
|
||||
api.ReasoningHigh: api.StringPtr("high"),
|
||||
api.ReasoningXHigh: api.StringPtr("max"),
|
||||
api.ReasoningMax: api.StringPtr("max"),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
// Package providers defines vendor defaults and routing rules independently of the model catalog.
|
||||
package providers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"academy/internal/models"
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// AuthStyle names how a vendor expects credentials.
|
||||
type AuthStyle string
|
||||
|
||||
const (
|
||||
// AuthBearer sends Authorization: Bearer <key>.
|
||||
AuthBearer AuthStyle = "bearer"
|
||||
// AuthAPIKeyHeader sends api-key: <key> (Azure OpenAI).
|
||||
AuthAPIKeyHeader AuthStyle = "api-key"
|
||||
// AuthXAPIKey sends x-api-key: <key> (Anthropic).
|
||||
AuthXAPIKey AuthStyle = "x-api-key"
|
||||
// AuthGoogleAPIKey sends x-goog-api-key: <key> (Gemini native).
|
||||
AuthGoogleAPIKey AuthStyle = "x-goog-api-key"
|
||||
// AuthNone sends nothing (local deployments).
|
||||
AuthNone AuthStyle = "none"
|
||||
// AuthSigned delegates to the vendor's Signer hook (Academy Cloud).
|
||||
AuthSigned AuthStyle = "signed"
|
||||
)
|
||||
|
||||
// ExtraField describes one vendor-specific configuration input the model
|
||||
// editor renders dynamically (Azure api-version, LKEAP secret key, ...).
|
||||
type ExtraField struct {
|
||||
Key string `json:"key"`
|
||||
Label string `json:"label"`
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
Type string `json:"type"` // "string", "number", "boolean", "select", "password"
|
||||
Required bool `json:"required"`
|
||||
Default string `json:"default,omitempty"`
|
||||
Placeholder string `json:"placeholder,omitempty"`
|
||||
// Placeholders carries localized variants of Placeholder.
|
||||
Placeholders map[string]string `json:"placeholders,omitempty"`
|
||||
Options []ExtraFieldOption `json:"options,omitempty"`
|
||||
// ModelTypes restricts the field to some model types; empty means all.
|
||||
ModelTypes []types.ModelType `json:"model_types,omitempty"`
|
||||
// Secret marks values that must never be echoed back to the UI.
|
||||
Secret bool `json:"secret,omitempty"`
|
||||
}
|
||||
|
||||
// CredentialLabel renames the primary credential input for one vendor.
|
||||
//
|
||||
// Most vendors take an API key and need none of this. LKEAP and Volcengine
|
||||
// authenticate their rerank API with a CAM / IAM identity pair instead, where
|
||||
// the first field is a SecretId / AccessKeyId — calling it "API Key" leads
|
||||
// operators to paste an `sk-` token that can never authenticate. The vendor
|
||||
// says what the field is called rather than the editor hardcoding a table of
|
||||
// vendor ids, which is what this whole layer exists to avoid.
|
||||
type CredentialLabel struct {
|
||||
Label string `json:"label"`
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
Placeholder string `json:"placeholder,omitempty"`
|
||||
Placeholders map[string]string `json:"placeholders,omitempty"`
|
||||
// Hint is rendered under the input, for a warning the label cannot carry.
|
||||
Hint string `json:"hint,omitempty"`
|
||||
Hints map[string]string `json:"hints,omitempty"`
|
||||
// ModelTypes restricts the override; empty means every type.
|
||||
ModelTypes []types.ModelType `json:"model_types,omitempty"`
|
||||
// Required marks the credential mandatory even where the generic label
|
||||
// calls it optional.
|
||||
Required bool `json:"required,omitempty"`
|
||||
}
|
||||
|
||||
// LocalizedLabel / LocalizedPlaceholder / LocalizedHint resolve one locale,
|
||||
// falling back to the default string.
|
||||
func (c CredentialLabel) LocalizedLabel(locale string) string {
|
||||
return localizedOr(c.Labels, locale, c.Label)
|
||||
}
|
||||
|
||||
// LocalizedPlaceholder resolves the placeholder for a locale.
|
||||
func (c CredentialLabel) LocalizedPlaceholder(locale string) string {
|
||||
return localizedOr(c.Placeholders, locale, c.Placeholder)
|
||||
}
|
||||
|
||||
// LocalizedHint resolves the hint for a locale.
|
||||
func (c CredentialLabel) LocalizedHint(locale string) string {
|
||||
return localizedOr(c.Hints, locale, c.Hint)
|
||||
}
|
||||
|
||||
func localizedOr(table map[string]string, locale, fallback string) string {
|
||||
if v, ok := table[locale]; ok && v != "" {
|
||||
return v
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
// LocalizedPlaceholder resolves the placeholder for a locale.
|
||||
func (f ExtraField) LocalizedPlaceholder(locale string) string {
|
||||
return localizedOr(f.Placeholders, locale, f.Placeholder)
|
||||
}
|
||||
|
||||
// CredentialLabelFor returns the credential naming for a model type, or nil
|
||||
// when the vendor uses the generic API-key wording.
|
||||
func (v *Definition) CredentialLabelFor(modelType types.ModelType) *CredentialLabel {
|
||||
for i := range v.CredentialLabels {
|
||||
c := &v.CredentialLabels[i]
|
||||
if len(c.ModelTypes) == 0 {
|
||||
return c
|
||||
}
|
||||
for _, mt := range c.ModelTypes {
|
||||
if mt == modelType {
|
||||
return c
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ExtraFieldOption is one choice of a select field. Labels carries localized
|
||||
// variants keyed by locale, like every other operator-facing string here: an
|
||||
// option whose label is prose rather than an identifier is unreadable to half
|
||||
// the product without it.
|
||||
type ExtraFieldOption struct {
|
||||
Label string `json:"label"`
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
// LocalizedLabel resolves the option label for a locale.
|
||||
func (o ExtraFieldOption) LocalizedLabel(locale string) string {
|
||||
return localizedOr(o.Labels, locale, o.Label)
|
||||
}
|
||||
|
||||
// EndpointRequest is the input to a vendor's Endpoint hook.
|
||||
type EndpointRequest struct {
|
||||
BaseURL string
|
||||
Model string
|
||||
ModelType types.ModelType
|
||||
API api.API
|
||||
// EmbeddingAPI is the resolved embedding protocol on an embedding
|
||||
// request. Aliyun and Volcengine each serve their text and multimodal
|
||||
// embeddings on different paths under one base URL, so the hook has to
|
||||
// know which one the model speaks.
|
||||
EmbeddingAPI api.EmbeddingAPI
|
||||
Extra map[string]string
|
||||
}
|
||||
|
||||
// Definition is one model vendor / gateway / self-hosted runtime.
|
||||
type Definition struct {
|
||||
// ID is the stable identifier stored in models.parameters.provider.
|
||||
ID string
|
||||
// Name is the brand name; Names carries localized variants keyed by
|
||||
// locale ("zh-CN"). Description / Descriptions likewise.
|
||||
Name string
|
||||
Names map[string]string
|
||||
Description string
|
||||
Descriptions map[string]string
|
||||
Website string
|
||||
// Icon is the brand mark as SVG bytes (served inline to the UI).
|
||||
Icon []byte
|
||||
// API is the default chat protocol; a ModelSpec may override it.
|
||||
API api.API
|
||||
// RerankAPI is the rerank protocol. Register defaults it to the Cohere
|
||||
// shape for any vendor that serves rerank without naming another.
|
||||
RerankAPI api.RerankAPI
|
||||
// EmbeddingAPI is the embedding protocol. Register defaults it to the
|
||||
// OpenAI shape for any vendor that serves embeddings without naming
|
||||
// another.
|
||||
EmbeddingAPI api.EmbeddingAPI
|
||||
// TranscriptionAPI is the speech-to-text protocol. Register defaults it
|
||||
// to the OpenAI shape for any vendor that serves ASR.
|
||||
TranscriptionAPI api.TranscriptionAPI
|
||||
// DefaultBaseURLs by model type; GetDefaultURL falls back to chat.
|
||||
DefaultBaseURLs map[types.ModelType]string
|
||||
ModelTypes []types.ModelType
|
||||
RequiresAuth bool
|
||||
Auth AuthStyle
|
||||
// AuthByAPI overrides Auth for one protocol. A vendor that exposes a
|
||||
// second protocol on a sub-path may authenticate it differently: Gemini's
|
||||
// OpenAI-compatible facade documents Authorization: Bearer while the
|
||||
// native generateContent API takes x-goog-api-key. Protocols absent from
|
||||
// the map use Auth.
|
||||
AuthByAPI map[api.API]AuthStyle
|
||||
// URLPatterns are substrings of a base URL that identify this vendor
|
||||
// when the operator left provider empty (legacy rows).
|
||||
URLPatterns []string
|
||||
ExtraFields []ExtraField
|
||||
// CredentialLabels rename the primary credential input per model type.
|
||||
CredentialLabels []CredentialLabel
|
||||
// Compat holds vendor-level protocol defaults.
|
||||
Compat VendorCompat
|
||||
// ThinkingLevels is the vendor-level level map.
|
||||
ThinkingLevels api.ThinkingLevelMap
|
||||
// Order sorts the vendor list in the UI (lower first).
|
||||
Order int
|
||||
|
||||
// Endpoint, when set, computes the request URL instead of the protocol
|
||||
// default (BaseURL + protocol path). Returning "" falls back.
|
||||
Endpoint func(req EndpointRequest) (url string, query map[string]string)
|
||||
// PreferAPI, when set, may switch the protocol for a base URL / model
|
||||
// pair after URL inference ran (OpenAI uses Responses on its own host
|
||||
// and Chat Completions on relays). Returning "" keeps the current choice.
|
||||
PreferAPI func(baseURL string, spec models.ModelSpec) api.API
|
||||
// Signer, when set (AuthSigned), builds the request signer from the
|
||||
// stored credentials.
|
||||
Signer func(creds api.Credentials) api.AuthFunc
|
||||
// Validate checks a configuration before it is saved or used. Nil means
|
||||
// the default check (key required when RequiresAuth; model name required).
|
||||
Validate func(cfg *Config) error
|
||||
// Headers are static headers sent on every request (vendor betas).
|
||||
Headers map[string]string
|
||||
// DefaultAPIKey is a deployment-level key from config/models.json used
|
||||
// when the model row stores none.
|
||||
DefaultAPIKey string
|
||||
}
|
||||
|
||||
// Config is the operator-supplied configuration of one model row.
|
||||
type Config struct {
|
||||
Provider string
|
||||
BaseURL string
|
||||
APIKey string
|
||||
ModelName string
|
||||
ModelID string
|
||||
ModelType types.ModelType
|
||||
Extra map[string]string
|
||||
}
|
||||
|
||||
// GetDefaultURL returns the default base URL for a model type, falling back
|
||||
// to the chat URL.
|
||||
func (v *Definition) GetDefaultURL(modelType types.ModelType) string {
|
||||
if v == nil {
|
||||
return ""
|
||||
}
|
||||
if url, ok := v.DefaultBaseURLs[modelType]; ok {
|
||||
return url
|
||||
}
|
||||
if url, ok := v.DefaultBaseURLs[types.ModelTypeKnowledgeQA]; ok {
|
||||
return url
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// SupportsType reports whether the vendor lists the model type.
|
||||
func (v *Definition) SupportsType(modelType types.ModelType) bool {
|
||||
for _, t := range v.ModelTypes {
|
||||
if t == modelType {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// LocalizedName returns the name for a locale, falling back to Name.
|
||||
func (v *Definition) LocalizedName(locale string) string {
|
||||
if n, ok := v.Names[locale]; ok && n != "" {
|
||||
return n
|
||||
}
|
||||
return v.Name
|
||||
}
|
||||
|
||||
// LocalizedDescription returns the description for a locale.
|
||||
func (v *Definition) LocalizedDescription(locale string) string {
|
||||
if d, ok := v.Descriptions[locale]; ok && d != "" {
|
||||
return d
|
||||
}
|
||||
return v.Description
|
||||
}
|
||||
|
||||
// AuthStyleFor returns the auth style this vendor uses for one protocol,
|
||||
// falling back to the vendor-wide Auth.
|
||||
func (v *Definition) AuthStyleFor(protocol api.API) AuthStyle {
|
||||
if style, ok := v.AuthByAPI[protocol]; ok && style != "" {
|
||||
return style
|
||||
}
|
||||
return v.Auth
|
||||
}
|
||||
|
||||
// AuthFunc builds the request authenticator for the stored credentials. The
|
||||
// protocol matters because a vendor that serves a second protocol on a
|
||||
// sub-path may authenticate it differently (see Definition.AuthByAPI).
|
||||
func (v *Definition) AuthFunc(protocol api.API, creds api.Credentials) api.AuthFunc {
|
||||
switch v.AuthStyleFor(protocol) {
|
||||
case AuthAPIKeyHeader:
|
||||
return api.HeaderAuth("api-key", creds.APIKey)
|
||||
case AuthXAPIKey:
|
||||
return api.HeaderAuth("x-api-key", creds.APIKey)
|
||||
case AuthGoogleAPIKey:
|
||||
return api.HeaderAuth("x-goog-api-key", creds.APIKey)
|
||||
case AuthNone:
|
||||
return api.NoAuth()
|
||||
case AuthSigned:
|
||||
if v.Signer != nil {
|
||||
return v.Signer(creds)
|
||||
}
|
||||
return api.NoAuth()
|
||||
default:
|
||||
return api.BearerAuth(creds.APIKey)
|
||||
}
|
||||
}
|
||||
|
||||
// ValidateConfig runs the vendor's validation.
|
||||
func (v *Definition) ValidateConfig(cfg *Config) error {
|
||||
if v.Validate != nil {
|
||||
return v.Validate(cfg)
|
||||
}
|
||||
return defaultValidate(v, cfg)
|
||||
}
|
||||
|
||||
// IconContentType is the media type of vendor icons served inline.
|
||||
const IconContentType = "image/svg+xml"
|
||||
|
||||
// GenericID is the catch-all OpenAI-compatible provider.
|
||||
const GenericID = "generic"
|
||||
|
||||
func defaultValidate(v *Definition, cfg *Config) error {
|
||||
if cfg == nil {
|
||||
return fmt.Errorf("config is nil")
|
||||
}
|
||||
if v.RequiresAuth && v.Auth != AuthSigned && strings.TrimSpace(cfg.APIKey) == "" {
|
||||
return fmt.Errorf("API key is required for %s", v.Name)
|
||||
}
|
||||
if v.ID == GenericID && strings.TrimSpace(cfg.BaseURL) == "" {
|
||||
return fmt.Errorf("base URL is required for generic provider")
|
||||
}
|
||||
if strings.TrimSpace(cfg.ModelName) == "" {
|
||||
return fmt.Errorf("model name is required")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
// Package providers registers Google's Gemini API.
|
||||
//
|
||||
// Facts (https://ai.google.dev/gemini-api/docs/thinking):
|
||||
// - the native protocol is generateContent under
|
||||
// https://generativelanguage.googleapis.com/v1beta with the
|
||||
// `x-goog-api-key` header;
|
||||
// - the two thinking knobs are generation-specific and mutually
|
||||
// exclusive: Gemini 3.x takes `thinkingConfig.thinkingLevel`, Gemini 2.5
|
||||
// takes `thinkingConfig.thinkingBudget` and ignores/rejects
|
||||
// thinkingLevel; sending both in one call is a 400. The per-model level
|
||||
// sets differ too — 3.8 Flash, 3.7 Flash and 3.1 Pro accept
|
||||
// low | medium | high, 3.6 Flash, 3.5 Flash, 3.5 Flash Lite, 3.1 Flash
|
||||
// Lite and 3 Flash Preview add minimal, and 3 Pro Preview accepts only
|
||||
// low | high, which is what the conservative gemini-3* family entry
|
||||
// assumes;
|
||||
// - no thinkingLevel value turns thinking off, so every Gemini 3 entry is
|
||||
// "off": null. On 2.5, Pro is the exception that cannot be switched off
|
||||
// (its budget must be 128..32768, or -1 for dynamic) while Flash and
|
||||
// Flash Lite accept budget 0; the vendor budget ladder starts at 128 for
|
||||
// that reason and tops out at 32768;
|
||||
// - pointing base_url at https://generativelanguage.googleapis.com/v1beta/openai
|
||||
// keeps the OpenAI-compatible Chat Completions protocol (Resolve detects
|
||||
// the /openai suffix) and switches the credential to
|
||||
// `Authorization: Bearer`, the only form that facade documents
|
||||
// (https://ai.google.dev/gemini-api/docs/openai). Every row created
|
||||
// before the native protocol became the default carries exactly that base
|
||||
// URL, so this is the auth those rows have always used; on that facade
|
||||
// `reasoning_effort` is translated to
|
||||
// thinking_level or thinking_budget per model,
|
||||
// `extra_body.google.thinking_config` carries include_thoughts, and usage
|
||||
// reports cached tokens (the OpenAICompletions vendor compat below);
|
||||
// - embeddings are served natively and on the facade:
|
||||
// gemini-embedding-001 defaults to 3072 dimensions over 2048 input
|
||||
// tokens, gemini-embedding-2 to 3072 over 8192 and accepts multimodal
|
||||
// input (https://ai.google.dev/gemini-api/docs/embeddings).
|
||||
//
|
||||
// Unverified:
|
||||
// - `extra_content` on tool calls is not named anywhere in the current
|
||||
// OpenAI-compat guide; the tool_call_extra_fields entry is kept because
|
||||
// dropping an opaque round-trip field is the riskier direction.
|
||||
// - gemini-embedding-2 is listed as `gemini-embedding-2` in the embeddings
|
||||
// guide but as `gemini-embedding-2-preview` on the models page and in the
|
||||
// OpenAI-compat samples, so both spellings resolve to one entry.
|
||||
// - gemini-3.1-flash-lite is on the models page but absent from the
|
||||
// thinking guide's level table, so its minimal rung is an assumption
|
||||
// carried over from the other Flash Lite tiers.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/gemini.svg
|
||||
var geminiIcon []byte
|
||||
|
||||
// GeminiID is the provider identifier stored on model rows.
|
||||
const GeminiID = "gemini"
|
||||
|
||||
// GeminiBaseURL is the native Gemini API endpoint.
|
||||
const GeminiBaseURL = "https://generativelanguage.googleapis.com/v1beta"
|
||||
|
||||
// GeminiOpenAICompatBaseURL keeps the OpenAI Chat Completions protocol.
|
||||
const GeminiOpenAICompatBaseURL = GeminiBaseURL + "/openai"
|
||||
|
||||
func newGeminiProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: GeminiID,
|
||||
Name: "Google Gemini",
|
||||
Names: map[string]string{"zh-CN": "Google Gemini"},
|
||||
Description: "gemini-3.8-flash, gemini-3.1-pro-preview, gemini-2.5-pro, gemini-embedding-2, etc. " +
|
||||
"Native generateContent by default; set base_url to " + GeminiOpenAICompatBaseURL +
|
||||
" to keep the OpenAI-compatible protocol.",
|
||||
Descriptions: map[string]string{
|
||||
"zh-CN": "gemini-3.8-flash, gemini-3.1-pro-preview, gemini-2.5-pro, gemini-embedding-2 等。" +
|
||||
"默认走原生 generateContent 协议;将 base_url 指向 " + GeminiOpenAICompatBaseURL + " 可继续使用 OpenAI 兼容协议。",
|
||||
},
|
||||
Website: "https://aistudio.google.com",
|
||||
Icon: geminiIcon,
|
||||
API: api.APIGoogleGenerativeAI,
|
||||
EmbeddingAPI: api.EmbeddingGoogle,
|
||||
Order: 33,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthGoogleAPIKey,
|
||||
// The OpenAI-compatible facade documents only Authorization: Bearer.
|
||||
// Sending x-goog-api-key there would change the credential of every
|
||||
// row stored before the native protocol became the default — they all
|
||||
// carry the .../v1beta/openai base URL.
|
||||
AuthByAPI: map[api.API]AuthStyle{
|
||||
api.APIOpenAICompletions: AuthBearer,
|
||||
},
|
||||
URLPatterns: []string{"generativelanguage.googleapis.com"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: GeminiBaseURL,
|
||||
types.ModelTypeEmbedding: GeminiBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
// https://ai.google.dev/api/embeddings: per request model, content
|
||||
// and embedContentConfig {taskType, title, outputDimensionality,
|
||||
// autoTruncate, …}; the same option names at the top level of the
|
||||
// request are marked deprecated. The pre-catalog client sent the
|
||||
// width top-level as output_dimensionality, which the proto JSON
|
||||
// parser reads as the same field. taskType exists on
|
||||
// gemini-embedding-001 only and is deliberately not declared: it
|
||||
// changes the document vectors, so turning it on would split every
|
||||
// existing index across two spaces (Tencent/WeKnora#1401).
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
DimensionsField: api.Ptr("outputDimensionality"),
|
||||
},
|
||||
// Used when the operator points base_url at the /openai facade.
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
ToolCallExtraFields: []string{"extra_content"},
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatOpenAI),
|
||||
SupportsReasoningEffort: api.Ptr(true),
|
||||
PromptCacheAccounting: api.Ptr(true),
|
||||
},
|
||||
// Native protocol keeps the generativelanguage defaults.
|
||||
GoogleGenerativeAI: api.GoogleGenerativeAICompat{},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
// Package providers registers the catch-all vendor for any OpenAI-compatible
|
||||
// endpoint (vLLM, SGLang, Xinference, Ollama's OpenAI facade, ...).
|
||||
//
|
||||
// Facts (no single upstream; the settings follow the vLLM / SGLang
|
||||
// conventions, https://docs.vllm.ai/en/latest/features/reasoning_outputs.html
|
||||
// and https://docs.sglang.io/basic_usage/openai_api_completions.html):
|
||||
// - output cap stays `max_tokens`. vLLM now marks it deprecated in favour
|
||||
// of `max_completion_tokens` but still accepts it, while SGLang,
|
||||
// GPUStack and Xinference document only `max_tokens`, so it remains the
|
||||
// one field every runtime behind this vendor understands;
|
||||
// - thinking is switched through `chat_template_kwargs.enable_thinking`,
|
||||
// which both servers document as the per-request override. vLLM also
|
||||
// accepts a top-level `reasoning_effort` with exactly this project's
|
||||
// ladder (none | minimal | low | medium | high | xhigh | max) and
|
||||
// injects enable_thinking from it, but SGLang only says effort "follows
|
||||
// a separate normalization path", so the chat-template switch is the
|
||||
// portable choice and operators on vLLM can opt into effort per model;
|
||||
// - the gpt-5*/o1*/o3*/o4* family entries stay: a relay parked behind this
|
||||
// vendor is the common way to front OpenAI, and those families need
|
||||
// max_completion_tokens, reasoning_effort and no sampling parameters
|
||||
// whatever the hop count;
|
||||
// - no default base URL: the operator must supply one (Validate enforces
|
||||
// it) and a key is optional because local deployments run without one;
|
||||
// - no URL patterns: DetectByURL falls back to this vendor when nothing
|
||||
// else matches.
|
||||
//
|
||||
// Unverified: `enable_thinking` is not a portable key. vLLM documents
|
||||
// `{"thinking": true}` for IBM Granite and SGLang documents the same for
|
||||
// DeepSeek-V3, so a non-Qwen template will ignore the switch this vendor
|
||||
// sends rather than reject it. Per-model chat-template keys are not
|
||||
// expressible in the compat model.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"academy/internal/models"
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/generic.svg
|
||||
var genericIcon []byte
|
||||
|
||||
func newGenericProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: GenericID,
|
||||
Name: "Custom (OpenAI-compatible)",
|
||||
Names: map[string]string{"zh-CN": "自定义 (OpenAI兼容接口)"},
|
||||
Description: "Any OpenAI-compatible endpoint (vLLM, SGLang, Xinference, Ollama, ...)",
|
||||
Descriptions: map[string]string{"zh-CN": "任意 OpenAI 兼容接口(vLLM、SGLang、Xinference、Ollama 等)"},
|
||||
Icon: genericIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 0,
|
||||
RequiresAuth: false,
|
||||
Auth: AuthBearer,
|
||||
DefaultBaseURLs: map[types.ModelType]string{},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeRerank,
|
||||
types.ModelTypeVLLM,
|
||||
types.ModelTypeASR,
|
||||
},
|
||||
ExtraFields: []ExtraField{{
|
||||
Key: models.ExtraScoreScale,
|
||||
Label: "Rerank score scale",
|
||||
Labels: map[string]string{"zh-CN": "Rerank 分数标度"},
|
||||
Type: "select",
|
||||
Options: []ExtraFieldOption{
|
||||
{
|
||||
Label: "Unbounded score (Qwen3-Reranker class)",
|
||||
Labels: map[string]string{"zh-CN": "无界分数(Qwen3-Reranker 一类)"},
|
||||
Value: "logit",
|
||||
},
|
||||
{
|
||||
Label: "0..1 relevance (BGE class)",
|
||||
Labels: map[string]string{"zh-CN": "0~1 相关度(BGE 一类)"},
|
||||
Value: "probability",
|
||||
},
|
||||
},
|
||||
Placeholder: "match the reranker actually deployed behind this endpoint",
|
||||
Placeholders: map[string]string{"zh-CN": "按这个端点后面实际部署的重排模型选择"},
|
||||
// A gateway serves whatever reranker was deployed behind it, and
|
||||
// the two families disagree. The vendor default follows the
|
||||
// documentation; the operator knows which model is actually there.
|
||||
Required: false,
|
||||
ModelTypes: []types.ModelType{types.ModelTypeRerank},
|
||||
}, {
|
||||
Key: models.ExtraTruncatePromptTokens,
|
||||
Label: "Rerank prompt truncation (vLLM)",
|
||||
Labels: map[string]string{"zh-CN": "Rerank 提示词截断长度(vLLM)"},
|
||||
Type: "number",
|
||||
// Off unless the operator asks: a runtime that does not implement
|
||||
// the extension rejects the unknown field.
|
||||
Required: false,
|
||||
Placeholder: "empty unless the backend rejects long documents",
|
||||
Placeholders: map[string]string{"zh-CN": "留空,除非后端因文档过长而报错"},
|
||||
ModelTypes: []types.ModelType{types.ModelTypeRerank},
|
||||
}},
|
||||
Compat: VendorCompat{
|
||||
// Transcriptions keeps the baseline, json by default. The
|
||||
// pre-catalog client always asked for verbose_json, which not every
|
||||
// model or server can produce: OpenAI's gpt-4o transcribers accept
|
||||
// only json, and vox-box's FunASR backend answers verbose_json with
|
||||
// a bare JSON string. A row that wants segments sets
|
||||
// {"response_format": "verbose_json"} in its compat. The language
|
||||
// hint goes as OpenAI's language form field, which a server that
|
||||
// does not implement it ignores.
|
||||
Transcriptions: api.TranscriptionsCompat{
|
||||
LanguageParam: api.Ptr(api.LanguageForm),
|
||||
},
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
// Whatever the operator runs. Everything the pre-catalog client
|
||||
// sent stays: vLLM, SGLang, TEI and Ollama's OpenAI route all
|
||||
// accept it, and dimensions still goes out only when the row
|
||||
// asks for a width.
|
||||
SendEncodingFormat: api.Ptr(true),
|
||||
DimensionsField: api.Ptr("dimensions"),
|
||||
AcceptsTruncatePromptTokens: api.Ptr(true),
|
||||
// Used only when the row declares image input. vLLM, the most
|
||||
// common server behind this vendor, takes images only as a
|
||||
// chat conversation in `messages`; an SGLang row switches to
|
||||
// {"image_format": "object", "image_field": "image"}.
|
||||
ImageFormat: api.Ptr(api.EmbeddingImageMessages),
|
||||
},
|
||||
Rerank: api.RerankCompat{
|
||||
// Any OpenAI-compatible endpoint an operator points here is most
|
||||
// often a vLLM or SGLang server, which is where
|
||||
// truncate_prompt_tokens comes from.
|
||||
AcceptsTruncatePromptTokens: api.Ptr(true),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
MaxTokensField: api.Ptr("max_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatChatTemplateKwargs),
|
||||
},
|
||||
},
|
||||
Validate: func(cfg *Config) error {
|
||||
if cfg == nil {
|
||||
return fmt.Errorf("config is nil")
|
||||
}
|
||||
if strings.TrimSpace(cfg.BaseURL) == "" {
|
||||
return fmt.Errorf("base URL is required for generic provider")
|
||||
}
|
||||
if strings.TrimSpace(cfg.ModelName) == "" {
|
||||
return fmt.Errorf("model name is required")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
// Package providers registers a self-hosted GPUStack cluster
|
||||
// (https://github.com/gpustack/gpustack).
|
||||
//
|
||||
// Facts (https://docs.gpustack.ai/latest/integrations/inference-apis/):
|
||||
// - the OpenAI-compatible surface is mounted at /v1: "GPUStack serves
|
||||
// OpenAI-compatible APIs using the `/v1` path." The 0.x/1.x line served
|
||||
// them at /v1-openai and documented /v1 as an alias for everything but
|
||||
// the models endpoint, so /v1 is the one path that works on both lines;
|
||||
// the 2.x page no longer mentions /v1-openai at all. Rerank is served at
|
||||
// /v1/rerank as well — "the OpenAI-compatible APIs does not provide a
|
||||
// `rerank` API, so GPUStack serves Jina compatible Rerank API using the
|
||||
// `/v1/rerank` path" — so chat, embeddings, transcriptions and rerank now
|
||||
// share one base URL;
|
||||
// - authentication is `Authorization: Bearer <api key>`;
|
||||
// - output cap is `max_tokens`: every GPUStack example uses it and
|
||||
// `max_completion_tokens` is never mentioned, so acceptance of the newer
|
||||
// field is the backend's business, not the gateway's;
|
||||
// - built-in backends are vLLM, SGLang, Ascend MindIE and VoxBox (llama-box
|
||||
// was dropped from the 2.x built-in list), so thinking is switched with
|
||||
// `chat_template_kwargs.enable_thinking`;
|
||||
// - the default base URL is a placeholder the operator must replace
|
||||
// (Validate requires it); the hostname contains "gpustack" so
|
||||
// DetectByURL recognises catalog rows;
|
||||
// - the catalog ships no models: deployments name their own.
|
||||
//
|
||||
// Unverified: whether GPUStack 2.x still answers on the old /v1-openai path.
|
||||
// The 2.x docs neither document it nor announce its removal, which is why
|
||||
// the default moved to /v1 rather than keeping a path only one line
|
||||
// documents.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"academy/internal/models"
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/gpustack.svg
|
||||
var gpustackIcon []byte
|
||||
|
||||
// GpustackID is the provider identifier stored on model rows.
|
||||
const GpustackID = "gpustack"
|
||||
|
||||
// GpustackBaseURL is the OpenAI-compatible placeholder. Since GPUStack 2.x every
|
||||
// surface — chat, embeddings, transcriptions and the Jina-style rerank —
|
||||
// hangs off /v1.
|
||||
const GpustackBaseURL = "http://your_gpustack_server_url/v1"
|
||||
|
||||
func newGpustackProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: GpustackID,
|
||||
Name: "GPUStack",
|
||||
Names: map[string]string{"zh-CN": "GPUStack"},
|
||||
Description: "Choose your deployed model on GPUStack",
|
||||
Descriptions: map[string]string{"zh-CN": "选择你在 GPUStack 上部署的模型"},
|
||||
Website: "https://gpustack.ai",
|
||||
Icon: gpustackIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 60,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"gpustack"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: GpustackBaseURL,
|
||||
types.ModelTypeEmbedding: GpustackBaseURL,
|
||||
types.ModelTypeRerank: GpustackBaseURL,
|
||||
types.ModelTypeVLLM: GpustackBaseURL,
|
||||
types.ModelTypeASR: GpustackBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeRerank,
|
||||
types.ModelTypeVLLM,
|
||||
types.ModelTypeASR,
|
||||
},
|
||||
ExtraFields: []ExtraField{{
|
||||
Key: models.ExtraScoreScale,
|
||||
Label: "Rerank score scale",
|
||||
Labels: map[string]string{"zh-CN": "Rerank 分数标度"},
|
||||
Type: "select",
|
||||
Options: []ExtraFieldOption{
|
||||
{
|
||||
Label: "Unbounded score (Qwen3-Reranker class)",
|
||||
Labels: map[string]string{"zh-CN": "无界分数(Qwen3-Reranker 一类)"},
|
||||
Value: "logit",
|
||||
},
|
||||
{
|
||||
Label: "0..1 relevance (BGE class)",
|
||||
Labels: map[string]string{"zh-CN": "0~1 相关度(BGE 一类)"},
|
||||
Value: "probability",
|
||||
},
|
||||
},
|
||||
Placeholder: "match the reranker actually deployed behind this endpoint",
|
||||
Placeholders: map[string]string{"zh-CN": "按这个端点后面实际部署的重排模型选择"},
|
||||
// A gateway serves whatever reranker was deployed behind it, and
|
||||
// the two families disagree. The vendor default follows the
|
||||
// documentation; the operator knows which model is actually there.
|
||||
Required: false,
|
||||
ModelTypes: []types.ModelType{types.ModelTypeRerank},
|
||||
}, {
|
||||
Key: models.ExtraTruncatePromptTokens,
|
||||
Label: "Rerank prompt truncation (vLLM)",
|
||||
Labels: map[string]string{"zh-CN": "Rerank 提示词截断长度(vLLM)"},
|
||||
Type: "number",
|
||||
// Off unless the operator asks: a runtime that does not implement
|
||||
// the extension rejects the unknown field.
|
||||
Required: false,
|
||||
Placeholder: "empty unless the backend rejects long documents",
|
||||
Placeholders: map[string]string{"zh-CN": "留空,除非后端因文档过长而报错"},
|
||||
ModelTypes: []types.ModelType{types.ModelTypeRerank},
|
||||
}},
|
||||
Compat: VendorCompat{
|
||||
// Transcriptions keeps the baseline, json by default. GPUStack
|
||||
// serves audio through vox-box (https://github.com/gpustack/vox-box),
|
||||
// whose route wraps a json answer as {"text": ...} but returns
|
||||
// verbose_json as whatever the backend produced — and its FunASR
|
||||
// backend (SenseVoice, Paraformer) produces a bare string for every
|
||||
// format. The pre-catalog client's verbose_json therefore arrived
|
||||
// as a JSON string that could not be decoded. The route reads a
|
||||
// language form field.
|
||||
Transcriptions: api.TranscriptionsCompat{
|
||||
LanguageParam: api.Ptr(api.LanguageForm),
|
||||
},
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
// vLLM's embedding server: dimensions for Matryoshka models, the
|
||||
// row's truncation budget, and encoding_format.
|
||||
SendEncodingFormat: api.Ptr(true),
|
||||
DimensionsField: api.Ptr("dimensions"),
|
||||
AcceptsTruncatePromptTokens: api.Ptr(true),
|
||||
},
|
||||
Rerank: api.RerankCompat{
|
||||
// GPUStack's built-in backends are vLLM, SGLang, Ascend MindIE and
|
||||
// VoxBox, so the vLLM rerank extension reaches the model.
|
||||
AcceptsTruncatePromptTokens: api.Ptr(true),
|
||||
// The field is spelled relevance_score like the Cohere shape, but
|
||||
// it is not a probability: the rerank API page's own example
|
||||
// returns 1.951932668685913, -3.7347371578216553 and
|
||||
// -6.157620906829834. Read as a probability, every negative score
|
||||
// falls below a relevance threshold tuned for 0..1.
|
||||
// https://docs.gpustack.ai/2.0/user-guide/rerank-api/
|
||||
ScoreScale: api.Ptr(api.ScoreLogit),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
MaxTokensField: api.Ptr("max_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatChatTemplateKwargs),
|
||||
},
|
||||
},
|
||||
Validate: func(cfg *Config) error {
|
||||
if cfg == nil {
|
||||
return fmt.Errorf("config is nil")
|
||||
}
|
||||
if strings.TrimSpace(cfg.BaseURL) == "" {
|
||||
return fmt.Errorf("base URL is required for GPUStack provider")
|
||||
}
|
||||
if strings.TrimSpace(cfg.APIKey) == "" {
|
||||
return fmt.Errorf("API key is required for GPUStack provider")
|
||||
}
|
||||
if strings.TrimSpace(cfg.ModelName) == "" {
|
||||
return fmt.Errorf("model name is required")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// Package providers includes Hugging Face Text Embeddings Inference, which
|
||||
// serves a model chosen at startup.
|
||||
// Its native rerank route is POST /rerank with query/texts and a bare array
|
||||
// response; it does not accept a model field or use the OpenAI /v1 prefix.
|
||||
// https://huggingface.co/docs/text-embeddings-inference/quick_tour#re-rankers
|
||||
// https://github.com/huggingface/text-embeddings-inference/blob/main/docs/openapi.json
|
||||
package providers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// HuggingFaceTEIID is the provider ID for self-hosted TEI rerank models.
|
||||
const HuggingFaceTEIID = "huggingface_tei"
|
||||
|
||||
func newHuggingFaceTEIProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: HuggingFaceTEIID,
|
||||
Name: "Hugging Face TEI",
|
||||
Names: map[string]string{"zh-CN": "Hugging Face TEI"},
|
||||
Description: "Self-hosted reranker served by Text Embeddings Inference",
|
||||
Descriptions: map[string]string{"zh-CN": "通过 Text Embeddings Inference 自部署的重排模型"},
|
||||
Website: "https://huggingface.co/docs/text-embeddings-inference",
|
||||
Icon: genericIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
RerankAPI: api.RerankTEI,
|
||||
Order: 61,
|
||||
RequiresAuth: false,
|
||||
Auth: AuthBearer, // Only TEI servers started with --api-key need this.
|
||||
ModelTypes: []types.ModelType{types.ModelTypeRerank},
|
||||
Compat: VendorCompat{Rerank: api.RerankCompat{
|
||||
// TEI rejects requests above --max-client-batch-size, which
|
||||
// defaults to 32.
|
||||
MaxDocuments: api.Ptr(32),
|
||||
}},
|
||||
Validate: func(cfg *Config) error {
|
||||
if cfg == nil {
|
||||
return fmt.Errorf("config is nil")
|
||||
}
|
||||
if strings.TrimSpace(cfg.BaseURL) == "" {
|
||||
return fmt.Errorf("base URL is required for Hugging Face TEI provider")
|
||||
}
|
||||
if strings.TrimSpace(cfg.ModelName) == "" {
|
||||
return fmt.Errorf("model name is required")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
// Package providers registers Tencent Hunyuan through its OpenAI-compatible
|
||||
// endpoint.
|
||||
//
|
||||
// Facts (https://cloud.tencent.com/document/product/1729/111007):
|
||||
// - https://api.hunyuan.cloud.tencent.com/v1 serves both chat
|
||||
// (/chat/completions) and embeddings (/embeddings); the only credential
|
||||
// is a console API key sent as Authorization: Bearer, so this vendor
|
||||
// needs no ExtraFields (the TC3-signed native API is a different host);
|
||||
// - the output cap is `max_tokens` (default 4096); the reference does not
|
||||
// document `max_completion_tokens`;
|
||||
// - `tool_choice` 可选值包括 none、auto、custom and "仅对 hunyuan-turbos、
|
||||
// hunyuan-functioncall 模型生效", so `required` is never sent; "custom" is
|
||||
// a Hunyuan-specific shape rather than OpenAI's named-function object,
|
||||
// so the "function" mode is withheld as well;
|
||||
// - temperature is [0.0, 2.0] and top_p [0.0, 1.0], neither restricted;
|
||||
// - stream_options.include_usage is supported;
|
||||
// - hunyuan-embedding returns a fixed 1024-dimension vector.
|
||||
//
|
||||
// Thinking (https://cloud.tencent.com/document/product/1729/105701): the
|
||||
// native API exposes `EnableThinking`, "未传值时默认开启" and the switch
|
||||
// "仅对 hunyuan-a13b 模型生效". The T1 series reasons unconditionally, so
|
||||
// models.json marks it "off": null, and hunyuan-a13b additionally accepts a
|
||||
// `/no_think` prompt prefix
|
||||
// (https://cloud.tencent.com/document/product/1729/104753).
|
||||
//
|
||||
// Second protocol: an Anthropic Messages facade at
|
||||
// https://api.hunyuan.cloud.tencent.com/anthropic (path
|
||||
// /anthropic/v1/messages) documents hunyuan-2.0-thinking-20251109 and
|
||||
// hunyuan-2.0-instruct-20251111 with thinking {type, budget_tokens}
|
||||
// (https://cloud.tencent.com/document/product/1729/127293). The
|
||||
// OpenAI-compatible surface stays this vendor's default.
|
||||
//
|
||||
// unverified: the OpenAI-compatible reference documents no thinking field at
|
||||
// all, so the snake_case `enable_thinking` spelling used here is carried over
|
||||
// from the native API and is unconfirmed for this endpoint;
|
||||
// unverified: response_format, parallel_tool_calls and prompt-cache
|
||||
// accounting are absent from the compatible-interface reference, so the
|
||||
// protocol defaults (supported, no cache counters) stand untested;
|
||||
// unverified: Tencent's model list (1729/104753) and pricing page
|
||||
// (1729/97731) document limits for hunyuan-a13b (224k in / 32k out) and the
|
||||
// vision models only. hunyuan-t1-latest, hunyuan-turbos-latest, hunyuan-lite
|
||||
// and hunyuan-turbos-vision appear in neither table (new models are
|
||||
// migrating to TokenHub), so their context windows, output caps and prices
|
||||
// are carried over unconfirmed; no retirement notice was found either, so
|
||||
// the entries stay. hunyuan-t1-latest used to claim a 64K output cap above
|
||||
// its own 32K context window; since no doc supports either number, the cap
|
||||
// was dropped rather than corrected, leaving the context window as the only
|
||||
// (still unconfirmed) limit. Treat it as a placeholder that the per-model
|
||||
// field in the UI overrides, and do not raise it without a documented
|
||||
// source: an overstated context window stops history compaction from firing
|
||||
// and the upstream rejects the request instead;
|
||||
// unverified: the hunyuan-2.0-* ids are documented only on the Anthropic
|
||||
// facade, so their availability on this OpenAI-compatible host, their
|
||||
// context windows and their output caps are unconfirmed.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/hunyuan.svg
|
||||
var hunyuanIcon []byte
|
||||
|
||||
// HunyuanID is the provider identifier stored on model rows.
|
||||
const HunyuanID = "hunyuan"
|
||||
|
||||
// HunyuanBaseURL is the OpenAI-compatible endpoint (chat and embedding).
|
||||
const HunyuanBaseURL = "https://api.hunyuan.cloud.tencent.com/v1"
|
||||
|
||||
func newHunyuanProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: HunyuanID,
|
||||
Name: "Tencent Hunyuan",
|
||||
Names: map[string]string{"zh-CN": "腾讯混元 Hunyuan"},
|
||||
Description: "hunyuan-t1-latest, hunyuan-turbos-latest, hunyuan-a13b, hunyuan-embedding, etc.",
|
||||
Website: "https://cloud.tencent.com/product/hunyuan",
|
||||
Icon: hunyuanIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 13,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"hunyuan.cloud.tencent.com"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: HunyuanBaseURL,
|
||||
types.ModelTypeEmbedding: HunyuanBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
// Embeddings keeps the bare baseline on purpose: "Embedding 接口目前仅
|
||||
// 支持 input 和 model 参数 … dimensions 固定为 1024"
|
||||
// (https://cloud.tencent.com/document/product/1729/111007).
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
MaxTokensField: api.Ptr("max_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatEnableThinking),
|
||||
// 可选值包括 none、auto、custom: neither "required" nor OpenAI's
|
||||
// named-function object is documented.
|
||||
ToolChoiceModes: []string{"none", "auto"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
// Package providers registers Jina AI's embedding and rerank APIs.
|
||||
//
|
||||
// Facts (https://jina.ai/embeddings and https://jina.ai/reranker):
|
||||
// - both endpoints live under https://api.jina.ai/v1 and authenticate with
|
||||
// `Authorization: Bearer`;
|
||||
// - /v1/embeddings matches the input and output JSON schema of OpenAI's
|
||||
// text-embedding-3-large (it is a superset: `task`, `normalized`,
|
||||
// `embedding_type` and `dimensions` are Jina-only additions);
|
||||
// /v1/rerank takes the Cohere-style {model, query, documents, top_n}
|
||||
// body;
|
||||
// - the v5 generation is a family of four rather than one id:
|
||||
// omni (multimodal) and text, each in small (1024 dims, 32K tokens) and
|
||||
// nano (768 dims, 8K tokens). jina-embeddings-v4 still defaults to 2048
|
||||
// dimensions over 32K tokens and v3 to 1024 over 8K; v4 supports
|
||||
// Matryoshka truncation down to 128 through `dimensions`;
|
||||
// - jina-reranker-v3.5 and v3 take 131K tokens and are the current
|
||||
// recommendations; m0 (10K) and v2-base-multilingual (1K) remain listed;
|
||||
// - there is no chat model, so ModelTypes lists embedding and rerank only.
|
||||
//
|
||||
// Unverified: api.jina.ai does not serve a fetchable OpenAPI document, so
|
||||
// the OpenAI-schema compatibility claim rests on the wording of the
|
||||
// embeddings FAQ rather than a spec.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/jina.svg
|
||||
var jinaIcon []byte
|
||||
|
||||
// JinaID is the provider identifier stored on model rows.
|
||||
const JinaID = "jina"
|
||||
|
||||
// JinaBaseURL serves embeddings and rerank.
|
||||
const JinaBaseURL = "https://api.jina.ai/v1"
|
||||
|
||||
func newJinaProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: JinaID,
|
||||
Name: "Jina AI",
|
||||
Names: map[string]string{"zh-CN": "Jina"},
|
||||
Description: "jina-embeddings-v5-text-small, jina-embeddings-v4, jina-reranker-v3.5, jina-reranker-m0, etc.",
|
||||
Website: "https://jina.ai",
|
||||
Icon: jinaIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 50,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"api.jina.ai"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeEmbedding: JinaBaseURL,
|
||||
types.ModelTypeRerank: JinaBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeRerank,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
// https://jina.ai/embeddings/: model, input, an optional task,
|
||||
// dimensions, embedding_type, normalized, late_chunking and a
|
||||
// boolean truncate that defaults to false (an over-long input is
|
||||
// an error). truncate: true is what this vendor has always been
|
||||
// sent. task is deliberately not declared: the adapter it selects
|
||||
// changes the document vectors, so turning it on would leave every
|
||||
// existing index half in one space and half in another
|
||||
// (Tencent/WeKnora#1401).
|
||||
DimensionsField: api.Ptr("dimensions"),
|
||||
TruncateField: api.Ptr("truncate"),
|
||||
TruncateValue: api.Ptr("true"),
|
||||
// The multimodal models take {"image": URL or data URI} in
|
||||
// input; "Maximum file sizes are 5 MB for images". The page
|
||||
// gives no image count per request, so each image goes alone.
|
||||
ImageField: api.Ptr("image"),
|
||||
MaxImageBytes: api.Ptr(5_000_000),
|
||||
},
|
||||
Rerank: api.RerankCompat{
|
||||
// return_documents echoes the text back. Results are matched
|
||||
// by index, so this is not needed to map them; it is kept
|
||||
// because it is what this vendor has always been sent.
|
||||
SendReturnDocs: api.Ptr(true),
|
||||
// jina-reranker-m0 takes {"image": URL or base64} documents
|
||||
// (https://jina.ai/news/jina-reranker-m0-multilingual-multimodal-document-reranker/).
|
||||
// Unverified: no rerank example shows the base64 form, so the
|
||||
// data URI the embeddings reference documents is sent. The
|
||||
// page states no image count per request; each goes alone.
|
||||
ImageField: api.Ptr("image"),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
// Package providers registers a self-hosted LiteLLM proxy
|
||||
// (https://github.com/BerriAI/litellm).
|
||||
//
|
||||
// Facts (https://docs.litellm.ai/docs/reasoning_content):
|
||||
// - the proxy speaks plain OpenAI Chat Completions and translates
|
||||
// `reasoning_effort` for every upstream it fronts, so the OpenAI
|
||||
// thinking format is used and graded effort is supported. The documented
|
||||
// vocabulary is minimal | low | medium | high | xhigh | max (mapped onto
|
||||
// Anthropic budgets of 1024/1024/2048/4096/8192/16384), plus `none` to
|
||||
// turn thinking off — which is why the vendor level map spells "off" as
|
||||
// "none" and keeps xhigh and max enabled;
|
||||
// - both `max_tokens` and `max_completion_tokens` are listed as supported
|
||||
// input params (https://docs.litellm.ai/docs/completion/input) with no
|
||||
// stated preference, so the protocol default max_completion_tokens
|
||||
// stands;
|
||||
// - the default base URL is a placeholder the operator must replace; its
|
||||
// hostname contains "litellm" so DetectByURL recognises catalog rows,
|
||||
// while loopback URLs stay generic (they are SSRF-blocked unless
|
||||
// whitelisted). The proxy's own default is port 4000, and both
|
||||
// /v1/chat/completions and /chat/completions are documented;
|
||||
// - the catalog ships no models: deployments name their own routes.
|
||||
//
|
||||
// Unverified: `chat_template_kwargs` is not named in the LiteLLM docs. It
|
||||
// should reach a vLLM/SGLang upstream under the general rule that "LiteLLM
|
||||
// treats any non-openai param as a provider-specific param, and passes it to
|
||||
// the provider in the request body", but a proxy configured with
|
||||
// allowed_openai_params may drop it, so operators fronting open-weight
|
||||
// models may need thinking_control=chat_template_kwargs plus that allowlist.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models"
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/litellm.svg
|
||||
var litellmIcon []byte
|
||||
|
||||
// LitellmID is the provider identifier stored on model rows.
|
||||
const LitellmID = "litellm"
|
||||
|
||||
// LitellmBaseURL is a placeholder the operator replaces with a reachable proxy.
|
||||
const LitellmBaseURL = "http://your_litellm_proxy/v1"
|
||||
|
||||
// LitellmRerankBaseURL is the proxy root. LiteLLM documents rerank at /rerank
|
||||
// rather than /v1/rerank, so it does not hang off the chat base URL.
|
||||
const LitellmRerankBaseURL = "http://your_litellm_proxy"
|
||||
|
||||
func newLitellmProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: LitellmID,
|
||||
Name: "LiteLLM",
|
||||
Names: map[string]string{"zh-CN": "LiteLLM"},
|
||||
Description: "Self-hosted LiteLLM proxy: one OpenAI-compatible endpoint to 100+ ",
|
||||
Descriptions: map[string]string{"zh-CN": "自建 LiteLLM 代理:一个 OpenAI 兼容入口对接 100+ 模型服务。"},
|
||||
Website: "https://docs.litellm.ai",
|
||||
Icon: litellmIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 41,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"litellm"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: LitellmBaseURL,
|
||||
types.ModelTypeEmbedding: LitellmBaseURL,
|
||||
types.ModelTypeRerank: LitellmRerankBaseURL,
|
||||
types.ModelTypeVLLM: LitellmBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeRerank,
|
||||
types.ModelTypeVLLM,
|
||||
types.ModelTypeASR,
|
||||
},
|
||||
ExtraFields: []ExtraField{{
|
||||
Key: models.ExtraScoreScale,
|
||||
Label: "Rerank score scale",
|
||||
Labels: map[string]string{"zh-CN": "Rerank 分数标度"},
|
||||
Type: "select",
|
||||
Options: []ExtraFieldOption{
|
||||
{
|
||||
Label: "Unbounded score (Qwen3-Reranker class)",
|
||||
Labels: map[string]string{"zh-CN": "无界分数(Qwen3-Reranker 一类)"},
|
||||
Value: "logit",
|
||||
},
|
||||
{
|
||||
Label: "0..1 relevance (BGE class)",
|
||||
Labels: map[string]string{"zh-CN": "0~1 相关度(BGE 一类)"},
|
||||
Value: "probability",
|
||||
},
|
||||
},
|
||||
Placeholder: "match the reranker actually deployed behind this endpoint",
|
||||
Placeholders: map[string]string{"zh-CN": "按这个端点后面实际部署的重排模型选择"},
|
||||
// A gateway serves whatever reranker was deployed behind it, and
|
||||
// the two families disagree. The vendor default follows the
|
||||
// documentation; the operator knows which model is actually there.
|
||||
Required: false,
|
||||
ModelTypes: []types.ModelType{types.ModelTypeRerank},
|
||||
}},
|
||||
Compat: VendorCompat{
|
||||
// Transcriptions keeps the baseline: the proxy serves the OpenAI
|
||||
// /audio/transcriptions route for whichever upstream it is
|
||||
// configured with (https://docs.litellm.ai/docs/audio_transcription).
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
// https://docs.litellm.ai/docs/embedding/supported_embedding:
|
||||
// model, input, user, dimensions, encoding_format; anything else
|
||||
// is forwarded to the upstream as a provider-specific kwarg.
|
||||
SendEncodingFormat: api.Ptr(true),
|
||||
DimensionsField: api.Ptr("dimensions"),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatOpenAI),
|
||||
SupportsReasoningEffort: api.Ptr(true),
|
||||
},
|
||||
},
|
||||
// LiteLLM documents the whole ladder plus "none" as the off switch.
|
||||
ThinkingLevels: api.ThinkingLevelMap{
|
||||
api.ReasoningOff: api.StringPtr("none"),
|
||||
api.ReasoningXHigh: api.StringPtr("xhigh"),
|
||||
api.ReasoningMax: api.StringPtr("max"),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
// Package providers registers Tencent Cloud LKEAP (Knowledge Engine Atomic
|
||||
// Power) through its OpenAI-compatible endpoint.
|
||||
//
|
||||
// Chat facts (https://cloud.tencent.com/document/product/1772/115969 and
|
||||
// the model list at https://cloud.tencent.com/document/product/1772/115963):
|
||||
// - the documented endpoint is
|
||||
// https://api.lkeap.cloud.tencent.com/v1/chat/completions, so the base
|
||||
// URL already carries the /v1 segment;
|
||||
// - authentication is a plain `Authorization: Bearer sk-...` console key,
|
||||
// unrelated to the Tencent Cloud SecretId / SecretKey pair;
|
||||
// - output cap is `max_tokens`; temperature (default 0.6, range [0, 2]) and
|
||||
// top_p (default 0.6, range (0, 1]) are both accepted, as are stop,
|
||||
// presence_penalty, frequency_penalty, Function Calling and
|
||||
// response_format json_object (json_schema on V3.1+);
|
||||
// - thinking is switched with `thinking: {"type": "enabled"|"disabled"}`,
|
||||
// documented as taking effect only on deepseek-v3.1-terminus and
|
||||
// deepseek-v3.2; DeepSeek R1 reasons unconditionally, so the R1 entries
|
||||
// carry "off": null and never receive a disable switch;
|
||||
// - `reasoning_effort` is not part of the LKEAP surface, so effort grading
|
||||
// stays off and only the thinking switch is sent.
|
||||
//
|
||||
// Rerank facts (https://cloud.tencent.com/document/product/1772/115339):
|
||||
// - it is not the OpenAI-compatible host but the Tencent Cloud API
|
||||
// lkeap.tencentcloudapi.com, action RunRerank, version 2024-05-22,
|
||||
// available in ap-beijing and ap-guangzhou only;
|
||||
// - it therefore needs the TC3-HMAC-SHA256 credential pair: the API key
|
||||
// field carries the SecretId and the rerank-only extra fields carry the
|
||||
// SecretKey and the region (default ap-guangzhou). The SecretKey is
|
||||
// genuinely required — TC3 signing cannot be done without it;
|
||||
// - the optional Model parameter defaults to lke-reranker-base, which is
|
||||
// documented as the only available rerank model.
|
||||
//
|
||||
// unverified: the current model list documents deepseek-v3-0324,
|
||||
// deepseek-r1-0528, deepseek-v3.1-terminus and deepseek-v3.2. The plain
|
||||
// deepseek-r1 / deepseek-v3 / deepseek-v3.1 ids kept in models.json are no
|
||||
// longer listed, but no LKEAP retirement notice covers them, so they stay
|
||||
// with their previously recorded limits.
|
||||
//
|
||||
// unverified: LKEAP documents neither tool_choice modes,
|
||||
// stream_options.include_usage nor any prompt-cache accounting, so the
|
||||
// protocol defaults are kept.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/lkeap.svg
|
||||
var lkeapIcon []byte
|
||||
|
||||
// LkeapID is the provider identifier stored on model rows.
|
||||
const LkeapID = "lkeap"
|
||||
|
||||
// LkeapBaseURL is the OpenAI-compatible chat endpoint.
|
||||
const LkeapBaseURL = "https://api.lkeap.cloud.tencent.com/v1"
|
||||
|
||||
// LkeapRerankBaseURL is the TC3-signed cloud API host used for rerank.
|
||||
const LkeapRerankBaseURL = "https://lkeap.tencentcloudapi.com"
|
||||
|
||||
func newLkeapProvider() *Definition {
|
||||
rerankOnly := []types.ModelType{types.ModelTypeRerank}
|
||||
return &Definition{
|
||||
ID: LkeapID,
|
||||
Name: "Tencent Cloud LKEAP",
|
||||
Names: map[string]string{"zh-CN": "腾讯云 LKEAP"},
|
||||
Description: "deepseek-v3.2, deepseek-v3.1-terminus, deepseek-r1-0528, lke-reranker-base",
|
||||
Descriptions: map[string]string{
|
||||
"zh-CN": "DeepSeek-V3.2、DeepSeek-V3.1-Terminus、DeepSeek-R1-0528、lke-reranker-base",
|
||||
},
|
||||
Website: "https://cloud.tencent.com/product/lkeap",
|
||||
Icon: lkeapIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 23,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"lkeap.cloud.tencent.com", "api.lkeap", "lkeap.tencentcloudapi.com"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: LkeapBaseURL,
|
||||
types.ModelTypeRerank: LkeapRerankBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeRerank,
|
||||
},
|
||||
// The rerank API authenticates with a TC3-signed CAM identity, so the
|
||||
// first credential is a SecretId, not a bearer token. Left as the
|
||||
// generic "API Key" an operator pastes an `sk-` key that can never
|
||||
// sign a request.
|
||||
CredentialLabels: []CredentialLabel{{
|
||||
Label: "SecretId",
|
||||
Labels: map[string]string{"zh-CN": "SecretId(TC3 签名)"},
|
||||
Placeholder: "Tencent Cloud SecretId (AKID...)",
|
||||
Placeholders: map[string]string{"zh-CN": "腾讯云 SecretId(AKID 开头)"},
|
||||
Hint: "Rerank is signed with a CAM key pair; this is not an sk- API key.",
|
||||
Hints: map[string]string{"zh-CN": "Rerank 使用 CAM 密钥对签名,不是 sk- 开头的 API Key。"},
|
||||
ModelTypes: rerankOnly,
|
||||
Required: true,
|
||||
}},
|
||||
ExtraFields: []ExtraField{
|
||||
{
|
||||
Key: "secret_key",
|
||||
Label: "Secret Key",
|
||||
Labels: map[string]string{"zh-CN": "SecretKey(TC3 签名)"},
|
||||
Type: "password",
|
||||
Required: true,
|
||||
Placeholder: "Tencent Cloud SecretKey (the API Key field holds the SecretId)",
|
||||
Placeholders: map[string]string{
|
||||
"zh-CN": "腾讯云 SecretKey(API Key 那一栏填的是 SecretId)",
|
||||
},
|
||||
ModelTypes: rerankOnly,
|
||||
Secret: true,
|
||||
},
|
||||
{
|
||||
// RunRerank is only published in ap-beijing and ap-guangzhou.
|
||||
Key: "region",
|
||||
Label: "Region",
|
||||
Labels: map[string]string{"zh-CN": "地域"},
|
||||
Type: "select",
|
||||
Default: "ap-guangzhou",
|
||||
Placeholder: "ap-guangzhou",
|
||||
Options: []ExtraFieldOption{
|
||||
{Label: "ap-guangzhou", Value: "ap-guangzhou"},
|
||||
{Label: "ap-beijing", Value: "ap-beijing"},
|
||||
},
|
||||
ModelTypes: rerankOnly,
|
||||
},
|
||||
},
|
||||
RerankAPI: api.RerankTencentLKEAP,
|
||||
Compat: VendorCompat{
|
||||
Rerank: api.RerankCompat{
|
||||
// RunRerank takes at most 60 documents, and Query plus Docs
|
||||
// together at most 2000 characters.
|
||||
MaxDocuments: api.Ptr(60),
|
||||
MaxRequestChars: api.Ptr(2000),
|
||||
// Batches went out one at a time before the shared batching
|
||||
// layer existed. A 2000-character budget splits a large
|
||||
// candidate set into many requests, so the default fan-out of
|
||||
// four would be a new burst against RunRerank.
|
||||
MaxConcurrency: api.Ptr(1),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
MaxTokensField: api.Ptr("max_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatThinkingType),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
// Package providers registers Meituan LongCat's OpenAI-compatible endpoint.
|
||||
//
|
||||
// Facts (chat reference https://longcat.chat/platform/docs/zh/api/chat.html,
|
||||
// overview https://longcat.chat/platform/docs/zh/APIDocs.html):
|
||||
// - the OpenAI facade is served at
|
||||
// POST https://api.longcat.chat/openai/v1/chat/completions, so the base
|
||||
// URL carries the /openai/v1 prefix;
|
||||
// - auth is `Authorization: Bearer <API Key>` and nothing else;
|
||||
// - output cap is `max_tokens`, which defaults to and tops out at the
|
||||
// model's 128K (131072) output budget; `max_completion_tokens` is not
|
||||
// part of the reference;
|
||||
// - thinking IS switchable, with `thinking: {"type": "enabled"}` or
|
||||
// `{"type": "disabled"}`, and it is enabled by default. No
|
||||
// `reasoning_effort` is documented, so the switch is sent without a
|
||||
// grade;
|
||||
// - the model replies with `reasoning_content` and reports
|
||||
// `completion_tokens_details.reasoning_tokens`, which the protocol
|
||||
// already reads by default;
|
||||
// - `messages` is text only (roles system / user / assistant), which is
|
||||
// why every entry lists the text modality alone;
|
||||
// - temperature is documented over 0..1 rather than the OpenAI 0..2, and
|
||||
// top_p is accepted. The protocol has no field for a narrower range,
|
||||
// so values are passed through unchanged;
|
||||
// - LongCat also serves an Anthropic Messages surface at
|
||||
// https://api.longcat.chat/anthropic/v1/messages
|
||||
// (https://longcat.chat/platform/docs/zh/api/messages.html) with the
|
||||
// same model and the same thinking shape. The documented default, and
|
||||
// what this package configures, is the OpenAI format.
|
||||
//
|
||||
// unverified: the changelog credits LongCat-2.0 with "native tool
|
||||
// calling", but neither API reference documents `tools`, `tool_choice`,
|
||||
// `parallel_tool_calls` or a `tool` message role, so the protocol
|
||||
// defaults (the full OpenAI tool_choice set) are kept untested.
|
||||
//
|
||||
// unverified: `response_format` and `stream_options.include_usage` do not
|
||||
// appear in the reference either; the protocol defaults are kept.
|
||||
//
|
||||
// unverified: nothing documents a mandatory thinking switch or a
|
||||
// non-stream restriction, so thinking_always_send and
|
||||
// thinking_disable_on_non_stream stay off.
|
||||
//
|
||||
// unverified: the published usage object carries no cache counters even
|
||||
// though the price list bills cached input, so prompt_cache_accounting
|
||||
// stays off; neither prompt_cache_key nor cache_control is documented.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/longcat.svg
|
||||
var longcatIcon []byte
|
||||
|
||||
// LongcatID is the provider identifier stored on model rows.
|
||||
const LongcatID = "longcat"
|
||||
|
||||
// LongcatBaseURL is the OpenAI-compatible chat endpoint.
|
||||
const LongcatBaseURL = "https://api.longcat.chat/openai/v1"
|
||||
|
||||
// LongcatAnthropicBaseURL is the Anthropic Messages surface of the same platform.
|
||||
const LongcatAnthropicBaseURL = "https://api.longcat.chat/anthropic/v1"
|
||||
|
||||
func newLongcatProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: LongcatID,
|
||||
Name: "LongCat AI",
|
||||
Names: map[string]string{"zh-CN": "美团 LongCat"},
|
||||
Description: "LongCat-2.0",
|
||||
Website: "https://longcat.chat/platform",
|
||||
Icon: longcatIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 22,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"longcat.chat"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: LongcatBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
MaxTokensField: api.Ptr("max_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatThinkingType),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// Package providers registers Xiaomi MiMo's OpenAI-compatible endpoint.
|
||||
//
|
||||
// Facts (https://mimo.mi.com/static/docs/api/chat/openai-api.md,
|
||||
// https://mimo.mi.com/static/docs/quick-start/summary/model.md,
|
||||
// https://mimo.mi.com/static/docs/api/guidance/model-hyperparameters.md):
|
||||
// - the OpenAI-compatible base URL is https://api.xiaomimimo.com/v1 and auth
|
||||
// is `Authorization: Bearer sk-...`; an Anthropic Messages endpoint lives
|
||||
// at https://api.xiaomimimo.com/anthropic and is not selected here;
|
||||
// - the output cap is `max_completion_tokens` (the protocol default);
|
||||
// `max_tokens` is not a documented parameter;
|
||||
// - thinking is switched with `thinking: {"type": "enabled"|"disabled"}`,
|
||||
// enabled by default on both chat models; there is no reasoning_effort and
|
||||
// no thinking budget;
|
||||
// - prior assistant turns must replay `reasoning_content` whenever the turn
|
||||
// carried tool_calls, otherwise the API answers 400 (the default);
|
||||
// - temperature ([0, 1.5], default 1.0) and top_p ([0.01, 1.0], default
|
||||
// 0.95) are accepted, but while thinking is on the service silently pins
|
||||
// them to 1.0 / 0.95 instead of erroring, so they stay enabled;
|
||||
// - `tool_choice` only offers `auto`: any other value is dropped server side
|
||||
// and the request behaves as auto;
|
||||
// - usage reports `prompt_tokens_details.cached_tokens` (cache writes are
|
||||
// free for now), so cache accounting is on;
|
||||
// - mimo-v2-flash — together with mimo-v2-pro, mimo-v2-omni and mimo-v2-tts —
|
||||
// was retired on 2026-06-30 and is kept only as a deprecated entry
|
||||
// (https://mimo.mi.com/static/docs/updates/deprecate.md).
|
||||
//
|
||||
// Unverified: `stream_options.include_usage` is absent from the documented
|
||||
// request schema, but the streaming chunks document a `usage` object, so the
|
||||
// protocol default (send it) is kept rather than guessed away;
|
||||
// parallel_tool_calls and seed are likewise absent from the documented schema
|
||||
// without being documented as rejected; mimo-v2.5-pro-ultraspeed is a closed
|
||||
// beta that neither the model list nor the price list carries, so its id,
|
||||
// limits and prices are unconfirmed; the ASR (mimo-v2.5-asr) and TTS models
|
||||
// are documented but not registered here, since this vendor only declares the
|
||||
// chat model type.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/mimo.svg
|
||||
var mimoIcon []byte
|
||||
|
||||
// MimoID is the provider identifier stored on model rows.
|
||||
const MimoID = "mimo"
|
||||
|
||||
// MimoBaseURL is the OpenAI-compatible chat endpoint.
|
||||
const MimoBaseURL = "https://api.xiaomimimo.com/v1"
|
||||
|
||||
func newMimoProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: MimoID,
|
||||
Name: "Xiaomi MiMo",
|
||||
Names: map[string]string{"zh-CN": "小米 MiMo"},
|
||||
Description: "mimo-v2.5-pro, mimo-v2.5",
|
||||
Website: "https://platform.xiaomimimo.com",
|
||||
Icon: mimoIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 18,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"xiaomimimo.com"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: MimoBaseURL,
|
||||
},
|
||||
TranscriptionAPI: api.TranscriptionChatAudio,
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeASR,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
// ASR: mimo-v2.5-asr on the chat endpoint, WAV or MP3 as a base64
|
||||
// data URI whose "encoded string size must not exceed 10 MB"
|
||||
// (https://mimo.mi.com/docs/en-US/quick-start/usage-guide/audio/Speech-Recognition).
|
||||
Transcriptions: api.TranscriptionsCompat{
|
||||
// The ceiling counts the whole data URI as sent.
|
||||
MaxEncodedBytes: api.Ptr(10 << 20),
|
||||
Formats: []string{"wav", "mp3"},
|
||||
// asr_options.language: "auto|zh|en".
|
||||
LanguageParam: api.Ptr(api.LanguageASROptions),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatThinkingType),
|
||||
PromptCacheAccounting: api.Ptr(true),
|
||||
// Only `auto` is honoured; everything else is stripped.
|
||||
ToolChoiceModes: []string{"auto"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
// Package providers registers MiniMax's OpenAI-compatible chat endpoint.
|
||||
//
|
||||
// Facts (https://platform.minimax.io/docs/api-reference/text-openai-api):
|
||||
// - both `max_tokens` (legacy) and `max_completion_tokens` are accepted,
|
||||
// and the reference recommends the latter for new integrations, so the
|
||||
// protocol default is kept;
|
||||
// - thinking is `thinking: {"type": "adaptive"|"disabled"}` (hence
|
||||
// thinking_enabled_value "adaptive"). On this OpenAI surface thinking is
|
||||
// ON when the field is omitted, so the switch is only sent when the
|
||||
// caller asks for one; the M2 generation accepts the field but cannot
|
||||
// actually turn thinking off, and models.json marks it "off": null;
|
||||
// - prompt caching is automatic and usage reports
|
||||
// `prompt_tokens_details.cached_tokens`, hence prompt_cache_accounting
|
||||
// (https://platform.minimax.io/docs/api-reference/text-prompt-caching);
|
||||
// - the only credential is a bearer API key: the GroupId that the legacy
|
||||
// /v1/text/chatcompletion_v2 endpoint required is not used here, so this
|
||||
// vendor needs no ExtraFields;
|
||||
// - the mainland endpoint is https://api.minimax.cn/v1 and the global one
|
||||
// https://api.minimax.io/v1; keys are region-bound (mainland keys to
|
||||
// minimax.cn, global keys to minimax.io). Mainland endpoint reference:
|
||||
// https://platform.minimax.cn/docs/api-reference/text-openai-api.
|
||||
//
|
||||
// Second protocol: an Anthropic Messages facade lives at
|
||||
// https://api.minimax.io/anthropic (mainland form in MinimaxAnthropicBaseURL), and
|
||||
// the vendor presents it first for thinking and tool workflows, documented at
|
||||
// https://platform.minimax.io/docs/api-reference/text-anthropic-api.
|
||||
// Resolve switches protocol when the base URL ends with /anthropic; this
|
||||
// package still defaults to the OpenAI-compatible surface, which is the one
|
||||
// documented for both regions.
|
||||
//
|
||||
// unverified: the sampling ranges are contradictory. The OpenAI-surface
|
||||
// reference gives temperature [0, 2] and top_p [0, 1], but MiniMax rejects
|
||||
// temperature=0 and top_p=0 in practice with error 2013 ("invalid params,
|
||||
// param 'top_p' should be in (0,1]"), i.e. the real range is (0, 1]. The
|
||||
// catalog can only express "no sampling" or "one fixed temperature", not an
|
||||
// exclusive lower bound, so nothing is configured and zero values still
|
||||
// reach the vendor;
|
||||
// unverified: `tool_choice`, `parallel_tool_calls`, `response_format` and
|
||||
// `prompt_cache_key` are not described on the OpenAI surface, so the
|
||||
// protocol defaults stand untested;
|
||||
// unverified: max output caps. The model table publishes context windows but
|
||||
// no per-model output cap, so the max_output_tokens in models.json are
|
||||
// carried over unconfirmed;
|
||||
// The mainland Anthropic facade is documented at
|
||||
// https://platform.minimax.cn/docs/api-reference/text-anthropic-api.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/minimax.svg
|
||||
var minimaxIcon []byte
|
||||
|
||||
// MinimaxID is the provider identifier stored on model rows.
|
||||
const MinimaxID = "minimax"
|
||||
|
||||
// MinimaxBaseURL is the mainland-China OpenAI-compatible endpoint.
|
||||
const MinimaxBaseURL = "https://api.minimax.cn/v1"
|
||||
|
||||
// MinimaxGlobalBaseURL is the international endpoint.
|
||||
const MinimaxGlobalBaseURL = "https://api.minimax.io/v1"
|
||||
|
||||
// MinimaxAnthropicBaseURL is the Anthropic Messages compatibility facade.
|
||||
const MinimaxAnthropicBaseURL = "https://api.minimax.cn/anthropic"
|
||||
|
||||
func newMinimaxProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: MinimaxID,
|
||||
Name: "MiniMax",
|
||||
Names: map[string]string{"zh-CN": "MiniMax"},
|
||||
Description: "MiniMax-M3, MiniMax-M2.7, MiniMax-M2.7-highspeed, etc. Global endpoint " +
|
||||
MinimaxGlobalBaseURL + "; Anthropic-compatible facade " + MinimaxAnthropicBaseURL,
|
||||
Descriptions: map[string]string{
|
||||
"zh-CN": "MiniMax-M3, MiniMax-M2.7, MiniMax-M2.7-highspeed 等。国际版 " +
|
||||
MinimaxGlobalBaseURL + ";Anthropic 兼容接口 " + MinimaxAnthropicBaseURL,
|
||||
},
|
||||
Website: "https://platform.minimax.cn",
|
||||
Icon: minimaxIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 16,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
// Retain inference for saved rows using the previous mainland domain.
|
||||
URLPatterns: []string{"minimax.cn", "minimax.io", "minimaxi.com"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: MinimaxBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeASR,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
Transcriptions: api.TranscriptionsCompat{
|
||||
// https://platform.minimax.io/docs/api-reference/speech-to-text
|
||||
// (and the same page on platform.minimax.cn): multipart model
|
||||
// (asr-1.0) + file on /v1/speech_to_text rather than the OpenAI
|
||||
// path, answering {text, duration, trace_id} for the default
|
||||
// json. At most 50 MB and 500 seconds; "超出会返回 400 而不会被截断".
|
||||
Path: api.Ptr("/speech_to_text"),
|
||||
MaxFileBytes: api.Ptr(50 << 20),
|
||||
// "wav / aiff / flac / alac(m4a) / mp3 / aac / opus / ogg";
|
||||
// "不支持无容器的裸 PCM 数据". The language hint is a request
|
||||
// header, a BCP-47 tag, not a form field.
|
||||
Formats: []string{"wav", "aiff", "flac", "m4a", "mp3", "aac", "opus", "ogg"},
|
||||
LanguageParam: api.Ptr(api.LanguageHeader),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatThinkingType),
|
||||
ThinkingEnabledValue: api.Ptr("adaptive"),
|
||||
PromptCacheAccounting: api.Ptr(true),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// Package providers registers ModelScope's API-Inference service.
|
||||
//
|
||||
// Facts (https://modelscope.cn/docs/model-service/API-Inference/intro,
|
||||
// https://modelscope.cn/docs/model-service/API-Inference/limits):
|
||||
// - the OpenAI-compatible base URL is https://api-inference.modelscope.cn/v1
|
||||
// and auth is `Authorization: Bearer <ModelScope Access Token>` (the
|
||||
// account must be bound to a verified Aliyun account);
|
||||
// - the same host also serves an OpenAI Responses endpoint on /v1 (Qwen3.5
|
||||
// family only) and a beta Anthropic Messages endpoint on the bare host
|
||||
// (https://api-inference.modelscope.cn/anthropic/v1/messages); this vendor
|
||||
// only selects Chat Completions;
|
||||
// - model ids are ModelScope repo ids ("Owner/Model-Name"); which of them
|
||||
// API-Inference serves changes over time — the docs state outright that
|
||||
// older models are taken offline as newer ones land, and only the model
|
||||
// page (the API-Inference panel) is authoritative;
|
||||
// - API-Inference is a free, non-commercial service with dynamic rate limits
|
||||
// and no per-token price: calls are metered in 魔粒 credits
|
||||
// (0.5 / 1 / 2 per call by model tier), which is why the entries below
|
||||
// carry a zero token cost rather than a real one;
|
||||
// - the documented scope is open LLM, multimodal (MLLM) and AIGC
|
||||
// text-to-image models.
|
||||
//
|
||||
// Unverified: the thinking switch — ModelScope documents no thinking
|
||||
// parameter, so the top-level `enable_thinking` of the DashScope/Bailian
|
||||
// channel behind API-Inference is kept as a guess, as is `max_tokens` for the
|
||||
// output cap; embedding support is not documented anywhere on the
|
||||
// API-Inference pages, so the Embedding model type and the two Qwen3-Embedding
|
||||
// entries are unconfirmed; every model id, context window, max output and
|
||||
// thinking flag below predates the current lineup, and as of 2026-09-20 none
|
||||
// of them advertises a "ModelScope" provider on
|
||||
// https://modelscope.cn/api/v1/inference/list_model_providers (models that are
|
||||
// served, such as Qwen/Qwen3.5-35B-A3B or ZhipuAI/GLM-5.2, do) — they are kept
|
||||
// because no official page states their retirement, but the list needs a
|
||||
// refresh against the model pages.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/modelscope.svg
|
||||
var modelscopeIcon []byte
|
||||
|
||||
// ModelscopeID is the provider identifier stored on model rows.
|
||||
const ModelscopeID = "modelscope"
|
||||
|
||||
// ModelscopeBaseURL is the OpenAI-compatible inference endpoint.
|
||||
const ModelscopeBaseURL = "https://api-inference.modelscope.cn/v1"
|
||||
|
||||
func newModelscopeProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: ModelscopeID,
|
||||
Name: "ModelScope",
|
||||
Names: map[string]string{"zh-CN": "魔搭 ModelScope"},
|
||||
Description: "Qwen/Qwen3-235B-A22B-Instruct-2507, ZhipuAI/GLM-4.6, Qwen/Qwen3-Embedding-8B, etc.",
|
||||
Website: "https://modelscope.cn",
|
||||
Icon: modelscopeIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 19,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"modelscope.cn"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: ModelscopeBaseURL,
|
||||
types.ModelTypeEmbedding: ModelscopeBaseURL,
|
||||
types.ModelTypeVLLM: ModelscopeBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeVLLM,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
// Embeddings keeps the bare baseline: /v1/embeddings answers, but no
|
||||
// ModelScope page documents a single parameter of it.
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
MaxTokensField: api.Ptr("max_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatEnableThinking),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
// Package providers registers Moonshot AI (Kimi).
|
||||
//
|
||||
// Facts (https://platform.kimi.com/docs/api/overview,
|
||||
// https://platform.kimi.com/docs/api/chat,
|
||||
// https://platform.kimi.com/docs/api/models-overview):
|
||||
// - the mainland base URL is https://api.moonshot.cn/v1 and the global one
|
||||
// https://api.moonshot.ai/v1 (the default here); both are recognised by
|
||||
// URL pattern. The same hosts also expose an OpenAI Responses endpoint on
|
||||
// /v1 and an Anthropic Messages endpoint on /anthropic, neither of which
|
||||
// this vendor selects;
|
||||
// - auth is `Authorization: Bearer <key>`;
|
||||
// - the output cap is `max_completion_tokens` (the protocol default);
|
||||
// `max_tokens` is still accepted but documented as deprecated;
|
||||
// - kimi-k2.6 and the kimi-k2.7-code pair switch thinking with
|
||||
// `thinking: {"type": "enabled"|"disabled"}`; k2.7-code cannot turn it off
|
||||
// (Preserved Thinking is always on), k2.6 can;
|
||||
// - kimi-k3 takes no `thinking` object at all: it always reasons and is only
|
||||
// graded through the top-level `reasoning_effort` (low | high | max,
|
||||
// default max), so that entry overrides the thinking format to openai;
|
||||
// - every current model refuses sampling parameters (temperature is pinned
|
||||
// to 1.0 on k3 / k2.7-code and to 1.0 thinking / 0.6 non-thinking on k2.6,
|
||||
// top_p to 0.95, n to 1, both penalties to 0), so none are sent;
|
||||
// - tool_choice accepts none / auto on every model and required only on
|
||||
// kimi-k3; a named function is never sent because it answers 400 while
|
||||
// thinking is enabled;
|
||||
// - response_format (text / json_object / json_schema) and
|
||||
// `stream_options: {"include_usage": true}` are supported;
|
||||
// - context caching is automatic and usage reports
|
||||
// `prompt_tokens_details.cached_tokens` / `cache_write_tokens`;
|
||||
// Anthropic-style breakpoints (`prompt_cache_breakpoint`) are rejected;
|
||||
// - moonshot-v1* (incl. the vision previews), kimi-k2.5, kimi-k2-turbo-preview
|
||||
// and kimi-k2-thinking were retired on 2026-08-31, the older kimi-k2*
|
||||
// snapshots on 2026-05-25; they stay as deprecated entries so stored model
|
||||
// rows still resolve (https://platform.kimi.com/docs/models).
|
||||
//
|
||||
// Unverified: `prompt_cache_key` / `prompt_cache_options` are documented but
|
||||
// left off, because the protocol layer pairs prompt_cache_key with OpenAI's
|
||||
// `prompt_cache_retention`, which Moonshot does not document (it uses
|
||||
// prompt_cache_options.ttl with 5m / 1h); parallel_tool_calls and seed are
|
||||
// absent from the documented request schema yet not documented as rejected, so
|
||||
// the protocol defaults are kept; the 262144 max output tokens of the K2.x
|
||||
// entries is not a documented cap (the docs only give a 32768 default); the
|
||||
// per-token costs are USD conversions of the CNY price list.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/moonshot.svg
|
||||
var moonshotIcon []byte
|
||||
|
||||
// MoonshotID is the provider identifier stored on model rows.
|
||||
const MoonshotID = "moonshot"
|
||||
|
||||
// MoonshotBaseURL is the global OpenAI-compatible endpoint.
|
||||
const MoonshotBaseURL = "https://api.moonshot.ai/v1"
|
||||
|
||||
func newMoonshotProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: MoonshotID,
|
||||
Name: "Moonshot AI",
|
||||
Names: map[string]string{"zh-CN": "月之暗面 Moonshot"},
|
||||
Description: "kimi-k3, kimi-k2.7-code, kimi-k2.7-code-highspeed, kimi-k2.6",
|
||||
Website: "https://platform.kimi.com",
|
||||
Icon: moonshotIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 17,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"moonshot.ai", "moonshot.cn"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: MoonshotBaseURL,
|
||||
types.ModelTypeVLLM: MoonshotBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeVLLM,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatThinkingType),
|
||||
PromptCacheAccounting: api.Ptr(true),
|
||||
// `required` is kimi-k3 only and a named function 400s while
|
||||
// thinking is on, which is the default on every model.
|
||||
ToolChoiceModes: []string{"none", "auto"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// Package providers registers the Novita AI gateway.
|
||||
//
|
||||
// Facts (https://docs.novita.ai — novita.ai/docs/* redirects there):
|
||||
// - chat, embedding, VLM and rerank share https://api.novita.ai/openai/v1;
|
||||
// /v1/completions, /v1/batches and /v1/files sit alongside;
|
||||
// - rerank is the Cohere shape — {model, query, documents, top_n} answering
|
||||
// results[].{index, relevance_score, document.text} — so it needs no
|
||||
// vendor settings beyond the type being open
|
||||
// (https://docs.novita.ai/api-reference/model-apis-llm-create-rerank).
|
||||
// No ceiling on the document count is documented, and the reference
|
||||
// lists no model ids, so none are shipped: the operator names the model;
|
||||
// - output cap is `max_tokens`, documented as required;
|
||||
// `max_completion_tokens` is never mentioned;
|
||||
// - the thinking switch is a **top-level** `enable_thinking` boolean
|
||||
// (default true) — "Controls the switches between thinking and
|
||||
// non-thinking modes" — not `chat_template_kwargs.enable_thinking` and
|
||||
// not `reasoning_effort`, neither of which appears anywhere in the docs.
|
||||
// There is no graded effort, so supports_reasoning_effort stays off and
|
||||
// models that cannot stop reasoning are marked "off": null.
|
||||
//
|
||||
// Unverified:
|
||||
// - the documented enable_thinking support list still names glm-4.5 and
|
||||
// deepseek-v3.1/v3.2-exp, so whether the current flagships (glm-5.x,
|
||||
// deepseek-v4-*, kimi-k3, minimax-m2.7) honour it is not stated. The
|
||||
// switch is only sent when a caller asks for one, so a model that
|
||||
// ignores it degrades to its own default rather than failing;
|
||||
// - the three embedding entries are served by the API but the embeddings
|
||||
// reference restricts `model` to a single enum value (baai/bge-m3), and
|
||||
// they are absent from the default /v1/models listing.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/novita.svg
|
||||
var novitaIcon []byte
|
||||
|
||||
// NovitaID is the provider identifier stored on model rows.
|
||||
const NovitaID = "novita"
|
||||
|
||||
// NovitaBaseURL is the OpenAI-compatible gateway endpoint.
|
||||
const NovitaBaseURL = "https://api.novita.ai/openai/v1"
|
||||
|
||||
func newNovitaProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: NovitaID,
|
||||
Name: "Novita AI",
|
||||
Names: map[string]string{"zh-CN": "Novita AI"},
|
||||
Description: "moonshotai/kimi-k3, zai-org/glm-5.2, deepseek/deepseek-v4-pro, qwen/qwen3-embedding-0.6b, etc.",
|
||||
Website: "https://novita.ai",
|
||||
Icon: novitaIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 52,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"api.novita.ai", "novita.ai"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: NovitaBaseURL,
|
||||
types.ModelTypeEmbedding: NovitaBaseURL,
|
||||
types.ModelTypeRerank: NovitaBaseURL,
|
||||
types.ModelTypeVLLM: NovitaBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeRerank,
|
||||
types.ModelTypeVLLM,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
// https://novita.ai/docs/api-reference/model-apis-llm-create-embeddings:
|
||||
// input, model, encoding_format. Nothing else.
|
||||
SendEncodingFormat: api.Ptr(true),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
MaxTokensField: api.Ptr("max_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatEnableThinking),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
// Package providers registers NVIDIA NIM's hosted API (build.nvidia.com).
|
||||
//
|
||||
// Facts (https://docs.api.nvidia.com/nim/ and the per-model cards on
|
||||
// https://build.nvidia.com):
|
||||
// - chat, embedding and VLM share https://integrate.api.nvidia.com/v1 with
|
||||
// `Authorization: Bearer`; rerank is a separate host,
|
||||
// https://ai.api.nvidia.com/v1/retrieval/nvidia/reranking, whose body is
|
||||
// {query, passages, model, truncate} with at most 512 passages. Current
|
||||
// rerank NIMs also expose a per-model path
|
||||
// (.../retrieval/nvidia/<slug>/reranking); the shared path stays live and
|
||||
// is what legacy rerank models answer on;
|
||||
// - the output cap field is mixed per model. NVIDIA's own curl and Python
|
||||
// samples use `max_tokens`, so that is the vendor default, but the cards
|
||||
// for kimi-k3 and gemma-4-31b-it show `max_completion_tokens`; those
|
||||
// entries override it. The LLM API reference defers to the vLLM
|
||||
// OpenAI-server schema rather than pinning either field;
|
||||
// - thinking has no single encoding on NIM. Nemotron 3 takes
|
||||
// `chat_template_kwargs: {"enable_thinking": bool}` (the vendor default
|
||||
// here), DeepSeek V4 takes `chat_template_kwargs: {"thinking": bool,
|
||||
// "reasoning_effort": ...}`, GLM-5.3 takes a top-level `reasoning_effort`
|
||||
// defaulting to max, MiniMax M3 takes `thinking_mode`, and Gemma 4
|
||||
// switches thinking with a `<|think|>` token in the system prompt rather
|
||||
// than any parameter — which is why the gemma entry sets thinking_format
|
||||
// "none" instead of pretending a switch exists. The entries that grade
|
||||
// with a top-level `reasoning_effort` carry thinking_format "openai";
|
||||
// without it the vendor default would emit a chat-template switch and
|
||||
// drop the level, leaving the picker's rungs inert;
|
||||
// - most hosted endpoints are metered at zero cost; the Nemotron and
|
||||
// DeepSeek endpoints are priced;
|
||||
// - nemotron-3-embed-1b is the one embedding endpoint here that
|
||||
// build.nvidia.com does not mark deprecated: nv-embed-v1,
|
||||
// llama-3_2-nemoretriever-300m-embed-v1 (and its v2) and baai/bge-m3 all
|
||||
// carry "This NIM Endpoint has been deprecated", so their entries were
|
||||
// removed. Its reference caps input at 4096 tokens; the 2048-wide vector
|
||||
// is from the Nemotron-3-Embed-1B model card on Hugging Face.
|
||||
//
|
||||
// Unverified:
|
||||
// - `minimaxai/minimax-m3`, `minimaxai/minimax-m2.7` and
|
||||
// `mistralai/mistral-medium-3.5-128b` have live build.nvidia.com pages
|
||||
// whose samples ship an empty `model=""`, so the exact org-prefixed id
|
||||
// could not be confirmed; they are left out rather than guessed;
|
||||
// - `nvidia/rerank-qa-mistral-4b` (the previous entry here) has no
|
||||
// per-model rerank route and one source reports a 2026-08-24
|
||||
// deprecation, so it was replaced with nv-rerankqa-mistral-4b-v3 and the
|
||||
// current llama-nemotron-rerank-vl-1b-v2;
|
||||
// - DeepSeek on NIM wants `reasoning_effort` nested inside
|
||||
// chat_template_kwargs, which this compat model cannot express: it emits
|
||||
// either a chat-template switch or a top-level effort, never both;
|
||||
// - the kimi-k3 card states "Thinking is always enabled" and advertises
|
||||
// "configurable low, high, or max reasoning effort", but none of its
|
||||
// samples show the parameter. The entry assumes the top-level
|
||||
// `reasoning_effort` its first-party API documents.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/nvidia.svg
|
||||
var nvidiaIcon []byte
|
||||
|
||||
// NvidiaID is the provider identifier stored on model rows.
|
||||
const NvidiaID = "nvidia"
|
||||
|
||||
// NvidiaBaseURL serves chat, embedding and VLM.
|
||||
const NvidiaBaseURL = "https://integrate.api.nvidia.com/v1"
|
||||
|
||||
// NvidiaRerankBaseURL is the retrieval reranking NIM.
|
||||
const NvidiaRerankBaseURL = "https://ai.api.nvidia.com/v1/retrieval/nvidia/reranking"
|
||||
|
||||
func newNvidiaProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: NvidiaID,
|
||||
Name: "NVIDIA",
|
||||
Names: map[string]string{"zh-CN": "NVIDIA"},
|
||||
Description: "nvidia/nemotron-3-ultra-550b-a55b, deepseek-ai/deepseek-v4-pro-0813, " +
|
||||
"nvidia/nemotron-3-embed-1b, nvidia/nv-rerankqa-mistral-4b-v3, etc.",
|
||||
Website: "https://build.nvidia.com",
|
||||
Icon: nvidiaIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 51,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"nvidia.com"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: NvidiaBaseURL,
|
||||
types.ModelTypeEmbedding: NvidiaBaseURL,
|
||||
types.ModelTypeRerank: NvidiaRerankBaseURL,
|
||||
types.ModelTypeVLLM: NvidiaBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeRerank,
|
||||
types.ModelTypeVLLM,
|
||||
},
|
||||
RerankAPI: api.RerankNIM,
|
||||
Compat: VendorCompat{
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
// https://docs.api.nvidia.com/nim/reference/nvidia-nemotron-3-embed-1b-infer:
|
||||
// input, model, input_type (passage | query), encoding_format,
|
||||
// truncate (NONE | START | END, default NONE), user. There is no
|
||||
// dimensions field. input_type is required and passage is what
|
||||
// this vendor has always been sent for documents, so the indexed
|
||||
// side is unchanged; queries now get query, as the reference
|
||||
// insists they must. This is the hosted API: a self-hosted NIM
|
||||
// (https://docs.nvidia.com/nim/nemo-retriever/embedding/latest/reference.html)
|
||||
// does take dimensions, and belongs on a generic row pointed at it.
|
||||
SendEncodingFormat: api.Ptr(true),
|
||||
InputTypeField: api.Ptr("input_type"),
|
||||
InputTypeValues: map[string]string{"document": "passage", "query": "query"},
|
||||
// NONE fails the request on an over-long input instead of
|
||||
// cutting it.
|
||||
TruncateField: api.Ptr("truncate"),
|
||||
TruncateValue: api.Ptr("END"),
|
||||
},
|
||||
Rerank: api.RerankCompat{
|
||||
// rankings[].logit is unbounded and routinely negative, so the
|
||||
// caller must be told this is not a 0..1 relevance score.
|
||||
ScoreScale: api.Ptr(api.ScoreLogit),
|
||||
// truncate defaults to NONE upstream, which fails the request on
|
||||
// an over-long passage instead of cutting it.
|
||||
Truncate: api.Ptr("END"),
|
||||
MaxDocuments: api.Ptr(512),
|
||||
// VLM reranking: "Images must be base64 data URLs"; "PNG, JPEG,
|
||||
// WebP, GIF, BMP, and TIFF image bytes are recognized"; "A
|
||||
// request can include up to 512 passages." No size limit is
|
||||
// stated. https://docs.nvidia.com/nim/nemo-retriever/reranking/latest/use-the-api-openai.html
|
||||
MaxImageBatchSize: api.Ptr(512),
|
||||
ImageMIMETypes: []string{
|
||||
"image/png", "image/jpeg", "image/webp", "image/gif", "image/bmp", "image/tiff",
|
||||
},
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
MaxTokensField: api.Ptr("max_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatChatTemplateKwargs),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
// Package providers registers OpenAI's first-party platform.
|
||||
//
|
||||
// Facts (https://developers.openai.com/api/docs — platform.openai.com/docs
|
||||
// now redirects there):
|
||||
// - output cap is `max_completion_tokens` (`max_tokens` is one of the
|
||||
// parameters reasoning models reject outright);
|
||||
// - thinking is graded with `reasoning_effort` only. The full vocabulary is
|
||||
// none | minimal | low | medium | high | xhigh | max and every model takes
|
||||
// a subset: `minimal` exists only on the original GPT-5 trio and is gone
|
||||
// from gpt-5.1 and later, so the gpt-5* family folds minimal onto low;
|
||||
// `none` is accepted from gpt-5.1 through gpt-5.6 but rejected by GPT-5,
|
||||
// the o-series and GPT-6 Astra, which are therefore "off": null;
|
||||
// `xhigh` is limited to GPT-6, GPT-5.6, GPT-5.5 and GPT-5.4, and `max`
|
||||
// to GPT-6 and GPT-5.6
|
||||
// (https://developers.openai.com/api/docs/guides/reasoning, and the
|
||||
// per-model support matrix Microsoft publishes for the same models at
|
||||
// https://learn.microsoft.com/azure/ai-foundry/openai/how-to/reasoning);
|
||||
// - reasoning models take the `developer` role instead of `system`, and
|
||||
// reject temperature, top_p, presence_penalty, frequency_penalty,
|
||||
// logprobs, top_logprobs, logit_bias and max_tokens, so the gpt-6* /
|
||||
// gpt-5* / o1* / o3* / o4* families set supports_temperature false;
|
||||
// - `store: false` is sent so completions are not retained, and
|
||||
// `prompt_cache_key` steers cache routing; usage reports cached tokens;
|
||||
// - chat, embedding, VLM and ASR are served from https://api.openai.com/v1;
|
||||
// there is no rerank API;
|
||||
// - requests that go to api.openai.com itself use the Responses protocol
|
||||
// (https://developers.openai.com/api/docs/api-reference/responses),
|
||||
// OpenAI's primary API where reasoning items and encrypted reasoning are
|
||||
// replayable; relays and proxies that only speak Chat Completions keep
|
||||
// that protocol because their base URL is not api.openai.com. Operators
|
||||
// can force either with extra_config.api. Two documented Chat Completions
|
||||
// restrictions make Responses the right default rather than a preference:
|
||||
// `reasoning_effort: "max"` is Responses-only, and on GPT-5.6 models Chat
|
||||
// Completions rejects `tools` together with any effort other than "none"
|
||||
// ("Function tools with reasoning_effort are not supported ... in
|
||||
// /v1/chat/completions. To use function tools, use /v1/responses").
|
||||
// A relay pinned to Chat Completions therefore cannot combine tools with
|
||||
// graded thinking on those models; that is the relay's limit, not ours.
|
||||
//
|
||||
// Unverified: `o1-mini` does not accept `reasoning_effort` at all, but the
|
||||
// o1* family entry cannot express a single-model exception without shadowing
|
||||
// the pattern, so the vendor-level supports_reasoning_effort still applies to
|
||||
// it. Responses-only compat (prompt-cache retention, reasoning summaries)
|
||||
// cannot be set per model here either: a models.json `compat` object is read
|
||||
// against the entry's own API, and these entries are Chat Completions
|
||||
// entries. GPT-5.6 and later replaced `prompt_cache_retention` with
|
||||
// `prompt_cache_options.ttl`, which the protocol layer does not send yet.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"academy/internal/models"
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/openai.svg
|
||||
var openaiIcon []byte
|
||||
|
||||
// OpenaiID is the provider identifier stored on model rows.
|
||||
const OpenaiID = "openai"
|
||||
|
||||
// OpenaiBaseURL is the documented first-party endpoint.
|
||||
const OpenaiBaseURL = "https://api.openai.com/v1"
|
||||
|
||||
func newOpenaiProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: OpenaiID,
|
||||
Name: "OpenAI",
|
||||
Names: map[string]string{"zh-CN": "OpenAI"},
|
||||
Description: "gpt-6-astra, gpt-5.6-sol, gpt-5.5, gpt-4.1, text-embedding-3-large, etc.",
|
||||
Website: "https://developers.openai.com",
|
||||
Icon: openaiIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 30,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"api.openai.com"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: OpenaiBaseURL,
|
||||
types.ModelTypeEmbedding: OpenaiBaseURL,
|
||||
types.ModelTypeVLLM: OpenaiBaseURL,
|
||||
types.ModelTypeASR: OpenaiBaseURL,
|
||||
},
|
||||
// No rerank: OpenAI's API has no rerank endpoint — the reference
|
||||
// index (https://developers.openai.com/api/llms.txt) does not mention
|
||||
// one — so a row created here would only ever 404. A relay that
|
||||
// serves rerank behind an OpenAI-style URL is a generic row.
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeVLLM,
|
||||
types.ModelTypeASR,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
Transcriptions: api.TranscriptionsCompat{
|
||||
// The transcription reference (URL in openaitranscriptions):
|
||||
// response_format differs per model — "For gpt-4o-transcribe
|
||||
// and gpt-4o-mini-transcribe, the only supported format is
|
||||
// json", the default — so it is declared per entry, not here.
|
||||
// "Files can be up to 25 MB"
|
||||
// (https://developers.openai.com/api/docs/guides/speech-to-text).
|
||||
MaxFileBytes: api.Ptr(25 << 20),
|
||||
// "flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm", and a
|
||||
// language field in ISO-639-1.
|
||||
Formats: []string{"flac", "mp3", "mp4", "mpeg", "mpga", "m4a", "ogg", "wav", "webm"},
|
||||
LanguageParam: api.Ptr(api.LanguageForm),
|
||||
},
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
// https://developers.openai.com/api/reference/resources/embeddings/methods/create:
|
||||
// model, input, dimensions (text-embedding-3 and later; the ada-002
|
||||
// entry turns it off), encoding_format, user. An input array
|
||||
// "must be 2048 dimensions or less" — elements, despite the word.
|
||||
SendEncodingFormat: api.Ptr(true),
|
||||
DimensionsField: api.Ptr("dimensions"),
|
||||
MaxBatchSize: api.Ptr(2048),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatOpenAI),
|
||||
SupportsReasoningEffort: api.Ptr(true),
|
||||
SupportsDeveloperRole: api.Ptr(true),
|
||||
SupportsStore: api.Ptr(true),
|
||||
PromptCacheKey: api.Ptr(true),
|
||||
PromptCacheAccounting: api.Ptr(true),
|
||||
},
|
||||
},
|
||||
|
||||
PreferAPI: OpenaiPreferResponsesOnFirstParty,
|
||||
}
|
||||
}
|
||||
|
||||
// OpenaiPreferResponsesOnFirstParty switches chat traffic aimed at api.openai.com
|
||||
// to the Responses protocol. Anything else (Azure-style relays, LiteLLM,
|
||||
// enterprise gateways) keeps Chat Completions, the protocol they document.
|
||||
func OpenaiPreferResponsesOnFirstParty(baseURL string, spec models.ModelSpec) api.API {
|
||||
if spec.Type != "" && spec.Type != types.ModelTypeKnowledgeQA {
|
||||
return ""
|
||||
}
|
||||
u, err := url.Parse(strings.TrimSpace(baseURL))
|
||||
if err != nil || !strings.EqualFold(u.Hostname(), "api.openai.com") {
|
||||
return ""
|
||||
}
|
||||
return api.APIOpenAIResponses
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
// Package providers registers the OpenRouter gateway.
|
||||
//
|
||||
// Facts (https://openrouter.ai/docs/guides/best-practices/reasoning-tokens —
|
||||
// the old /docs/use-cases/ path now redirects there):
|
||||
// - `max_tokens` is documented as deprecated ("Maximum tokens
|
||||
// (deprecated, use max_completion_tokens)") and some upstreams enforce a
|
||||
// minimum of 16 on it, so this vendor keeps the protocol default
|
||||
// `max_completion_tokens`;
|
||||
// - thinking is expressed with the unified `reasoning` object
|
||||
// ({"effort": ...} or {"enabled": bool}) which OpenRouter translates for
|
||||
// every upstream. The effort enum is
|
||||
// max | xhigh | high | medium | low | minimal | none, which is why xhigh
|
||||
// and max are enabled vendor-wide; per-model support is gated by
|
||||
// `supported_efforts` in /api/v1/models, and models flagged mandatory
|
||||
// (today gemini-3.8-flash, gemini-3.1-pro-preview, glm-5.3, grok-4.6)
|
||||
// reject an off switch entirely. Claude upstreams reject "none" and send
|
||||
// minimal as low, so the anthropic/* family is "off": null with minimal
|
||||
// folded onto low;
|
||||
// - Anthropic-routed models honour `cache_control` breakpoints, ephemeral
|
||||
// with a 5m or 1h ttl and at most four explicit breakpoints (the
|
||||
// anthropic/* family sets cache_control_format "anthropic");
|
||||
// - `prompt_cache_key` is accepted as the sticky routing key (OpenRouter's
|
||||
// own preferred field is `session_id`) and usage reports
|
||||
// prompt_tokens_details.cached_tokens;
|
||||
// - embeddings are routed through the same /api/v1 base
|
||||
// (https://openrouter.ai/docs/api_reference/embeddings).
|
||||
//
|
||||
// Unverified: GET /api/v1/models lists chat models only — embedding models
|
||||
// live behind /api/v1/embeddings/models — so any future auto-sync of this
|
||||
// catalog has to read both listings or it will silently lose embeddings.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/openrouter.svg
|
||||
var openrouterIcon []byte
|
||||
|
||||
// OpenrouterID is the provider identifier stored on model rows.
|
||||
const OpenrouterID = "openrouter"
|
||||
|
||||
// OpenrouterBaseURL is the OpenAI-compatible gateway endpoint.
|
||||
const OpenrouterBaseURL = "https://openrouter.ai/api/v1"
|
||||
|
||||
func newOpenrouterProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: OpenrouterID,
|
||||
Name: "OpenRouter",
|
||||
Names: map[string]string{"zh-CN": "OpenRouter"},
|
||||
Description: "openai/gpt-5.5, anthropic/claude-opus-5, google/gemini-3.8-flash, " +
|
||||
"deepseek/deepseek-v4-pro, etc.",
|
||||
Website: "https://openrouter.ai",
|
||||
Icon: openrouterIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 40,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"openrouter.ai"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: OpenrouterBaseURL,
|
||||
types.ModelTypeEmbedding: OpenrouterBaseURL,
|
||||
types.ModelTypeRerank: OpenrouterBaseURL,
|
||||
types.ModelTypeVLLM: OpenrouterBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeRerank,
|
||||
types.ModelTypeVLLM,
|
||||
types.ModelTypeASR,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
Transcriptions: api.TranscriptionsCompat{
|
||||
// https://openrouter.ai/docs/api/api-reference/stt/create-transcription:
|
||||
// OpenAI-style multipart file + model, json by default. "Max 25
|
||||
// MB; send larger files as base64 JSON via input_audio."
|
||||
MaxFileBytes: api.Ptr(25 << 20),
|
||||
// language is an ISO-639-1 form field. The format "is derived
|
||||
// from the filename extension", with no closed list.
|
||||
LanguageParam: api.Ptr(api.LanguageForm),
|
||||
},
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
// https://openrouter.ai/docs/api/api-reference/embeddings/create-embeddings:
|
||||
// model, input, dimensions, encoding_format, input_type, provider,
|
||||
// user. input_type is a free-form string handed to whichever
|
||||
// upstream serves the model ("e.g. search_query,
|
||||
// search_document"), so its vocabulary is the upstream's, and on
|
||||
// an asymmetric model it changes the document vectors. Not
|
||||
// declared, for the reason Jina's task is not
|
||||
// (Tencent/WeKnora#1401).
|
||||
SendEncodingFormat: api.Ptr(true),
|
||||
DimensionsField: api.Ptr("dimensions"),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatOpenRouter),
|
||||
SupportsReasoningEffort: api.Ptr(true),
|
||||
PromptCacheKey: api.Ptr(true),
|
||||
PromptCacheAccounting: api.Ptr(true),
|
||||
},
|
||||
},
|
||||
// The reasoning.effort enum covers the whole ladder; per-model
|
||||
// support is gated upstream, not here.
|
||||
ThinkingLevels: api.ThinkingLevelMap{
|
||||
api.ReasoningXHigh: api.StringPtr("xhigh"),
|
||||
api.ReasoningMax: api.StringPtr("max"),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Package providers registers Pinecone's standalone hosted rerank endpoint.
|
||||
// https://docs.pinecone.io/guides/search/rerank-results
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/pinecone.svg
|
||||
var pineconeIcon []byte
|
||||
|
||||
// PineconeID identifies the Pinecone provider in the model catalog.
|
||||
const PineconeID = "pinecone"
|
||||
|
||||
// PineconeRerankBaseURL is the default Pinecone Inference API endpoint.
|
||||
const PineconeRerankBaseURL = "https://api.pinecone.io"
|
||||
|
||||
func newPineconeProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: PineconeID, Name: "Pinecone",
|
||||
Description: "Pinecone Inference standalone reranking (bge-reranker-v2-m3, pinecone-rerank-v0)",
|
||||
Website: "https://www.pinecone.io", Icon: pineconeIcon,
|
||||
API: api.APIOpenAICompletions, RerankAPI: api.RerankPinecone,
|
||||
Order: 56, RequiresAuth: true, Auth: AuthAPIKeyHeader,
|
||||
URLPatterns: []string{"api.pinecone.io"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{types.ModelTypeRerank: PineconeRerankBaseURL},
|
||||
ModelTypes: []types.ModelType{types.ModelTypeRerank},
|
||||
Headers: map[string]string{"X-Pinecone-Api-Version": "2026-07"},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,690 @@
|
||||
package providers_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"academy/internal/models"
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/models/api/anthropicmessages"
|
||||
"academy/internal/models/providers"
|
||||
modelruntime "academy/internal/models/runtime"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
// expectedIDs is every built-in vendor this package links.
|
||||
var expectedIDs = []string{
|
||||
"generic", "academycloud", "huggingface_tei",
|
||||
"aliyun", "zhipu", "volcengine", "hunyuan", "siliconflow", "deepseek",
|
||||
"minimax", "moonshot", "mimo", "modelscope", "qianfan", "qiniu", "longcat", "lkeap",
|
||||
"openai", "azure_openai", "anthropic", "gemini",
|
||||
"openrouter", "litellm", "requesty", "pinecone",
|
||||
"jina", "nvidia", "novita", "gpustack", "cohere",
|
||||
}
|
||||
|
||||
func TestMinimaxOfficialDefaultURLs(t *testing.T) {
|
||||
v, ok := modelruntime.Get(providers.MinimaxID)
|
||||
if !ok {
|
||||
t.Fatal("MiniMax provider missing")
|
||||
}
|
||||
for _, kind := range []types.ModelType{types.ModelTypeKnowledgeQA, types.ModelTypeASR} {
|
||||
if got := v.GetDefaultURL(kind); got != "https://api.minimax.cn/v1" {
|
||||
t.Errorf("%s default = %q, want current mainland endpoint", kind, got)
|
||||
}
|
||||
}
|
||||
if providers.MinimaxAnthropicBaseURL != "https://api.minimax.cn/anthropic" {
|
||||
t.Errorf("unexpected mainland Anthropic URL: %s", providers.MinimaxAnthropicBaseURL)
|
||||
}
|
||||
if v.Website != "https://platform.minimax.cn" {
|
||||
t.Errorf("unexpected mainland website: %s", v.Website)
|
||||
}
|
||||
for _, base := range []string{
|
||||
"https://api.minimax.cn/v1", "https://api.minimax.cn/anthropic",
|
||||
"https://api.minimaxi.com/v1", "https://api.minimaxi.com/anthropic",
|
||||
"https://api.minimax.io/v1", "https://api.minimax.io/anthropic",
|
||||
} {
|
||||
if got := modelruntime.DetectByURL(base); got != providers.MinimaxID {
|
||||
t.Errorf("DetectByURL(%q) = %q", base, got)
|
||||
}
|
||||
resolved, err := modelruntime.Resolve(modelruntime.Ref{BaseURL: base, Model: "MiniMax-M2.7"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if resolved.BaseURL != base {
|
||||
t.Errorf("explicit address was rewritten: %q -> %q", base, resolved.BaseURL)
|
||||
}
|
||||
wantAPI := api.APIOpenAICompletions
|
||||
if strings.HasSuffix(base, "/anthropic") {
|
||||
wantAPI = api.APIAnthropicMessages
|
||||
}
|
||||
if resolved.API != wantAPI {
|
||||
t.Errorf("%s resolved API = %s, want %s", base, resolved.API, wantAPI)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuiltinDefaultURLsAcrossModelTypes(t *testing.T) {
|
||||
for _, vendor := range modelruntime.List() {
|
||||
for _, kind := range vendor.ModelTypes {
|
||||
base := vendor.GetDefaultURL(kind)
|
||||
// These connections have no hosted service to prefill.
|
||||
if vendor.ID == "generic" || vendor.ID == "huggingface_tei" {
|
||||
if base != "" {
|
||||
t.Errorf("%s/%s should require an operator URL", vendor.ID, kind)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !strings.HasPrefix(base, "https://") && !strings.HasPrefix(base, "http://") {
|
||||
t.Errorf("%s/%s has no absolute default URL: %q", vendor.ID, kind, base)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAllVendorsRegistered(t *testing.T) {
|
||||
if len(expectedIDs) != 30 {
|
||||
t.Fatalf("expected 30 vendor ids in the spec, got %d", len(expectedIDs))
|
||||
}
|
||||
for _, id := range expectedIDs {
|
||||
v, ok := modelruntime.Get(id)
|
||||
if !ok {
|
||||
t.Errorf("vendor %q is not registered", id)
|
||||
continue
|
||||
}
|
||||
if v.ID != strings.ToLower(v.ID) {
|
||||
t.Errorf("vendor %q: id is not lowercase", id)
|
||||
}
|
||||
if v.Name == "" {
|
||||
t.Errorf("vendor %q: empty Name", id)
|
||||
}
|
||||
if len(v.Icon) == 0 || !bytes.HasPrefix(bytes.TrimSpace(v.Icon), []byte("<svg")) {
|
||||
t.Errorf("vendor %q: icon is empty or not an <svg> document", id)
|
||||
}
|
||||
if len(v.Icon) > 6*1024 {
|
||||
t.Errorf("vendor %q: icon is %d bytes, over the 6 KB budget", id, len(v.Icon))
|
||||
}
|
||||
if v.RequiresAuth && v.Auth == "" {
|
||||
t.Errorf("vendor %q: RequiresAuth without Auth style", id)
|
||||
}
|
||||
if v.Auth == providers.AuthSigned && v.Signer == nil {
|
||||
t.Errorf("vendor %q: AuthSigned without Signer", id)
|
||||
}
|
||||
if !v.API.Known() {
|
||||
t.Errorf("vendor %q: unknown default API %q", id, v.API)
|
||||
}
|
||||
if len(v.ModelTypes) == 0 {
|
||||
t.Errorf("vendor %q: no ModelTypes", id)
|
||||
}
|
||||
}
|
||||
for _, v := range modelruntime.List() {
|
||||
found := false
|
||||
for _, id := range expectedIDs {
|
||||
if id == v.ID {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("unexpected vendor %q registered", v.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestHuggingFaceTEIRequiresURLButNotAPIKey(t *testing.T) {
|
||||
v, ok := modelruntime.Get(providers.HuggingFaceTEIID)
|
||||
if !ok {
|
||||
t.Fatal("Hugging Face TEI provider not registered")
|
||||
}
|
||||
if err := v.ValidateConfig(&providers.Config{
|
||||
BaseURL: "http://tei.internal:8080", ModelName: "BAAI/bge-reranker-large",
|
||||
}); err != nil {
|
||||
t.Fatalf("a self-hosted TEI server should not require an API key: %v", err)
|
||||
}
|
||||
if err := v.ValidateConfig(&providers.Config{ModelName: "BAAI/bge-reranker-large"}); err == nil {
|
||||
t.Fatal("TEI provider accepted a missing base URL")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEveryCatalogEntryResolves(t *testing.T) {
|
||||
for _, id := range expectedIDs {
|
||||
v, ok := modelruntime.Get(id)
|
||||
if !ok {
|
||||
t.Fatalf("vendor %q missing", id)
|
||||
}
|
||||
for _, m := range v.Models() {
|
||||
if m.ID == "" && m.Match == "" {
|
||||
t.Errorf("%s: model entry %q has neither id nor match", id, m.Name)
|
||||
continue
|
||||
}
|
||||
name := m.ID
|
||||
if name == "" {
|
||||
// Exercise pattern entries with a name that matches the glob.
|
||||
name = strings.ReplaceAll(m.Match, "*", "x")
|
||||
}
|
||||
modelType := m.Type
|
||||
if modelType == "" {
|
||||
modelType = types.ModelTypeKnowledgeQA
|
||||
}
|
||||
r, err := modelruntime.Resolve(modelruntime.Ref{Provider: v.ID, Model: name, ModelType: modelType})
|
||||
// An entry may declare that this build cannot serve it — a vendor
|
||||
// whose second rerank dialect has no protocol package. Refusing is
|
||||
// the point: the alternative is a request shaped for the wrong
|
||||
// protocol. Such an entry must refuse, and must do it with a reason.
|
||||
if bytes.Contains(m.Compat, []byte("unsupported_reason")) {
|
||||
if err == nil {
|
||||
t.Errorf("%s/%s: declares unsupported_reason but still resolves", id, name)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("%s/%s: resolve: %v", id, name, err)
|
||||
continue
|
||||
}
|
||||
if !r.Cataloged {
|
||||
t.Errorf("%s/%s: did not match its own catalog entry", id, name)
|
||||
}
|
||||
if modelType == types.ModelTypeKnowledgeQA && !r.API.Known() {
|
||||
t.Errorf("%s/%s: resolved to unknown API %q", id, name, r.API)
|
||||
}
|
||||
if modelType == types.ModelTypeASR && !r.TranscriptionAPI.Known() {
|
||||
t.Errorf("%s/%s: resolved to unknown transcription API %q", id, name, r.TranscriptionAPI)
|
||||
}
|
||||
if modelType == types.ModelTypeEmbedding && !r.EmbeddingAPI.Known() {
|
||||
t.Errorf("%s/%s: resolved to unknown embedding API %q", id, name, r.EmbeddingAPI)
|
||||
}
|
||||
if modelType == types.ModelTypeEmbedding && m.ID != "" && m.Dimension <= 0 {
|
||||
t.Logf("%s/%s: embedding entry without dimension", id, name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Model names that fall inside a chat family's glob must still resolve as
|
||||
// embedding and rerank rows. The families that caught them carry chat compat
|
||||
// (thinking_always_send on Aliyun's qwen3*, max_tokens_field and
|
||||
// supports_temperature on gpt-5*), which the embedding and rerank overlays
|
||||
// reject, so an untyped lookup made these rows impossible to build — new ids
|
||||
// and dated snapshots first of all, since they are never in models.json yet.
|
||||
func TestNamesInsideChatGlobsResolveForOtherTypes(t *testing.T) {
|
||||
names := []struct{ provider, model string }{
|
||||
{"aliyun", "qwen3.8-text-embedding"},
|
||||
{"aliyun", "qwen3-embedding"},
|
||||
{"aliyun", "qwen3.7-text-embedding-20260601"},
|
||||
{"generic", "gpt-5-embed"},
|
||||
{"openai", "gpt-5-embed"},
|
||||
}
|
||||
for _, n := range names {
|
||||
for _, modelType := range []types.ModelType{types.ModelTypeEmbedding, types.ModelTypeRerank} {
|
||||
r, err := modelruntime.Resolve(modelruntime.Ref{Provider: n.provider, Model: n.model, ModelType: modelType})
|
||||
if err != nil {
|
||||
t.Errorf("%s/%s as %s: %v", n.provider, n.model, modelType, err)
|
||||
continue
|
||||
}
|
||||
if r.Cataloged {
|
||||
t.Errorf("%s/%s as %s matched %q, which is not an entry of that type",
|
||||
n.provider, n.model, modelType, r.Spec.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDetectByURLRoundTrip(t *testing.T) {
|
||||
for _, id := range expectedIDs {
|
||||
v, _ := modelruntime.Get(id)
|
||||
if len(v.URLPatterns) == 0 {
|
||||
continue
|
||||
}
|
||||
u := v.GetDefaultURL(types.ModelTypeKnowledgeQA)
|
||||
if !strings.HasPrefix(u, "https://") || strings.Contains(u, "{") {
|
||||
continue // placeholder or http-only self-hosted default
|
||||
}
|
||||
if got := modelruntime.DetectByURL(u); got != v.ID {
|
||||
t.Errorf("DetectByURL(%q) = %q, want %q", u, got, v.ID)
|
||||
}
|
||||
}
|
||||
if got := modelruntime.DetectByURL("http://your_litellm_proxy/v1"); got != "litellm" {
|
||||
t.Errorf("litellm placeholder detected as %q", got)
|
||||
}
|
||||
// GPUStack 2.x serves the OpenAI-compatible surface at /v1; the 0.x
|
||||
// /v1-openai path must keep resolving for rows saved before the move.
|
||||
if got := modelruntime.DetectByURL("http://your_gpustack_server_url/v1-openai"); got != "gpustack" {
|
||||
t.Errorf("gpustack placeholder detected as %q", got)
|
||||
}
|
||||
if got := modelruntime.DetectByURL("https://api.moonshot.cn/v1"); got != "moonshot" {
|
||||
t.Errorf("moonshot.cn detected as %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestOpenAIProtocolSelection pins the first-party / relay split: Responses on
|
||||
// api.openai.com, Chat Completions everywhere else, extra_config.api wins.
|
||||
func TestOpenAIProtocolSelection(t *testing.T) {
|
||||
cases := []struct {
|
||||
baseURL string
|
||||
extra map[string]string
|
||||
want api.API
|
||||
}{
|
||||
{"", nil, api.APIOpenAIResponses},
|
||||
{"https://api.openai.com/v1", nil, api.APIOpenAIResponses},
|
||||
{"https://API.openai.com/v1/", nil, api.APIOpenAIResponses},
|
||||
{"https://my-relay.example.com/v1", nil, api.APIOpenAICompletions},
|
||||
{"https://api.openai.com/v1", map[string]string{"api": "openai-completions"}, api.APIOpenAICompletions},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
r, err := modelruntime.Resolve(modelruntime.Ref{
|
||||
Provider: "openai", Model: "gpt-5.5", BaseURL: tc.baseURL, Extra: tc.extra,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("resolve openai %q: %v", tc.baseURL, err)
|
||||
}
|
||||
if r.API != tc.want {
|
||||
t.Errorf("openai base %q extra %v: api = %q, want %q", tc.baseURL, tc.extra, r.API, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// claudeNoSamplingModels reject non-default temperature/top_p/top_k values.
|
||||
var claudeNoSamplingModels = []string{
|
||||
"claude-opus-4-7", "claude-opus-4-8", "claude-opus-5", "claude-sonnet-5", "claude-fable-5", "claude-fable-5-1",
|
||||
}
|
||||
|
||||
func resolve(t *testing.T, provider, model string) *modelruntime.Resolved {
|
||||
t.Helper()
|
||||
r, err := modelruntime.Resolve(modelruntime.Ref{Provider: provider, Model: model})
|
||||
if err != nil {
|
||||
t.Fatalf("resolve %s/%s: %v", provider, model, err)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func TestFamilyExpectations(t *testing.T) {
|
||||
if r := resolve(t, "openai", "gpt-5.2"); r.OpenAICompletions.SupportsTemperature {
|
||||
t.Error("openai/gpt-5.2 should not support temperature")
|
||||
}
|
||||
if r := resolve(t, "openai", "gpt-5-turbo-future"); r.OpenAICompletions.SupportsTemperature || !r.Spec.Reasoning {
|
||||
t.Error("openai gpt-5* family should be reasoning without temperature")
|
||||
}
|
||||
if r := resolve(t, "openai", "o4-mini"); r.ThinkingLevels.Supports(api.ReasoningOff) {
|
||||
t.Error("openai/o4-mini should not allow thinking off")
|
||||
}
|
||||
if r := resolve(t, "azure_openai", "gpt-5.4-prod"); r.OpenAICompletions.SupportsTemperature {
|
||||
t.Error("azure gpt-5* deployment should not support temperature")
|
||||
}
|
||||
// Claude Opus 4.7 and later and Sonnet 5 reject non-default sampling
|
||||
// values, so the internal pipelines that set a fixed temperature must not
|
||||
// send temperature or top_p to these models.
|
||||
for _, model := range claudeNoSamplingModels {
|
||||
r := resolve(t, "anthropic", model)
|
||||
if r.AnthropicMessages.SupportsTemperature {
|
||||
t.Errorf("anthropic/%s should not support temperature", model)
|
||||
}
|
||||
if r.AnthropicMessages.SupportsTopP {
|
||||
t.Errorf("anthropic/%s should not support top_p", model)
|
||||
}
|
||||
}
|
||||
if r := resolve(t, "anthropic", "claude-sonnet-4-6"); !r.AnthropicMessages.SupportsTemperature {
|
||||
t.Error("anthropic/claude-sonnet-4-6 should still support temperature")
|
||||
}
|
||||
// A deployment named exactly gpt-5 / gpt-5-mini / gpt-5-nano must agree
|
||||
// with the openai vendor: the original GPT-5 trio rejects
|
||||
// reasoning_effort "none", so the picker must not offer thinking off.
|
||||
// Only GPT-5.1 and later, which the gpt-5* pattern covers, accept it.
|
||||
for _, deployment := range []string{"gpt-5", "gpt-5-mini", "gpt-5-nano"} {
|
||||
azureSpec := resolve(t, "azure_openai", deployment)
|
||||
if azureSpec.ThinkingLevels.Supports(api.ReasoningOff) {
|
||||
t.Errorf("azure/%s should not allow thinking off", deployment)
|
||||
}
|
||||
openaiSpec := resolve(t, "openai", deployment)
|
||||
if openaiSpec.ThinkingLevels.Supports(api.ReasoningOff) {
|
||||
t.Errorf("openai/%s should not allow thinking off", deployment)
|
||||
}
|
||||
}
|
||||
if r := resolve(t, "azure_openai", "gpt-5.1-prod"); !r.ThinkingLevels.Supports(api.ReasoningOff) {
|
||||
t.Error("azure gpt-5* family (GPT-5.1 and later) should allow thinking off")
|
||||
}
|
||||
if r := resolve(t, "aliyun", "qwen3-max"); !r.OpenAICompletions.ThinkingAlwaysSend {
|
||||
t.Error("aliyun/qwen3-max should always send the thinking switch")
|
||||
}
|
||||
if r := resolve(t, "aliyun", "qwen-plus-2026-01-01"); !r.OpenAICompletions.ThinkingAlwaysSend ||
|
||||
!r.OpenAICompletions.ThinkingDisableOnNonStream {
|
||||
t.Error("aliyun qwen-plus* family should carry the hybrid thinking flags")
|
||||
}
|
||||
if r := resolve(t, "aliyun", "qwq-plus"); r.ThinkingLevels.Supports(api.ReasoningOff) {
|
||||
t.Error("aliyun/qwq-plus should not allow thinking off")
|
||||
}
|
||||
if r := resolve(t, "moonshot", "moonshot-v1-8k"); r.OpenAICompletions.FixedTemperature == nil ||
|
||||
*r.OpenAICompletions.FixedTemperature != 1 {
|
||||
t.Error("moonshot/moonshot-v1-8k should pin temperature to 1")
|
||||
}
|
||||
if r := resolve(t, "moonshot", "kimi-k2.6"); r.OpenAICompletions.SupportsTemperature {
|
||||
t.Error("moonshot/kimi-k2.6 should not support temperature")
|
||||
}
|
||||
if r := resolve(t, "lkeap", "deepseek-r1"); r.ThinkingLevels.Supports(api.ReasoningOff) {
|
||||
t.Error("lkeap/deepseek-r1 should not allow thinking off")
|
||||
}
|
||||
if r := resolve(t, "lkeap", "my-deepseek-v3-route"); !r.Spec.Reasoning ||
|
||||
!r.ThinkingLevels.Supports(api.ReasoningOff) {
|
||||
t.Error("lkeap *deepseek-v3* family should be switchable reasoning")
|
||||
}
|
||||
if r := resolve(t, "zhipu", "glm-5.2"); r.ThinkingLevels.Value(api.ReasoningMedium) != "high" {
|
||||
t.Errorf("zhipu/glm-5.2 medium should map to high, got %q", r.ThinkingLevels.Value(api.ReasoningMedium))
|
||||
}
|
||||
if r := resolve(t, "zhipu", "glm-4.7"); r.ThinkingLevels.Value(api.ReasoningOff) != "none" {
|
||||
t.Error("zhipu vendor map should spell off as none")
|
||||
}
|
||||
if r := resolve(t, "gemini", "gemini-2.5-flash"); r.API != api.APIGoogleGenerativeAI {
|
||||
t.Errorf("gemini/gemini-2.5-flash API = %q", r.API)
|
||||
}
|
||||
if r := resolve(t, "gemini", "gemini-3.8-flash"); r.GoogleGenerativeAI.ThinkingMode != api.GoogleThinkingLevel {
|
||||
t.Errorf("gemini/gemini-3.8-flash thinking mode = %q", r.GoogleGenerativeAI.ThinkingMode)
|
||||
}
|
||||
if r := resolve(t, "anthropic", "claude-opus-5"); r.AnthropicMessages.ThinkingMode !=
|
||||
api.AnthropicThinkingAdaptive || !r.AnthropicMessages.SupportsEffort {
|
||||
t.Error("anthropic/claude-opus-5 should use adaptive thinking with effort")
|
||||
}
|
||||
if r := resolve(t, "anthropic", "claude-sonnet-4-5"); r.AnthropicMessages.ThinkingMode !=
|
||||
api.AnthropicThinkingBudget {
|
||||
t.Error("anthropic/claude-sonnet-4-5 should keep budget thinking")
|
||||
}
|
||||
if r := resolve(t, "anthropic", "claude-sonnet-4-5-20250929"); !r.Cataloged {
|
||||
t.Error("anthropic dated alias should resolve to the catalog entry")
|
||||
}
|
||||
if r := resolve(t, "openrouter", "anthropic/claude-haiku-4.5"); r.OpenAICompletions.CacheControlFormat !=
|
||||
"anthropic" {
|
||||
t.Error("openrouter anthropic/* family should use anthropic cache_control")
|
||||
}
|
||||
if r := resolve(t, "siliconflow", "deepseek-ai/DeepSeek-V4-Pro"); !r.OpenAICompletions.SupportsReasoningEffort ||
|
||||
r.ThinkingLevels.Value(api.ReasoningMax) != "max" {
|
||||
t.Error("siliconflow DeepSeek-V4-Pro should grade effort high/max")
|
||||
}
|
||||
if r := resolve(t, "siliconflow", "Pro/zai-org/GLM-5"); r.OpenAICompletions.SupportsReasoningEffort {
|
||||
t.Error("siliconflow GLM-5 should not send reasoning_effort")
|
||||
}
|
||||
if r := resolve(t, "minimax", "MiniMax-M3"); r.OpenAICompletions.ThinkingEnabledValue != "adaptive" {
|
||||
t.Error("minimax should enable thinking with type adaptive")
|
||||
}
|
||||
if r := resolve(t, "volcengine", "doubao-seed-1-6-251015"); r.OpenAICompletions.MaxTokensField !=
|
||||
"max_completion_tokens" {
|
||||
t.Error("volcengine must keep max_completion_tokens")
|
||||
}
|
||||
if r := resolve(t, "deepseek", "deepseek-reasoner"); r.ThinkingLevels.Supports(api.ReasoningOff) {
|
||||
t.Error("deepseek/deepseek-reasoner should not allow thinking off")
|
||||
}
|
||||
// required / named tool choices 400 in thinking mode, which is the
|
||||
// DeepSeek default, so neither may reach the wire.
|
||||
if r := resolve(t, "deepseek", "deepseek-v4-pro"); r.OpenAICompletions.AllowsToolChoice("required") ||
|
||||
r.OpenAICompletions.AllowsToolChoice("function") {
|
||||
t.Error("deepseek should not send required or named tool choices")
|
||||
}
|
||||
// GLM-5.2 reads "minimal" as give-up-thinking and folds "low" to high, so
|
||||
// rewriting minimal to low here would send the weakest rung as the
|
||||
// strongest one.
|
||||
if r := resolve(t, "zhipu", "glm-5.2"); r.ThinkingLevels.Value(api.ReasoningMinimal) != "minimal" {
|
||||
t.Errorf("zhipu/glm-5.2 minimal should stay minimal, got %q", r.ThinkingLevels.Value(api.ReasoningMinimal))
|
||||
}
|
||||
// Both entries grade with a top-level reasoning_effort; the vendor
|
||||
// default (chat_template_kwargs) would silently drop the level.
|
||||
for _, model := range []string{"z-ai/glm-5.3", "moonshotai/kimi-k3"} {
|
||||
r := resolve(t, "nvidia", model)
|
||||
if r.OpenAICompletions.ThinkingFormat != api.ThinkingFormatOpenAI ||
|
||||
!r.OpenAICompletions.SupportsReasoningEffort {
|
||||
t.Errorf("nvidia/%s should grade with a top-level reasoning_effort", model)
|
||||
}
|
||||
}
|
||||
if r := resolve(t, "nvidia", "nvidia/nemotron-3-ultra-550b-a55b"); r.OpenAICompletions.ThinkingFormat !=
|
||||
api.ThinkingFormatChatTemplateKwargs {
|
||||
t.Error("nvidia nemotron should keep the chat-template switch")
|
||||
}
|
||||
// DashScope errors when qwen3.8-max gets both fields.
|
||||
for _, model := range []string{"qwen3.8-max", "qwen3.8-flash", "qwen3.8-plus-2026-09-01"} {
|
||||
if r := resolve(t, "aliyun", model); !r.OpenAICompletions.ThinkingBudgetExcludesEffort {
|
||||
t.Errorf("aliyun/%s should not send thinking_budget next to reasoning_effort", model)
|
||||
}
|
||||
}
|
||||
if r := resolve(t, "aliyun", "qwen3-max"); r.OpenAICompletions.ThinkingBudgetExcludesEffort {
|
||||
t.Error("aliyun/qwen3-max has no effort to conflict with and should keep the budget")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHooks(t *testing.T) {
|
||||
azure, _ := modelruntime.Get("azure_openai")
|
||||
u, q := azure.Endpoint(providers.EndpointRequest{
|
||||
BaseURL: "https://my-res.openai.azure.com/",
|
||||
Model: "gpt-4o deploy",
|
||||
ModelType: types.ModelTypeKnowledgeQA,
|
||||
Extra: map[string]string{models.ExtraAPIVersion: "2025-01-01-preview"},
|
||||
})
|
||||
if u != "https://my-res.openai.azure.com/openai/deployments/gpt-4o%20deploy/chat/completions" {
|
||||
t.Errorf("azure endpoint = %q", u)
|
||||
}
|
||||
if q["api-version"] != "2025-01-01-preview" {
|
||||
t.Errorf("azure api-version = %q", q["api-version"])
|
||||
}
|
||||
// Without an explicit api_version the hook emits the v1 GA data plane,
|
||||
// which carries the deployment name in the body and takes no
|
||||
// api-version at all.
|
||||
u, q = azure.Endpoint(providers.EndpointRequest{BaseURL: "https://x.openai.azure.com", Model: "d"})
|
||||
if u != "https://x.openai.azure.com/openai/v1/chat/completions" {
|
||||
t.Errorf("azure v1 endpoint = %q", u)
|
||||
}
|
||||
if len(q) != 0 {
|
||||
t.Errorf("azure v1 query = %v, want none", q)
|
||||
}
|
||||
if azure.Auth != providers.AuthAPIKeyHeader {
|
||||
t.Errorf("azure auth = %q", azure.Auth)
|
||||
}
|
||||
// Embedding obeys the same rule as chat for the same stored row, so one
|
||||
// Azure resource never ends up serving chat on v1 and embedding on the
|
||||
// dated deployments path. internal/models/embedding calls this hook.
|
||||
u, q = azure.Endpoint(providers.EndpointRequest{
|
||||
BaseURL: "https://x.openai.azure.com", Model: "embed-deploy",
|
||||
ModelType: types.ModelTypeEmbedding,
|
||||
})
|
||||
if u != "https://x.openai.azure.com/openai/v1/embeddings" {
|
||||
t.Errorf("azure v1 embedding endpoint = %q", u)
|
||||
}
|
||||
if len(q) != 0 {
|
||||
t.Errorf("azure v1 embedding query = %v, want none", q)
|
||||
}
|
||||
u, q = azure.Endpoint(providers.EndpointRequest{
|
||||
BaseURL: "https://x.openai.azure.com", Model: "embed-deploy",
|
||||
ModelType: types.ModelTypeEmbedding,
|
||||
Extra: map[string]string{models.ExtraAPIVersion: "2024-10-21"},
|
||||
})
|
||||
if u != "https://x.openai.azure.com/openai/deployments/embed-deploy/embeddings" {
|
||||
t.Errorf("azure legacy embedding endpoint = %q", u)
|
||||
}
|
||||
if q["api-version"] != "2024-10-21" {
|
||||
t.Errorf("azure legacy embedding api-version = %q", q["api-version"])
|
||||
}
|
||||
|
||||
wk, _ := modelruntime.Get("academycloud")
|
||||
u, _ = wk.Endpoint(providers.EndpointRequest{
|
||||
BaseURL: "https://weknora.weixin.qq.com/", ModelType: types.ModelTypeKnowledgeQA,
|
||||
})
|
||||
if u != "https://weknora.weixin.qq.com/api/v1/chat/completions" {
|
||||
t.Errorf("academycloud endpoint = %q", u)
|
||||
}
|
||||
if wk.Auth != providers.AuthSigned || wk.Signer == nil {
|
||||
t.Error("academycloud should use a signer")
|
||||
}
|
||||
if err := wk.ValidateConfig(&providers.Config{}); err != nil {
|
||||
t.Errorf("academycloud validate should pass without key: %v", err)
|
||||
}
|
||||
|
||||
generic, _ := modelruntime.Get("generic")
|
||||
if err := generic.ValidateConfig(&providers.Config{ModelName: "m"}); err == nil {
|
||||
t.Error("generic validate should require a base URL")
|
||||
}
|
||||
if err := generic.ValidateConfig(&providers.Config{BaseURL: "http://x/v1", ModelName: "m"}); err != nil {
|
||||
t.Errorf("generic validate: %v", err)
|
||||
}
|
||||
gpustack, _ := modelruntime.Get("gpustack")
|
||||
if err := gpustack.ValidateConfig(&providers.Config{APIKey: "k", ModelName: "m"}); err == nil {
|
||||
t.Error("gpustack validate should require a base URL")
|
||||
}
|
||||
|
||||
for _, id := range []string{"volcengine", "lkeap"} {
|
||||
v, _ := modelruntime.Get(id)
|
||||
found := false
|
||||
for _, f := range v.ExtraFields {
|
||||
if f.Key == "secret_key" {
|
||||
found = true
|
||||
if !f.Secret || len(f.ModelTypes) != 1 || f.ModelTypes[0] != types.ModelTypeRerank {
|
||||
t.Errorf("%s secret_key field should be secret and rerank-only", id)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("%s should expose a secret_key extra field", id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestSignedRerankCredentialLabels pins that the two signed rerank vendors
|
||||
// name their first credential after the identity it actually is. The editor
|
||||
// renders this instead of a hardcoded vendor table, so losing it silently
|
||||
// sends operators back to pasting an sk- key into a signature field.
|
||||
func TestSignedRerankCredentialLabels(t *testing.T) {
|
||||
for _, tc := range []struct{ vendor, wantLabel string }{
|
||||
{"lkeap", "SecretId"},
|
||||
{"volcengine", "Access Key ID"},
|
||||
} {
|
||||
t.Run(tc.vendor, func(t *testing.T) {
|
||||
v, ok := modelruntime.Get(tc.vendor)
|
||||
if !ok {
|
||||
t.Fatalf("vendor %s is not registered", tc.vendor)
|
||||
}
|
||||
label := v.CredentialLabelFor(types.ModelTypeRerank)
|
||||
if label == nil {
|
||||
t.Fatalf("rerank should override the credential label")
|
||||
}
|
||||
if label.Label != tc.wantLabel {
|
||||
t.Errorf("rerank credential label = %q, want %q", label.Label, tc.wantLabel)
|
||||
}
|
||||
if label.LocalizedLabel("zh-CN") == label.Label {
|
||||
t.Errorf("zh-CN label should differ from the default")
|
||||
}
|
||||
if label.Hint == "" {
|
||||
t.Errorf("the hint is what stops an sk- key being pasted here")
|
||||
}
|
||||
// Chat and embedding on these vendors do take a plain API key.
|
||||
if other := v.CredentialLabelFor(types.ModelTypeKnowledgeQA); other != nil {
|
||||
t.Errorf("chat should keep the generic API-key wording, got %q", other.Label)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestClaudeNoSamplingRequestBody builds the request body the way NewRemoteChat
|
||||
// does, from the resolved catalog entry. With thinking off, the anthropic
|
||||
// adapter sends top_p when temperature is not supported, so both flags have to
|
||||
// be off for these models to receive neither field.
|
||||
func TestClaudeNoSamplingRequestBody(t *testing.T) {
|
||||
build := func(t *testing.T, model string, effort api.ReasoningEffort) map[string]any {
|
||||
t.Helper()
|
||||
r := resolve(t, "anthropic", model)
|
||||
c := anthropicmessages.New(anthropicmessages.Config{
|
||||
Endpoint: api.Endpoint{Model: r.RemoteModel},
|
||||
Settings: r.AnthropicMessages,
|
||||
ThinkingLevels: r.ThinkingLevels,
|
||||
Reasoning: r.Spec.Reasoning,
|
||||
})
|
||||
body, err := c.BuildRequestBody(
|
||||
[]api.Message{{Role: "user", Content: "Hi"}},
|
||||
&api.Options{Temperature: 1, TopP: 0.9, ReasoningEffort: effort},
|
||||
false,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("build %s: %v", model, err)
|
||||
}
|
||||
return body
|
||||
}
|
||||
|
||||
for _, model := range claudeNoSamplingModels {
|
||||
efforts := []api.ReasoningEffort{""}
|
||||
if r := resolve(t, "anthropic", model); r.ThinkingLevels.Supports(api.ReasoningOff) {
|
||||
efforts = append(efforts, api.ReasoningOff)
|
||||
}
|
||||
for _, effort := range efforts {
|
||||
body := build(t, model, effort)
|
||||
for _, field := range []string{"temperature", "top_p", "top_k"} {
|
||||
if _, ok := body[field]; ok {
|
||||
t.Errorf("anthropic/%s (reasoning %q) sent %s", model, effort, field)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if body := build(t, "claude-sonnet-4-6", api.ReasoningOff); body["temperature"] != 1.0 {
|
||||
t.Errorf("anthropic/claude-sonnet-4-6 should still send temperature, got %v", body["temperature"])
|
||||
}
|
||||
}
|
||||
|
||||
// TestClaude55Models pins how the Claude 5.5 entries turn thinking off and
|
||||
// that none of them receives sampling parameters or budget_tokens: Opus 5.5
|
||||
// cannot turn thinking off, Sonnet 5.5 turns up-front thinking off with
|
||||
// "between_tools" (it rejects "disabled"), and Haiku 5.5 accepts "disabled".
|
||||
func TestClaude55Models(t *testing.T) {
|
||||
build := func(t *testing.T, model string, effort api.ReasoningEffort) map[string]any {
|
||||
t.Helper()
|
||||
r := resolve(t, "anthropic", model)
|
||||
c := anthropicmessages.New(anthropicmessages.Config{
|
||||
Endpoint: api.Endpoint{Model: r.RemoteModel},
|
||||
Settings: r.AnthropicMessages,
|
||||
ThinkingLevels: r.ThinkingLevels,
|
||||
Reasoning: r.Spec.Reasoning,
|
||||
})
|
||||
body, err := c.BuildRequestBody(
|
||||
[]api.Message{{Role: "user", Content: "Hi"}},
|
||||
&api.Options{Temperature: 0.3, TopP: 0.9, ReasoningEffort: effort},
|
||||
false,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("build %s: %v", model, err)
|
||||
}
|
||||
return body
|
||||
}
|
||||
|
||||
offBody := map[string]any{
|
||||
"claude-opus-5-5": nil,
|
||||
"claude-sonnet-5-5": map[string]any{"type": "between_tools"},
|
||||
"claude-haiku-5-5": map[string]any{"type": "disabled"},
|
||||
}
|
||||
for model, wantOff := range offBody {
|
||||
r := resolve(t, "anthropic", model)
|
||||
if !r.Cataloged {
|
||||
t.Fatalf("anthropic/%s should be in the catalog", model)
|
||||
}
|
||||
if r.AnthropicMessages.ThinkingMode != api.AnthropicThinkingAdaptive {
|
||||
t.Errorf("anthropic/%s should use adaptive thinking", model)
|
||||
}
|
||||
if got := r.ThinkingLevels.Supports(api.ReasoningOff); got != (wantOff != nil) {
|
||||
t.Errorf("anthropic/%s supports thinking off = %v", model, got)
|
||||
}
|
||||
for _, level := range []api.ReasoningEffort{api.ReasoningXHigh, api.ReasoningMax} {
|
||||
if !r.ThinkingLevels.Supports(level) {
|
||||
t.Errorf("anthropic/%s should support %s effort", model, level)
|
||||
}
|
||||
}
|
||||
|
||||
for _, effort := range []api.ReasoningEffort{"", api.ReasoningOff, api.ReasoningHigh} {
|
||||
body := build(t, model, effort)
|
||||
for _, field := range []string{"temperature", "top_p", "top_k"} {
|
||||
if _, ok := body[field]; ok {
|
||||
t.Errorf("anthropic/%s (reasoning %q) sent %s", model, effort, field)
|
||||
}
|
||||
}
|
||||
if thinking, ok := body["thinking"].(map[string]any); ok && thinking["type"] == "enabled" {
|
||||
t.Errorf("anthropic/%s (reasoning %q) sent budget thinking", model, effort)
|
||||
}
|
||||
}
|
||||
if wantOff != nil {
|
||||
body := build(t, model, api.ReasoningOff)
|
||||
if fmt.Sprint(body["thinking"]) != fmt.Sprint(wantOff) {
|
||||
t.Errorf("anthropic/%s thinking off sent %v, want %v", model, body["thinking"], wantOff)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
// Package providers registers Baidu AI Cloud Qianfan through its
|
||||
// OpenAI-compatible v2 endpoint.
|
||||
//
|
||||
// Facts (v2 text generation reference
|
||||
// https://cloud.baidu.com/doc/qianfan-api/s/3m7of64lb, auth
|
||||
// https://cloud.baidu.com/doc/qianfan-api/s/ym9chdsy5):
|
||||
// - one host serves every model type: chat is POST /v2/chat/completions,
|
||||
// embeddings POST /v2/embeddings
|
||||
// (https://cloud.baidu.com/doc/qianfan-api/s/Fm7u3ropn) and rerank
|
||||
// POST /v2/rerank, so all model types share the /v2 base URL;
|
||||
// - auth is `Authorization: Bearer <API Key>` and nothing else. The
|
||||
// console-issued `appid` header is optional on v2 and is not a
|
||||
// credential, so the vendor exposes no extra fields;
|
||||
// - both `max_tokens` (final answer only) and `max_completion_tokens`
|
||||
// (answer plus thinking chain) are accepted; we send
|
||||
// max_completion_tokens because it is the one that bounds the whole
|
||||
// generation of a thinking model;
|
||||
// - tool_choice takes none / auto / required / a named function,
|
||||
// parallel_tool_calls defaults to true, response_format takes
|
||||
// text / json_object / json_schema, seed is accepted and
|
||||
// stream_options.include_usage is supported, so every protocol
|
||||
// default holds unchanged;
|
||||
// - usage carries prompt_tokens_details.cached_tokens, so the vendor
|
||||
// does report prompt-cache counters (Baidu documents the counter for
|
||||
// a subset of the ERNIE models only);
|
||||
// - thinking (https://cloud.baidu.com/doc/qianfan-docs/s/Wm95lyynv):
|
||||
// the ERNIE and Qwen3 families switch it with `enable_thinking`
|
||||
// (default false, except ernie-5.0-thinking-preview which defaults to
|
||||
// true), while the DeepSeek / GLM / Kimi routes use
|
||||
// `thinking: {"type": "enabled"|"disabled"}` and carry that as a
|
||||
// per-model compat overlay in models.json. The chain length is capped
|
||||
// by the top-level `thinking_budget` (default 16384, minimum 100).
|
||||
// `reasoning_effort` (high | max) exists only on deepseek-v4-pro and
|
||||
// deepseek-v4-flash, which this catalog does not list, so the vendor
|
||||
// level never sends it.
|
||||
//
|
||||
// Unverified:
|
||||
// - neither a mandatory thinking switch nor a non-stream restriction is
|
||||
// documented, so thinking_always_send and thinking_disable_on_non_stream
|
||||
// stay off;
|
||||
// - prompt_cache_key and Anthropic-style cache_control are not
|
||||
// documented anywhere; only the usage counter above is;
|
||||
// - ernie-x1-turbo-32k no longer appears in the model list
|
||||
// (https://cloud.baidu.com/doc/qianfan-docs/s/7m95lyy43) but no
|
||||
// retirement notice was found, so the entry is kept unchanged,
|
||||
// including its always-on "off": null;
|
||||
// - ernie-4.5-turbo-vl-32k is listed without thinking while the
|
||||
// `-preview` variant of the same family has it, so the entry stays
|
||||
// reasoning: false;
|
||||
// - the DeepSeek routes reject temperature / top_p / presence_penalty /
|
||||
// frequency_penalty *while thinking*, but the docs give no rule for
|
||||
// the non-thinking path, so supports_temperature is left alone;
|
||||
// - Qianfan also exposes a Responses API
|
||||
// (https://cloud.baidu.com/doc/qianfan-docs/s/4mi400l1m); this vendor
|
||||
// stays on Chat Completions, which is what the model pages document.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/qianfan.svg
|
||||
var qianfanIcon []byte
|
||||
|
||||
// QianfanID is the provider identifier stored on model rows.
|
||||
const QianfanID = "qianfan"
|
||||
|
||||
// QianfanBaseURL is the OpenAI-compatible v2 endpoint for every model type.
|
||||
const QianfanBaseURL = "https://qianfan.baidubce.com/v2"
|
||||
|
||||
func newQianfanProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: QianfanID,
|
||||
Name: "Baidu Qianfan",
|
||||
Names: map[string]string{"zh-CN": "百度千帆 Baidu Cloud"},
|
||||
Description: "ernie-5.0-thinking-preview, ernie-4.5-turbo-128k, embedding-v1, bce-reranker-base, etc.",
|
||||
Website: "https://console.bce.baidu.com/qianfan",
|
||||
Icon: qianfanIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 20,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"qianfan.baidubce.com", "baidubce.com"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: QianfanBaseURL,
|
||||
types.ModelTypeEmbedding: QianfanBaseURL,
|
||||
types.ModelTypeRerank: QianfanBaseURL,
|
||||
types.ModelTypeVLLM: QianfanBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeRerank,
|
||||
types.ModelTypeVLLM,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
// https://cloud.baidu.com/doc/qianfan-api/s/Fm7u3ropn: model,
|
||||
// input, user, encoding_format ("当前只支持float"). The model list
|
||||
// (https://cloud.baidu.com/doc/qianfan/s/rmh4stp0j) caps a request
|
||||
// at 16 texts; tao-8k takes one.
|
||||
SendEncodingFormat: api.Ptr(true),
|
||||
MaxBatchSize: api.Ptr(16),
|
||||
},
|
||||
Rerank: api.RerankCompat{
|
||||
// "文本数量不超过64"; query "长度不超过1600个字符"; each document
|
||||
// "长度不超过4096个字符".
|
||||
MaxDocuments: api.Ptr(64),
|
||||
MaxQueryChars: api.Ptr(1600),
|
||||
MaxDocumentChars: api.Ptr(4096),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
// Both spellings are accepted; max_completion_tokens is the
|
||||
// one that also covers the thinking chain.
|
||||
MaxTokensField: api.Ptr("max_completion_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatEnableThinking),
|
||||
ThinkingBudgetField: api.Ptr("thinking_budget"),
|
||||
PromptCacheAccounting: api.Ptr(true),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
// Package providers registers Qiniu Cloud's AI token gateway.
|
||||
//
|
||||
// Facts (parameter reference
|
||||
// https://developer.qiniu.com/aitokenapi/13390/chat-completions, endpoint
|
||||
// https://developer.qiniu.com/aitokenapi/13379/real-time-ai-interface-api,
|
||||
// FAQ https://developer.qiniu.com/aitokenapi/13462/aitoken-use-faq):
|
||||
// - the base URL is the host plus /v1; the FAQ spells it out as
|
||||
// "domain + /v1" and the gateway serves POST /v1/chat/completions,
|
||||
// POST /v1/messages (an Anthropic-compatible surface) and
|
||||
// GET /v1/models. This package speaks Chat Completions, the format the
|
||||
// parameter reference documents;
|
||||
// - auth is `Authorization: Bearer <API Key>`; there are no other
|
||||
// credentials or vendor fields;
|
||||
// - output cap is `max_tokens`; `max_completion_tokens` is not in the
|
||||
// reference;
|
||||
// - thinking is switched with `thinking: {"type": ...}`. The OpenAPI
|
||||
// spec behind https://apidocs.qnaigc.com documents the types
|
||||
// enabled | disabled | auto; this package only ever sends
|
||||
// enabled / disabled, so "auto" is left to callers who set it
|
||||
// themselves;
|
||||
// - `reasoning_effort` is graded, and the same spec lists its values as
|
||||
// minimal | low | medium | high (plus `none`, which the protocol
|
||||
// expresses as thinking.type=disabled). minimal..high therefore pass
|
||||
// through under their own names and xhigh / max clamp down to high,
|
||||
// which is the protocol default, so no vendor level map is needed;
|
||||
// - sampling is the full OpenAI set: temperature 0..2, top_p 0..1,
|
||||
// top_k, presence_penalty / frequency_penalty -2..2,
|
||||
// repetition_penalty 0..2;
|
||||
// - tools, tool_choice (none / auto / required / a named tool) and
|
||||
// response_format are all accepted, so the protocol defaults hold;
|
||||
// - the gateway serves no embedding or rerank models: the FAQ states it
|
||||
// "currently has no text vector or embedding models", which is why
|
||||
// ModelTypes lists chat only.
|
||||
//
|
||||
// unverified: `parallel_tool_calls` and `stream_options.include_usage` do
|
||||
// not appear in the reference; the protocol defaults are kept.
|
||||
//
|
||||
// unverified: no response schema is published, so nothing states whether
|
||||
// usage carries cache counters. prompt_cache_accounting stays off, and
|
||||
// neither prompt_cache_key nor Anthropic-style cache_control is
|
||||
// documented.
|
||||
//
|
||||
// unverified: nothing documents a mandatory thinking switch or a
|
||||
// non-stream restriction, so thinking_always_send and
|
||||
// thinking_disable_on_non_stream stay off.
|
||||
//
|
||||
// unverified: the model catalogue is served dynamically from the model
|
||||
// marketplace rather than published as a list, and /v1/market/models
|
||||
// returned only a subset of the ids below. No retirement notice was found
|
||||
// for any of them, so every entry is kept; models.dev lists no prices for
|
||||
// this gateway, so cost is omitted.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/qiniu.svg
|
||||
var qiniuIcon []byte
|
||||
|
||||
// QiniuID is the provider identifier stored on model rows.
|
||||
const QiniuID = "qiniu"
|
||||
|
||||
// QiniuBaseURL is the OpenAI-compatible chat endpoint.
|
||||
const QiniuBaseURL = "https://api.qnaigc.com/v1"
|
||||
|
||||
func newQiniuProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: QiniuID,
|
||||
Name: "Qiniu Cloud",
|
||||
Names: map[string]string{"zh-CN": "七牛云 Qiniu"},
|
||||
Description: "deepseek/deepseek-v3.2-251201, z-ai/glm-4.7, qwen3.5-397b-a17b, etc.",
|
||||
Website: "https://portal.qiniu.com/ai-inference",
|
||||
Icon: qiniuIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 21,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
// api.modelink.ai is the gateway's documented international host.
|
||||
URLPatterns: []string{"qiniuapi.com", "qiniu", "qnaigc.com", "modelink.ai"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: QiniuBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
MaxTokensField: api.Ptr("max_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatThinkingType),
|
||||
SupportsReasoningEffort: api.Ptr(true),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
// Package providers registers the Requesty router.
|
||||
//
|
||||
// Facts (https://docs.requesty.ai/features/reasoning and
|
||||
// https://docs.requesty.ai/frameworks/openai):
|
||||
// - output cap is `max_tokens`; `max_completion_tokens` appears nowhere in
|
||||
// the documentation;
|
||||
// - thinking is a flat `reasoning_effort` string (there is no
|
||||
// OpenRouter-style reasoning object). Accepted values are
|
||||
// none | min | low | medium | high | xhigh | max, plus a numeric budget
|
||||
// passed as a string. Note the weakest rung is spelled `min`, not
|
||||
// `minimal`, which is what the vendor level map corrects;
|
||||
// - `max` is not the top rung everywhere: "`xhigh` is OpenAI's highest
|
||||
// reasoning effort. It is not the same as `max`. `max` is normalized to
|
||||
// `high` for OpenAI models, whereas `xhigh` is a strictly higher tier."
|
||||
// The OpenAI-routed entries therefore send `xhigh` for both xhigh and
|
||||
// max; Anthropic-routed ones keep `max` as their top rung;
|
||||
// - model ids are always `provider/model`: "To specify a model, you must
|
||||
// include the provider prefix". Every id in the live catalog carries
|
||||
// one, and the bare `model_canonical_name` a record reports is metadata,
|
||||
// not a usable value. The catalog entries below are prefixed
|
||||
// accordingly;
|
||||
// - embeddings and VLM share the https://router.requesty.ai/v1 base; the
|
||||
// Anthropic-style surface is a separate path
|
||||
// (/anthropic/v1/messages) and xhigh is unreachable through it.
|
||||
//
|
||||
// Unverified:
|
||||
// - Requesty warns "Do not hardcode model versions — model availability
|
||||
// changes", and several routes only exist in dated form
|
||||
// (deepseek/deepseek-v4-pro-0813). The undated deepseek-v4-flash has no
|
||||
// first-party route at all, so it is left out rather than guessed;
|
||||
// - gemini-3.8-flash is routed under `vertex/` only; there is no
|
||||
// `google/gemini-3.8-flash`, and the newest `google/` Gemini Flash is
|
||||
// 3.6;
|
||||
// - GET /v1/models is chat-only; embedding models live at
|
||||
// /v1/models/embedding, which the docs do not mention.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/requesty.svg
|
||||
var requestyIcon []byte
|
||||
|
||||
// RequestyID is the provider identifier stored on model rows.
|
||||
const RequestyID = "requesty"
|
||||
|
||||
// RequestyBaseURL is the OpenAI-compatible router endpoint.
|
||||
const RequestyBaseURL = "https://router.requesty.ai/v1"
|
||||
|
||||
func newRequestyProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: RequestyID,
|
||||
Name: "Requesty",
|
||||
Names: map[string]string{"zh-CN": "Requesty"},
|
||||
Description: "openai/gpt-5.5, anthropic/claude-opus-5, google/gemini-3.1-pro-preview, zai/glm-5.2, etc.",
|
||||
Website: "https://requesty.ai",
|
||||
Icon: requestyIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 42,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"router.requesty.ai", "requesty.ai"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: RequestyBaseURL,
|
||||
types.ModelTypeEmbedding: RequestyBaseURL,
|
||||
types.ModelTypeVLLM: RequestyBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeVLLM,
|
||||
types.ModelTypeASR,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
Transcriptions: api.TranscriptionsCompat{
|
||||
// https://docs.requesty.ai/api-reference/endpoint/audio-transcriptions-create:
|
||||
// OpenAI-compatible multipart, json by default, verbose_json
|
||||
// available. "The maximum upload size per request is 32 MB."
|
||||
MaxFileBytes: api.Ptr(32 << 20),
|
||||
// "flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm"; language
|
||||
// is an ISO 639-1 form field.
|
||||
Formats: []string{"flac", "mp3", "mp4", "mpeg", "mpga", "m4a", "ogg", "wav", "webm"},
|
||||
LanguageParam: api.Ptr(api.LanguageForm),
|
||||
},
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
// https://docs.requesty.ai/api-reference/endpoint/embeddings-create:
|
||||
// model, input, encoding_format, dimensions.
|
||||
SendEncodingFormat: api.Ptr(true),
|
||||
DimensionsField: api.Ptr("dimensions"),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
MaxTokensField: api.Ptr("max_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatOpenAI),
|
||||
SupportsReasoningEffort: api.Ptr(true),
|
||||
},
|
||||
},
|
||||
// Requesty spells the weakest rung "min" and accepts the whole
|
||||
// ladder; "off" is the literal "none".
|
||||
ThinkingLevels: api.ThinkingLevelMap{
|
||||
api.ReasoningOff: api.StringPtr("none"),
|
||||
api.ReasoningMinimal: api.StringPtr("min"),
|
||||
api.ReasoningXHigh: api.StringPtr("xhigh"),
|
||||
api.ReasoningMax: api.StringPtr("max"),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
// Package providers registers SiliconFlow (SiliconCloud), an
|
||||
// OpenAI-compatible gateway to open-weight models.
|
||||
//
|
||||
// Facts (https://docs.siliconflow.cn/cn/api-reference/chat-completions/chat-completions):
|
||||
// - output cap is `max_tokens`; `max_completion_tokens` is not documented;
|
||||
// - `enable_thinking` "在推理模式与非推理模式之间切换。该字段适用于大多数推理
|
||||
// 模型", sent as a top-level boolean, together with `thinking_budget`
|
||||
// (128 <= value <= 32768). Both work in streaming and non-streaming
|
||||
// mode and neither is mandatory, so the switch is only sent when the
|
||||
// caller asks for one;
|
||||
// - `reasoning_effort` accepts "high" | "max" and "该字段适用于
|
||||
// Pro/deepseek-ai/DeepSeek-V4、deepseek-ai/DeepSeek-V4-Flash 以及
|
||||
// Pro/zai-org/GLM-5.2", so every other reasoning entry disables it;
|
||||
// - usage reports `prompt_cache_hit_tokens` / `prompt_cache_miss_tokens`,
|
||||
// hence prompt_cache_accounting;
|
||||
// - response_format accepts text (default), json_object and json_schema;
|
||||
// - temperature is [0, 2] (default 0.7) and top_p up to 1, unrestricted;
|
||||
// - one base URL serves chat, embedding, rerank, VLM and ASR, and the only
|
||||
// credential is a bearer API key, so there are no ExtraFields.
|
||||
//
|
||||
// unverified: the reference documents `tools` but not `tool_choice`,
|
||||
// `parallel_tool_calls` or `stream_options`, so the protocol defaults for
|
||||
// those three stand untested;
|
||||
// unverified: `prompt_cache_key` and Anthropic-style cache_control are not
|
||||
// documented, so neither is sent;
|
||||
// unverified: the embedding / rerank / ASR entries (ids, dimensions) come
|
||||
// from the SiliconCloud model pages, and the per-model context windows,
|
||||
// output caps and prices in models.json are not restated in the API
|
||||
// reference.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/siliconflow.svg
|
||||
var siliconflowIcon []byte
|
||||
|
||||
// SiliconflowID is the provider identifier stored on model rows.
|
||||
const SiliconflowID = "siliconflow"
|
||||
|
||||
// SiliconflowBaseURL serves every model type.
|
||||
const SiliconflowBaseURL = "https://api.siliconflow.cn/v1"
|
||||
|
||||
func newSiliconflowProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: SiliconflowID,
|
||||
Name: "SiliconFlow",
|
||||
Names: map[string]string{"zh-CN": "硅基流动 SiliconFlow"},
|
||||
Description: "deepseek-ai/DeepSeek-V4-Pro, zai-org/GLM-5.2, Qwen/Qwen3.5-397B-A17B, BAAI/bge-m3, etc.",
|
||||
Website: "https://cloud.siliconflow.cn",
|
||||
Icon: siliconflowIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 14,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"siliconflow.cn"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: SiliconflowBaseURL,
|
||||
types.ModelTypeEmbedding: SiliconflowBaseURL,
|
||||
types.ModelTypeRerank: SiliconflowBaseURL,
|
||||
types.ModelTypeVLLM: SiliconflowBaseURL,
|
||||
types.ModelTypeASR: SiliconflowBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeRerank,
|
||||
types.ModelTypeVLLM,
|
||||
types.ModelTypeASR,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
Transcriptions: api.TranscriptionsCompat{
|
||||
// https://api-docs.siliconflow.cn/docs/api/audio-transcriptions-post:
|
||||
// file and model only — no response_format — and a file of
|
||||
// "时长不超过 1 小时,文件大小不超过 50MB".
|
||||
MaxFileBytes: api.Ptr(50 << 20),
|
||||
},
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
// https://api-docs.siliconflow.cn/docs/api/embeddings-post: model,
|
||||
// input, encoding_format, and dimensions "仅 Qwen/Qwen3 系列支持"
|
||||
// — the bge-m3 entry turns it off. The input array schema says
|
||||
// "当前最大数组大小为 32" (maxItems 32).
|
||||
SendEncodingFormat: api.Ptr(true),
|
||||
DimensionsField: api.Ptr("dimensions"),
|
||||
MaxBatchSize: api.Ptr(32),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
MaxTokensField: api.Ptr("max_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatEnableThinking),
|
||||
ThinkingBudgetField: api.Ptr("thinking_budget"),
|
||||
SupportsReasoningEffort: api.Ptr(true),
|
||||
PromptCacheAccounting: api.Ptr(true),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
// Package providers registers Volcengine Ark (Doubao) through its
|
||||
// OpenAI-compatible chat endpoint.
|
||||
//
|
||||
// Facts (https://www.volcengine.com/docs/82379/1494384 = Chat API reference,
|
||||
// https://docs.volcengine.com/docs/ark/deep-thinking and
|
||||
// https://docs.volcengine.com/docs/ark/base-url-and-authentication):
|
||||
// - the data-plane base URL is https://ark.cn-beijing.volces.com/api/v3
|
||||
// (chat completions at /chat/completions) with Bearer API-key auth; AK/SK
|
||||
// signing is the alternative and is what the managed rerank service uses;
|
||||
// - output cap stays `max_completion_tokens` ("控制模型输出的最大长度(包括
|
||||
// 模型回答和模型思维链内容长度)"), which is explicitly "不可与
|
||||
// max_tokens 字段同时设置". Its documented range is [1, 65536];
|
||||
// `max_tokens` defaults to 4096 and covers the answer only;
|
||||
// - thinking is switched with `thinking: {"type": ...}` where the type is
|
||||
// enabled | disabled | auto — Ark does accept "auto" ("模型自行判断是否
|
||||
// 需要进行深度思考"), although only doubao-seed-1-6-250615 lists it as
|
||||
// supported today. Every model tagged 深度思考 defaults to enabled;
|
||||
// - `reasoning_effort` takes none | minimal | low | medium | high | xhigh |
|
||||
// max and "所有支持该字段的模型均接受全部 7 档取值"; each model then maps
|
||||
// the rungs it does not implement onto equivalents (Seed 2.x folds
|
||||
// xhigh/max into high, glm-5-3-flash folds them into max, and on most
|
||||
// models `minimal` switches thinking off). The vendor map therefore
|
||||
// passes all seven through verbatim;
|
||||
// - doubao-seed-1-6-flash-250828 and doubao-seed-1-6-vision-250815 are
|
||||
// absent from the reasoning_effort table, so those entries turn it off;
|
||||
// - glm-5-3-flash-260828 "始终启用思考,不再支持禁用思考", so it carries
|
||||
// "off": null;
|
||||
// - temperature is [0, 2] but is "固定为 1,手动指定的参数值将被忽略" on
|
||||
// doubao-seed-2-0-pro-260215 and doubao-seed-2-0-lite-260215;
|
||||
// - tool_choice takes none / auto / required / a named function, and
|
||||
// parallel_tool_calls (default true, false only on doubao-seed-1.6 and
|
||||
// later), response_format (text | json_object | json_schema, beta) and
|
||||
// stream_options.include_usage are all documented, so the protocol
|
||||
// defaults stand. glm-5-2-260617, deepseek-v4-pro-ga-260813 and
|
||||
// deepseek-v4-flash-ga-260731 return streaming usage even without
|
||||
// include_usage;
|
||||
// - usage reports `prompt_tokens_details.cached_tokens` (implicit cache);
|
||||
// explicit prefix / session caching is a separate Context Cache API and
|
||||
// is not driven from here;
|
||||
// - in tool-calling turns Ark also returns `encrypted_content` next to
|
||||
// `reasoning_content` and asks for it to be replayed; omitting it is not
|
||||
// an error but degrades multi-turn agent quality;
|
||||
// - embeddings post to /api/v3/embeddings/multimodal with `dimensions`
|
||||
// defaulting to 2048, and answer one fused vector for the whole input
|
||||
// (https://docs.volcengine.com/docs/ark/multimodal-vectorization-api).
|
||||
// It is the only embedding API the current docs list, and the 向量化 model
|
||||
// list names only the two doubao-embedding-vision snapshots. The text
|
||||
// endpoint, /api/v3/embeddings in the OpenAI shape, now sits under
|
||||
// 下线文档归档 (retired documentation), so doubao-embedding-large-text was
|
||||
// removed from models.json; rows that still name a doubao-embedding text
|
||||
// model are routed to that endpoint by pattern;
|
||||
// - rerank is the VikingDB Knowledge Base service signed with AK/SK at
|
||||
// https://api-knowledgebase.mlp.cn-beijing.volces.com/api/knowledge/service/rerank
|
||||
// (the API key field carries the access key; the secret key, region and
|
||||
// instruction come from the rerank-only extra fields). Documented models
|
||||
// are doubao-seed-rerank and base-multilingual-rerank
|
||||
// (https://www.volcengine.com/docs/84313/1254474). datas takes at most
|
||||
// 200 items, and the default instruction is the console's, verbatim, as
|
||||
// the page asks for results that match the console;
|
||||
// - Ark additionally serves an Anthropic Messages surface at
|
||||
// https://ark.cn-beijing.volces.com/api/compatible/v1 with x-api-key
|
||||
// auth. This package configures OpenAI Chat Completions, which is the
|
||||
// surface every model page documents first.
|
||||
//
|
||||
// unverified: whether the retired text endpoint still answers for accounts
|
||||
// that used it. Rows naming a text model reach it either way; before the
|
||||
// catalog they were sent to the multimodal path.
|
||||
//
|
||||
// unverified: the model list spells lengths as "256k" / "1024k" without
|
||||
// saying whether k is 1000 or 1024, so the context windows in models.json are
|
||||
// left at their present values.
|
||||
//
|
||||
// unverified: prices in models.json come from the Ark pricing console, which
|
||||
// the public docs do not render.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"strings"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/volcengine.svg
|
||||
var volcengineIcon []byte
|
||||
|
||||
// VolcengineID is the provider identifier stored on model rows.
|
||||
const VolcengineID = "volcengine"
|
||||
|
||||
// VolcengineBaseURL is the OpenAI-compatible Ark chat endpoint.
|
||||
const VolcengineBaseURL = "https://ark.cn-beijing.volces.com/api/v3"
|
||||
|
||||
// VolcengineEmbeddingBaseURL is the Ark multimodal embedding endpoint.
|
||||
const VolcengineEmbeddingBaseURL = "https://ark.cn-beijing.volces.com/api/v3/embeddings/multimodal"
|
||||
|
||||
const (
|
||||
volcengineMultimodalEmbeddingPath = "/api/v3/embeddings/multimodal"
|
||||
volcengineTextEmbeddingPath = "/api/v3/embeddings"
|
||||
)
|
||||
|
||||
// VolcengineRerankBaseURL is the Knowledge Base managed rerank endpoint.
|
||||
const VolcengineRerankBaseURL = "https://api-knowledgebase.mlp.cn-beijing.volces.com"
|
||||
|
||||
// VolcengineAnthropicBaseURL is the documented Anthropic Messages surface. It is not
|
||||
// the default for this vendor; operators who want it configure it explicitly.
|
||||
const VolcengineAnthropicBaseURL = "https://ark.cn-beijing.volces.com/api/compatible/v1"
|
||||
|
||||
func newVolcengineProvider() *Definition {
|
||||
rerankOnly := []types.ModelType{types.ModelTypeRerank}
|
||||
return &Definition{
|
||||
ID: VolcengineID,
|
||||
Name: "Volcengine Ark",
|
||||
Names: map[string]string{"zh-CN": "火山引擎 Volcengine"},
|
||||
Description: "doubao-seed-2-1-pro-260628, deepseek-v4-pro-ga-260813, " +
|
||||
"doubao-embedding-vision-250615, doubao-seed-rerank, etc.",
|
||||
Website: "https://console.volcengine.com/ark",
|
||||
Icon: volcengineIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 12,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"volces.com", "volcengine"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: VolcengineBaseURL,
|
||||
types.ModelTypeEmbedding: VolcengineEmbeddingBaseURL,
|
||||
types.ModelTypeRerank: VolcengineRerankBaseURL,
|
||||
types.ModelTypeVLLM: VolcengineBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeRerank,
|
||||
types.ModelTypeVLLM,
|
||||
},
|
||||
// Rerank is signed with an IAM access-key pair, so the first
|
||||
// credential is an Access Key ID rather than an Ark bearer token.
|
||||
CredentialLabels: []CredentialLabel{{
|
||||
Label: "Access Key ID",
|
||||
Labels: map[string]string{"zh-CN": "Access Key ID(AK/SK 签名)"},
|
||||
Placeholder: "Volcengine IAM access key id (AKLT...)",
|
||||
Placeholders: map[string]string{"zh-CN": "火山引擎 IAM Access Key ID(AKLT 开头)"},
|
||||
Hint: "Rerank is signed with an IAM key pair; this is not an Ark API key.",
|
||||
Hints: map[string]string{"zh-CN": "Rerank 使用 IAM 密钥对签名,不是方舟的 API Key。"},
|
||||
ModelTypes: rerankOnly,
|
||||
Required: true,
|
||||
}},
|
||||
ExtraFields: []ExtraField{
|
||||
{
|
||||
Key: "secret_key",
|
||||
Label: "Secret Key",
|
||||
Labels: map[string]string{"zh-CN": "Secret Key(AK/SK 签名)"},
|
||||
Type: "password",
|
||||
Required: true,
|
||||
Placeholder: "Volcengine IAM secret key (the API Key field holds the access key)",
|
||||
Placeholders: map[string]string{
|
||||
"zh-CN": "火山引擎 IAM Secret Access Key(API Key 那一栏填的是 Access Key ID)",
|
||||
},
|
||||
ModelTypes: rerankOnly,
|
||||
Secret: true,
|
||||
},
|
||||
{
|
||||
Key: "region",
|
||||
Label: "Region",
|
||||
Labels: map[string]string{"zh-CN": "地域"},
|
||||
Type: "string",
|
||||
Default: "cn-beijing",
|
||||
Placeholder: "cn-beijing",
|
||||
ModelTypes: rerankOnly,
|
||||
},
|
||||
{
|
||||
Key: "instruction",
|
||||
Label: "Rerank Instruction",
|
||||
Labels: map[string]string{"zh-CN": "重排指令"},
|
||||
Type: "string",
|
||||
Default: "Whether the document answers the query or matches the content retrieval intent",
|
||||
Placeholder: "Instruction passed to the rerank model",
|
||||
Placeholders: map[string]string{
|
||||
"zh-CN": "传给重排模型的 instruction",
|
||||
},
|
||||
ModelTypes: rerankOnly,
|
||||
},
|
||||
},
|
||||
RerankAPI: api.RerankVolcengineKnowledge,
|
||||
EmbeddingAPI: api.EmbeddingArk,
|
||||
// Embedding rows have stored three shapes of base URL: the full
|
||||
// multimodal URL that was the default, .../api/v3 like chat, and the
|
||||
// bare host. All of them name the same service, so the request is
|
||||
// placed from the host.
|
||||
Endpoint: func(r EndpointRequest) (string, map[string]string) {
|
||||
if r.ModelType != types.ModelTypeEmbedding {
|
||||
return "", nil
|
||||
}
|
||||
root := strings.TrimRight(r.BaseURL, "/")
|
||||
if i := strings.Index(root, "/api/"); i >= 0 {
|
||||
root = root[:i]
|
||||
}
|
||||
if r.EmbeddingAPI == api.EmbeddingOpenAI {
|
||||
// The retired doubao-embedding text models, whose archived
|
||||
// reference still names this endpoint.
|
||||
return root + volcengineTextEmbeddingPath, nil
|
||||
}
|
||||
return root + volcengineMultimodalEmbeddingPath, nil
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
// https://docs.volcengine.com/docs/ark/multimodal-vectorization-api:
|
||||
// the only embedding API Ark still lists. It fuses everything in
|
||||
// one request into a single vector, so a request carries one text.
|
||||
// dimensions defaults to 2048 and the current models also serve
|
||||
// 1024; encoding_format defaults to float and the reference's own
|
||||
// curl sends it. `instructions` is documented too and deliberately
|
||||
// not declared: like Jina's task it changes the document vectors
|
||||
// (Tencent/WeKnora#1401).
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
SendEncodingFormat: api.Ptr(true),
|
||||
DimensionsField: api.Ptr("dimensions"),
|
||||
MaxBatchSize: api.Ptr(1),
|
||||
},
|
||||
Rerank: api.RerankCompat{
|
||||
// datas "数组长度不超过 200"
|
||||
// (https://docs.volcengine.com/docs/vector_database_vikingdb/Rerank).
|
||||
// The pre-catalog client split at 50, a constant of its own
|
||||
// rather than a documented ceiling.
|
||||
MaxDocuments: api.Ptr(200),
|
||||
MaxConcurrency: api.Ptr(4),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatThinkingType),
|
||||
SupportsReasoningEffort: api.Ptr(true),
|
||||
PromptCacheAccounting: api.Ptr(true),
|
||||
},
|
||||
},
|
||||
// Ark accepts all seven effort rungs on every model that supports the
|
||||
// field and maps the ones a model does not implement itself, so each
|
||||
// level is passed through under its own name.
|
||||
ThinkingLevels: api.ThinkingLevelMap{
|
||||
api.ReasoningMinimal: api.StringPtr("minimal"),
|
||||
api.ReasoningLow: api.StringPtr("low"),
|
||||
api.ReasoningMedium: api.StringPtr("medium"),
|
||||
api.ReasoningHigh: api.StringPtr("high"),
|
||||
api.ReasoningXHigh: api.StringPtr("xhigh"),
|
||||
api.ReasoningMax: api.StringPtr("max"),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// Package providers registers Zhipu AI's BigModel open platform.
|
||||
//
|
||||
// Facts (https://docs.bigmodel.cn/api-reference/模型-api/对话补全):
|
||||
// - chat completions live at POST /paas/v4/chat/completions under
|
||||
// https://open.bigmodel.cn/api, so the base URL is
|
||||
// https://open.bigmodel.cn/api/paas/v4;
|
||||
// - output cap is `max_tokens`; the reference lists no
|
||||
// `max_completion_tokens`. GLM-5.3 / 5.2 / 5.1 / 5 / 4.7 / 4.6 cap at
|
||||
// 128K output, the GLM-4.5 series at 96K;
|
||||
// - thinking is switched with `thinking: {"type": "enabled"|"disabled"}`
|
||||
// (default enabled, GLM-4.5 and later only). The sibling
|
||||
// `clear_thinking` defaults to true, i.e. the platform strips
|
||||
// `reasoning_content` from previous turns unless it is set to false, so
|
||||
// replaying it is accepted but normally a no-op;
|
||||
// - `reasoning_effort` takes none | minimal | low | medium | high | xhigh |
|
||||
// max, defaults to max, and is only honoured by "GLM-5.2 及其以上模型" —
|
||||
// GLM-5.1, GLM-5, GLM-4.7, GLM-4.6 and GLM-4.5 ignore it, so those
|
||||
// entries turn it off. The vendor-level map spells every rung, including
|
||||
// off -> "none";
|
||||
// - per-model effort ladders narrow that set: GLM-5.3 and GLM-5.3-Flash
|
||||
// only take low / high / max, and GLM-5.2 maps none|minimal to "no
|
||||
// thinking", low|medium to high and xhigh to max. That folding is the
|
||||
// platform's own, so GLM-5.2 keeps sending "minimal" and "low"
|
||||
// verbatim: rewriting minimal to "low" here would turn the weakest rung
|
||||
// into the strongest one, because the platform then folds it to high;
|
||||
// - GLM-5.3 and GLM-5.3-Flash/FlashX always think: `thinking.type` "限制只
|
||||
// 能开启", so both carry "off": null
|
||||
// (https://docs.bigmodel.cn/cn/guide/models/text/glm-5.3,
|
||||
// https://docs.bigmodel.cn/cn/guide/models/vlm/glm-5.3-flash);
|
||||
// - `tool_choice` is documented as "默认 auto 且仅支持 auto", so none /
|
||||
// required / named-function are never sent;
|
||||
// - `response_format` takes text | json_object (no json_schema);
|
||||
// temperature is [0.0, 1.0] and top_p is [0.01, 1.0], both two decimals;
|
||||
// - usage reports `prompt_tokens_details.cached_tokens`;
|
||||
// - the platform also exposes an Anthropic Messages facade at
|
||||
// https://open.bigmodel.cn/api/anthropic (/v1/messages under it), which
|
||||
// Resolve switches to when the base URL ends with /anthropic;
|
||||
// - embeddings: embedding-3 defaults to 2048 dimensions (256 / 512 / 1024 /
|
||||
// 2048 selectable), embedding-2 is fixed at 1024;
|
||||
// - rerank is POST https://open.bigmodel.cn/api/paas/v4/rerank with model
|
||||
// id "rerank".
|
||||
//
|
||||
// unverified: the reference does not document `stream_options`,
|
||||
// `parallel_tool_calls` or `seed`; the protocol defaults (include_usage sent,
|
||||
// parallel tool calls and seed allowed) are kept because nothing states they
|
||||
// are rejected.
|
||||
//
|
||||
// unverified: glm-5v-turbo is a vision model and the "GLM-5.2 及其以上" rule
|
||||
// does not name it, so its supports_reasoning_effort:false is kept as-is.
|
||||
//
|
||||
// unverified: context windows, max output tokens and prices of individual
|
||||
// entries beyond the GLM-5 / 5.2 / 5.3 / 4.7 model pages, and the
|
||||
// glm-4.7-flash zero price.
|
||||
package providers
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"academy/internal/models/api"
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
//go:embed assets/zhipu.svg
|
||||
var zhipuIcon []byte
|
||||
|
||||
// ZhipuID is the provider identifier stored on model rows.
|
||||
const ZhipuID = "zhipu"
|
||||
|
||||
// ZhipuBaseURL is the OpenAI-compatible chat / embedding endpoint.
|
||||
const ZhipuBaseURL = "https://open.bigmodel.cn/api/paas/v4"
|
||||
|
||||
// ZhipuRerankBaseURL is the rerank endpoint.
|
||||
const ZhipuRerankBaseURL = "https://open.bigmodel.cn/api/paas/v4/rerank"
|
||||
|
||||
// ZhipuAnthropicBaseURL is the Anthropic Messages compatibility facade.
|
||||
const ZhipuAnthropicBaseURL = "https://open.bigmodel.cn/api/anthropic"
|
||||
|
||||
func newZhipuProvider() *Definition {
|
||||
return &Definition{
|
||||
ID: ZhipuID,
|
||||
Name: "Zhipu BigModel",
|
||||
Names: map[string]string{"zh-CN": "智谱 BigModel"},
|
||||
Description: "glm-5.3, glm-5.2, glm-4.7, embedding-3, rerank; " +
|
||||
"Anthropic-compatible facade at " + ZhipuAnthropicBaseURL,
|
||||
Descriptions: map[string]string{
|
||||
"zh-CN": "glm-5.3, glm-5.2, glm-4.7, embedding-3, rerank;Anthropic 兼容接口 " + ZhipuAnthropicBaseURL,
|
||||
},
|
||||
Website: "https://open.bigmodel.cn",
|
||||
Icon: zhipuIcon,
|
||||
API: api.APIOpenAICompletions,
|
||||
Order: 11,
|
||||
RequiresAuth: true,
|
||||
Auth: AuthBearer,
|
||||
URLPatterns: []string{"open.bigmodel.cn", "zhipu"},
|
||||
DefaultBaseURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: ZhipuBaseURL,
|
||||
types.ModelTypeEmbedding: ZhipuBaseURL,
|
||||
types.ModelTypeRerank: ZhipuRerankBaseURL,
|
||||
types.ModelTypeVLLM: ZhipuBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeRerank,
|
||||
types.ModelTypeVLLM,
|
||||
types.ModelTypeASR,
|
||||
},
|
||||
Compat: VendorCompat{
|
||||
Transcriptions: api.TranscriptionsCompat{
|
||||
// https://docs.bigmodel.cn/api-reference/模型-api/语音转文本:
|
||||
// POST {base}/audio/transcriptions, multipart file + model
|
||||
// (glm-asr-2512), answering {text}. The file is ".wav / .mp3",
|
||||
// at most 25 MB and 30 seconds — the duration cannot be checked
|
||||
// here without decoding, so a longer file is the vendor's error.
|
||||
MaxFileBytes: api.Ptr(25 << 20),
|
||||
// No language field; prompt and hotwords are its only hints.
|
||||
Formats: []string{"wav", "mp3"},
|
||||
},
|
||||
Embeddings: api.EmbeddingsCompat{
|
||||
// https://docs.bigmodel.cn/api-reference/模型-api/文本嵌入: model,
|
||||
// input, dimensions — no encoding_format. embedding-2 is fixed at
|
||||
// 1024 and its entry turns dimensions off; embedding-3 takes at
|
||||
// most 64 inputs per request.
|
||||
DimensionsField: api.Ptr("dimensions"),
|
||||
},
|
||||
Rerank: api.RerankCompat{
|
||||
// The reference gives 最大长度为 4096 字符 for the query and for each
|
||||
// document, and caps documents at 128 per request.
|
||||
SendReturnDocs: api.Ptr(true),
|
||||
MaxDocuments: api.Ptr(128),
|
||||
MaxQueryChars: api.Ptr(4096),
|
||||
MaxDocumentChars: api.Ptr(4096),
|
||||
},
|
||||
OpenAICompletions: api.OpenAICompletionsCompat{
|
||||
MaxTokensField: api.Ptr("max_tokens"),
|
||||
ThinkingFormat: api.Ptr(api.ThinkingFormatThinkingType),
|
||||
SupportsReasoningEffort: api.Ptr(true),
|
||||
PromptCacheAccounting: api.Ptr(true),
|
||||
// "默认 auto 且仅支持 auto": none / required / named function
|
||||
// are rejected.
|
||||
ToolChoiceModes: []string{"auto"},
|
||||
},
|
||||
},
|
||||
ThinkingLevels: api.ThinkingLevelMap{
|
||||
api.ReasoningOff: api.StringPtr("none"),
|
||||
api.ReasoningMinimal: api.StringPtr("minimal"),
|
||||
api.ReasoningLow: api.StringPtr("low"),
|
||||
api.ReasoningMedium: api.StringPtr("medium"),
|
||||
api.ReasoningHigh: api.StringPtr("high"),
|
||||
api.ReasoningXHigh: api.StringPtr("xhigh"),
|
||||
api.ReasoningMax: api.StringPtr("max"),
|
||||
},
|
||||
}
|
||||
}
|
||||