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

96 lines
3.9 KiB
Go

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