Files
ai_academy/internal/models/providers/modelscope.go
T
runny 9058149576
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s
refactor: 项目更名 WeKnora → Academy
- 全量替换代码/配置/文档中的项目名(保留上游 GitHub 链接、weixin 文档域名、Docker Hub 镜像名)
- 重命名 32 个含项目名的文件/目录;Go module 路径改为 academy(含 client/cli 子模块)
- docreader proto 描述符采用等长替换,保持序列化字节布局有效
- Dockerfile.app 构建网络修复: browserskill 离线产物通道、PyPI/apt 国内镜像
- 运行验证: go build ✓ docker compose up ✓ 健康检查 ✓
2026-11-13 20:52:51 +08:00

86 lines
3.7 KiB
Go

// 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),
},
},
}
}