Files
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

151 lines
6.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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),
},
},
}
}