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
- 全量替换代码/配置/文档中的项目名(保留上游 GitHub 链接、weixin 文档域名、Docker Hub 镜像名) - 重命名 32 个含项目名的文件/目录;Go module 路径改为 academy(含 client/cli 子模块) - docreader proto 描述符采用等长替换,保持序列化字节布局有效 - Dockerfile.app 构建网络修复: browserskill 离线产物通道、PyPI/apt 国内镜像 - 运行验证: go build ✓ docker compose up ✓ 健康检查 ✓
108 lines
5.0 KiB
Go
108 lines
5.0 KiB
Go
// 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"},
|
|
},
|
|
},
|
|
}
|
|
}
|