From 37b2899f9d73e295ffbb0a18b81e858741e2bedf Mon Sep 17 00:00:00 2001 From: nullkey Date: Thu, 8 Jan 2026 16:13:52 +0800 Subject: [PATCH] feat:add several mainstream model providers --- docs/BUILTIN_MODELS.md | 2 +- docs/api/model.md | 47 ++++++++------ frontend/src/i18n/locales/en-US.ts | 28 +++++++-- frontend/src/i18n/locales/ko-KR.ts | 87 +++++++++++++++++++++++++- frontend/src/i18n/locales/ru-RU.ts | 28 +++++++-- frontend/src/i18n/locales/zh-CN.ts | 52 ++++++++++----- internal/models/provider/generic.go | 4 +- internal/models/provider/gpustack.go | 8 +-- internal/models/provider/longcat.go | 48 ++++++++++++++ internal/models/provider/modelscope.go | 53 ++++++++++++++++ internal/models/provider/moonshot.go | 50 +++++++++++++++ internal/models/provider/provider.go | 25 ++++++++ internal/models/provider/qianfan.go | 54 ++++++++++++++++ internal/models/provider/qiniu.go | 49 +++++++++++++++ 14 files changed, 481 insertions(+), 54 deletions(-) create mode 100644 internal/models/provider/longcat.go create mode 100644 internal/models/provider/modelscope.go create mode 100644 internal/models/provider/moonshot.go create mode 100644 internal/models/provider/qianfan.go create mode 100644 internal/models/provider/qiniu.go diff --git a/docs/BUILTIN_MODELS.md b/docs/BUILTIN_MODELS.md index c1886a2b..38f92019 100644 --- a/docs/BUILTIN_MODELS.md +++ b/docs/BUILTIN_MODELS.md @@ -24,7 +24,7 @@ - 模型参数(parameters):包括 base_url、api_key、provider 等 - 租户ID(tenant_id):建议使用小于10000的租户ID,避免冲突 -**支持的服务商(provider)**:`generic`(自定义)、`openai`、`aliyun`、`zhipu`、`volcengine`、`hunyuan`、`deepseek`、`minimax`、`mimo`、`siliconflow`、`jina`、`openrouter`、`gemini` +**支持的服务商(provider)**:`generic`(自定义)、`openai`、`aliyun`、`zhipu`、`volcengine`、`hunyuan`、`deepseek`、`minimax`、`mimo`、`siliconflow`、`jina`、`openrouter`、`gemini`、`modelscope`、`moonshot`、`qianfan`、`qiniu`、`longcat`、`gpustack` ### 2. 执行 SQL 插入语句 diff --git a/docs/api/model.md b/docs/api/model.md index 66dbb546..b5ab8e1d 100644 --- a/docs/api/model.md +++ b/docs/api/model.md @@ -17,21 +17,27 @@ WeKnora 支持多种主流 AI 模型服务商,在创建模型时可通过 `pro ### 支持的服务商列表 -| 服务商标识 | 名称 | 支持的模型类型 | -| -------------- | ------------------ | ------------------------------- | -| `generic` | 自定义API OpenAI 兼容 | Chat, Embedding, Rerank, VLLM | -| `aliyun` | 阿里云 DashScope | Chat, Embedding, Rerank, VLLM | -| `zhipu` | 智谱 AI | Chat, Embedding, Rerank, VLLM | -| `volcengine` | 火山引擎 | Chat, Embedding, VLLM | -| `hunyuan` | 腾讯混元 | Chat, Embedding, VLLM | -| `deepseek` | DeepSeek | Chat | -| `minimax` | MiniMax | Chat, Embedding, VLLM | -| `mimo` | 小米 Mimo | Chat | -| `siliconflow` | 硅基流动 | Chat, Embedding, Rerank | -| `jina` | Jina AI | Embedding, Rerank | -| `openrouter` | OpenRouter | Chat | -| `openai` | OpenAI | Chat, Embedding, VLLM | -| `gemini` | Google Gemini | Chat, Embedding, VLLM | +| 服务商标识 | 名称 | 支持的模型类型 | +| -------------- | ---------------------------- | ------------------------------- | +| `generic` | 自定义 (OpenAI兼容接口) | Chat, Embedding, Rerank, VLLM | +| `openai` | OpenAI | Chat, Embedding, Rerank, VLLM | +| `aliyun` | 阿里云 DashScope | Chat, Embedding, Rerank, VLLM | +| `zhipu` | 智谱 BigModel | Chat, Embedding, Rerank, VLLM | +| `volcengine` | 火山引擎 Volcengine | Chat, Embedding, VLLM | +| `hunyuan` | 腾讯混元 Hunyuan | Chat, Embedding | +| `deepseek` | DeepSeek | Chat | +| `minimax` | MiniMax | Chat | +| `mimo` | 小米 MiMo | Chat | +| `siliconflow` | 硅基流动 SiliconFlow | Chat, Embedding, Rerank, VLLM | +| `jina` | Jina | Embedding, Rerank | +| `openrouter` | OpenRouter | Chat, VLLM | +| `gemini` | Google Gemini | Chat | +| `modelscope` | 魔搭 ModelScope | Chat, Embedding, VLLM | +| `moonshot` | 月之暗面 Moonshot | Chat, VLLM | +| `qianfan` | 百度千帆 Baidu Cloud | Chat, Embedding, Rerank, VLLM | +| `qiniu` | 七牛云 Qiniu | Chat | +| `longcat` | LongCat AI | Chat | +| `gpustack` | GPUStack | Chat, Embedding, Rerank, VLLM | ## GET `/models/providers` - 获取模型服务商列表 @@ -64,7 +70,7 @@ curl --location 'http://localhost:8080/api/v1/models/providers?model_type=embedd { "value": "aliyun", "label": "阿里云 DashScope", - "description": "阿里云百炼大模型服务", + "description": "qwen-plus, tongyi-embedding-vision-plus, qwen3-rerank, etc.", "defaultUrls": { "chat": "https://dashscope.aliyuncs.com/compatible-mode/v1", "embedding": "https://dashscope.aliyuncs.com/compatible-mode/v1", @@ -74,13 +80,14 @@ curl --location 'http://localhost:8080/api/v1/models/providers?model_type=embedd }, { "value": "zhipu", - "label": "智谱 AI", - "description": "智谱清言大模型", + "label": "智谱 BigModel", + "description": "glm-4.7, embedding-3, rerank, etc.", "defaultUrls": { "chat": "https://open.bigmodel.cn/api/paas/v4", - "embedding": "https://open.bigmodel.cn/api/paas/v4/embeddings" + "embedding": "https://open.bigmodel.cn/api/paas/v4/embeddings", + "rerank": "https://open.bigmodel.cn/api/paas/v4/rerank" }, - "modelTypes": ["chat", "embedding", "vllm"] + "modelTypes": ["chat", "embedding", "rerank", "vllm"] } ] } diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index d6bb0bf5..fbd6f916 100755 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -1654,7 +1654,7 @@ export default { description: 'qwen-plus, tongyi-embedding-vision-plus, qwen3-rerank, etc.', }, zhipu: { - label: 'Zhipu AI', + label: 'Zhipu BigModel', description: 'glm-4.7, embedding-3, rerank, etc.', }, openrouter: { @@ -1662,7 +1662,7 @@ export default { description: 'openai/gpt-5.2-chat, google/gemini-3-flash-preview, etc.', }, generic: { - label: 'Custom API', + label: 'Custom (OpenAI-compatible)', description: 'Generic API endpoint', }, siliconflow: { @@ -1670,7 +1670,7 @@ export default { description: 'deepseek-ai/DeepSeek-V3.1, etc.', }, jina: { - label: 'Jina AI', + label: 'Jina', description: 'jina-clip-v1, jina-embeddings-v2-base-zh, etc.', }, volcengine: { @@ -1699,7 +1699,27 @@ export default { }, gpustack: { label: 'GPUStack', - description: 'Self-hosted GPU cluster platform, OpenAI-compatible API', + description: 'Choose your deployed model on GPUStack', + }, + modelscope: { + label: 'ModelScope', + description: 'Qwen/Qwen3-8B, Qwen/Qwen3-Embedding-8B, etc.', + }, + qiniu: { + label: 'Qiniu Cloud', + description: 'deepseek/deepseek-v3.2-251201, z-ai/glm-4.7, etc.', + }, + moonshot: { + label: 'Moonshot', + description: 'kimi-k2-turbo-preview, moonshot-v1-8k-vision-preview, etc.', + }, + qianfan: { + label: 'Baidu Qianfan', + description: 'ernie-5.0-thinking-preview, embedding-v1, bce-reranker-base, etc.', + }, + longcat: { + label: 'LongCat AI', + description: 'LongCat-Flash-Chat, LongCat-Flash-Thinking, etc.', }, }, } diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts index 5dbec7bf..64d7a5c3 100755 --- a/frontend/src/i18n/locales/ko-KR.ts +++ b/frontend/src/i18n/locales/ko-KR.ts @@ -983,6 +983,87 @@ export default { baseUrlEmpty: "Base URL은 비워둘 수 없습니다", baseUrlInvalid: "Base URL 형식이 올바르지 않습니다. 유효한 URL을 입력해주세요", }, + // Provider related translations + providerLabel: "제공업체", + providerPlaceholder: "모델 제공업체 선택", + providers: { + openai: { + label: "OpenAI", + description: "gpt-5.2, gpt-5-mini 등", + }, + aliyun: { + label: "Aliyun DashScope", + description: "qwen-plus, tongyi-embedding-vision-plus, qwen3-rerank 등", + }, + zhipu: { + label: "Zhipu BigModel", + description: "glm-4.7, embedding-3, rerank, etc.", + }, + openrouter: { + label: "OpenRouter", + description: "openai/gpt-5.2-chat, google/gemini-3-flash-preview 등", + }, + generic: { + label: "사용자 정의 (OpenAI 호환)", + description: "Generic API endpoint", + }, + siliconflow: { + label: "SiliconFlow", + description: "deepseek-ai/DeepSeek-V3.1 등", + }, + jina: { + label: "Jina", + description: "jina-clip-v1, jina-embeddings-v2-base-zh, etc.", + }, + volcengine: { + label: "Volcengine", + description: "doubao-1-5-pro-32k-250115, doubao-embedding-vision-250615 등", + }, + deepseek: { + label: "DeepSeek", + description: "deepseek-chat, deepseek-reasoner 등", + }, + hunyuan: { + label: "Hunyuan", + description: "hunyuan-pro, hunyuan-standard, hunyuan-embedding 등", + }, + minimax: { + label: "MiniMax", + description: "MiniMax-M2.1, MiniMax-M2.1-lightning 등", + }, + mimo: { + label: "MiMo", + description: "mimo-v2-flash", + }, + gemini: { + label: "Google Gemini", + description: "gemini-3-flash-preview, gemini-2.5-pro 등", + }, + gpustack: { + label: "GPUStack", + description: "Choose your deployed model on GPUStack", + }, + modelscope: { + label: "ModelScope", + description: "Qwen/Qwen3-8B, Qwen/Qwen3-Embedding-8B, etc.", + }, + qiniu: { + label: "Qiniu Cloud", + description: "deepseek/deepseek-v3.2-251201, z-ai/glm-4.7, etc.", + }, + moonshot: { + label: "Moonshot", + description: "kimi-k2-turbo-preview, moonshot-v1-8k-vision-preview, etc.", + }, + qianfan: { + label: "Baidu Qianfan", + description: "ernie-5.0-thinking-preview, embedding-v1, bce-reranker-base, etc.", + }, + longcat: { + label: "LongCat AI", + description: "LongCat-Flash-Chat, LongCat-Flash-Thinking, etc.", + }, + }, }, }, language: { @@ -1155,9 +1236,9 @@ export default { messages: { deleted: "삭제됨", deleteFailed: "삭제 실패", - file: "파일", - knowledgeBase: "지식베이스", - noResult: "결과 없음", + file: "파일", + knowledgeBase: "지식베이스", + noResult: "결과 없음", }, features: { knowledgeGraph: "지식 그래프 활성화됨", diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index 3af1d433..f7c48eb8 100755 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -904,7 +904,7 @@ export default { description: 'qwen-plus, tongyi-embedding-vision-plus, qwen3-rerank, etc.', }, zhipu: { - label: 'Zhipu AI', + label: 'Zhipu BigModel', description: 'glm-4.7, embedding-3, rerank, etc.', }, openrouter: { @@ -912,7 +912,7 @@ export default { description: 'openai/gpt-5.2-chat, google/gemini-3-flash-preview, etc.', }, generic: { - label: 'Пользовательский API', + label: 'Пользовательский (OpenAI-совместимый)', description: 'Generic API endpoint', }, siliconflow: { @@ -920,7 +920,7 @@ export default { description: 'deepseek-ai/DeepSeek-V3.1, etc.', }, jina: { - label: 'Jina AI', + label: 'Jina', description: 'jina-clip-v1, jina-embeddings-v2-base-zh, etc.', }, volcengine: { @@ -949,7 +949,27 @@ export default { }, gpustack: { label: 'GPUStack', - description: 'Приватная платформа GPU-кластеров, OpenAI-совместимый API', + description: 'Choose your deployed model on GPUStack', + }, + modelscope: { + label: 'ModelScope', + description: 'Qwen/Qwen3-8B, Qwen/Qwen3-Embedding-8B, etc.', + }, + qiniu: { + label: 'Qiniu Cloud', + description: 'deepseek/deepseek-v3.2-251201, z-ai/glm-4.7, etc.', + }, + moonshot: { + label: 'Moonshot', + description: 'kimi-k2-turbo-preview, moonshot-v1-8k-vision-preview, etc.', + }, + qianfan: { + label: 'Baidu Qianfan', + description: 'ernie-5.0-thinking-preview, embedding-v1, bce-reranker-base, etc.', + }, + longcat: { + label: 'LongCat AI', + description: 'LongCat-Flash-Chat, LongCat-Flash-Thinking, etc.', }, }, } diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index 10021481..09d42019 100755 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -1181,43 +1181,43 @@ export default { providers: { openai: { label: "OpenAI", - description: "OpenAI 官方 API", + description: "gpt-5.2, gpt-5-mini, etc.", }, aliyun: { label: "阿里云 DashScope", - description: "支持 Qwen、DeepSeek 等模型", + description: "qwen-plus, tongyi-embedding-vision-plus, qwen3-rerank, etc.", }, zhipu: { - label: "智谱 AI", - description: "支持 GLM-4 系列模型", + label: "智谱 BigModel", + description: "glm-4.7, embedding-3, rerank, etc.", }, openrouter: { label: "OpenRouter", - description: "多模型聚合平台", + description: "openai/gpt-5.2-chat, google/gemini-3-flash-preview, etc.", }, generic: { - label: "自定义 API", - description: "OpenAI 兼容的自定义端点", + label: "自定义 (OpenAI兼容接口)", + description: "Generic API endpoint (OpenAI-compatible)", }, siliconflow: { - label: "SiliconFlow", - description: "硅基流动,支持多种模型", + label: "硅基流动 SiliconFlow", + description: "deepseek-ai/DeepSeek-V3.1, etc.", }, jina: { - label: "Jina AI", - description: "专注于 Embedding 和 Rerank", + label: "Jina", + description: "jina-clip-v1, jina-embeddings-v2-base-zh, etc.", }, volcengine: { - label: "火山引擎", - description: "doubao-1-5-pro-32k, doubao-embedding-vision 等", + label: "火山引擎 Volcengine", + description: "doubao-1-5-pro-32k-250115, doubao-embedding-vision-250615, etc.", }, deepseek: { label: "DeepSeek", description: "deepseek-chat, deepseek-reasoner 等", }, hunyuan: { - label: "腾讯混元", - description: "hunyuan-pro, hunyuan-standard, hunyuan-embedding 等", + label: "腾讯混元 Hunyuan", + description: "hunyuan-pro, hunyuan-standard, hunyuan-embedding, etc.", }, minimax: { label: "MiniMax", @@ -1233,7 +1233,27 @@ export default { }, gpustack: { label: "GPUStack", - description: "私有化 GPU 集群部署平台,OpenAI 兼容 API", + description: "Choose your deployed model on GPUStack", + }, + modelscope: { + label: "魔搭 ModelScope", + description: "Qwen/Qwen3-8B, Qwen/Qwen3-Embedding-8B, etc.", + }, + qiniu: { + label: "七牛云 Qiniu", + description: "deepseek/deepseek-v3.2-251201, z-ai/glm-4.7, etc.", + }, + moonshot: { + label: "月之暗面 Moonshot", + description: "kimi-k2-turbo-preview, moonshot-v1-8k-vision-preview, etc.", + }, + qianfan: { + label: "百度千帆 Baidu Cloud", + description: "ernie-5.0-thinking-preview, embedding-v1, bce-reranker-base, etc.", + }, + longcat: { + label: "LongCat AI", + description: "LongCat-Flash-Chat, LongCat-Flash-Thinking, etc.", }, }, }, diff --git a/internal/models/provider/generic.go b/internal/models/provider/generic.go index f0ccd9a7..fe8aa862 100644 --- a/internal/models/provider/generic.go +++ b/internal/models/provider/generic.go @@ -17,8 +17,8 @@ func init() { func (p *GenericProvider) Info() ProviderInfo { return ProviderInfo{ Name: ProviderGeneric, - DisplayName: "自定义 (OpenAI格式兼容接口)", - Description: "Generic API endpoint", + DisplayName: "自定义 (OpenAI兼容接口)", + Description: "Generic API endpoint (OpenAI-compatible)", DefaultURLs: map[types.ModelType]string{}, // 需要用户自行配置填写 ModelTypes: []types.ModelType{ types.ModelTypeKnowledgeQA, diff --git a/internal/models/provider/gpustack.go b/internal/models/provider/gpustack.go index 9bbfc7e7..686b3516 100644 --- a/internal/models/provider/gpustack.go +++ b/internal/models/provider/gpustack.go @@ -8,9 +8,9 @@ import ( const ( // GPUStackBaseURL GPUStack API BaseURL (OpenAI 兼容模式) - GPUStackBaseURL = "http://your_gpustack_server_url/v1-openai" - GPUStackEmbeddingBaseURL = "http://your_gpustack_server_url/v1-openai/embeddings" - GPUStackRerankBaseURL = "http://your_gpustack_server_url/v1/rerank" + GPUStackBaseURL = "http://your_gpustack_server_url/v1-openai" + // GPUStackRerankBaseURL GPUStack Rerank API 虽然兼容OpenAI,但路径不同 (/v1/rerank 而非 /v1-openai/rerank) + GPUStackRerankBaseURL = "http://your_gpustack_server_url/v1" ) // GPUStackProvider 实现 GPUStack 的 Provider 接口 @@ -28,7 +28,7 @@ func (p *GPUStackProvider) Info() ProviderInfo { Description: "Choose your deployed model on GPUStack", DefaultURLs: map[types.ModelType]string{ types.ModelTypeKnowledgeQA: GPUStackBaseURL, - types.ModelTypeEmbedding: GPUStackEmbeddingBaseURL, + types.ModelTypeEmbedding: GPUStackBaseURL, types.ModelTypeRerank: GPUStackRerankBaseURL, types.ModelTypeVLLM: GPUStackBaseURL, }, diff --git a/internal/models/provider/longcat.go b/internal/models/provider/longcat.go new file mode 100644 index 00000000..0273463a --- /dev/null +++ b/internal/models/provider/longcat.go @@ -0,0 +1,48 @@ +package provider + +import ( + "fmt" + + "github.com/Tencent/WeKnora/internal/types" +) + +const ( + LongCatBaseURL = "https://api.longcat.chat/openai/v1" +) + +// LongCatProvider 实现 LongCat AI 的 Provider 接口 +type LongCatProvider struct{} + +func init() { + Register(&LongCatProvider{}) +} + +// Info 返回 LongCat provider 的元数据 +func (p *LongCatProvider) Info() ProviderInfo { + return ProviderInfo{ + Name: ProviderLongCat, + DisplayName: "LongCat AI", + Description: "LongCat-Flash-Chat, LongCat-Flash-Thinking, etc.", + DefaultURLs: map[types.ModelType]string{ + types.ModelTypeKnowledgeQA: LongCatBaseURL, + }, + ModelTypes: []types.ModelType{ + types.ModelTypeKnowledgeQA, + }, + RequiresAuth: true, + } +} + +// ValidateConfig 验证 LongCat provider 配置 +func (p *LongCatProvider) ValidateConfig(config *Config) error { + if config.BaseURL == "" { + return fmt.Errorf("base URL is required for LongCat provider") + } + if config.APIKey == "" { + return fmt.Errorf("API key is required for LongCat provider") + } + if config.ModelName == "" { + return fmt.Errorf("model name is required") + } + return nil +} diff --git a/internal/models/provider/modelscope.go b/internal/models/provider/modelscope.go new file mode 100644 index 00000000..aaa40709 --- /dev/null +++ b/internal/models/provider/modelscope.go @@ -0,0 +1,53 @@ +package provider + +import ( + "fmt" + + "github.com/Tencent/WeKnora/internal/types" +) + +const ( + // ModelScopeBaseURL ModelScope API BaseURL (OpenAI 兼容模式) + ModelScopeBaseURL = "https://api-inference.modelscope.cn/v1" +) + +// ModelScopeProvider 实现 ModelScope (魔搭) 的 Provider 接口 +type ModelScopeProvider struct{} + +func init() { + Register(&ModelScopeProvider{}) +} + +// Info 返回 ModelScope provider 的元数据 +func (p *ModelScopeProvider) Info() ProviderInfo { + return ProviderInfo{ + Name: ProviderModelScope, + DisplayName: "魔搭 ModelScope", + Description: "Qwen/Qwen3-8B, Qwen/Qwen3-Embedding-8B, etc.", + DefaultURLs: map[types.ModelType]string{ + types.ModelTypeKnowledgeQA: ModelScopeBaseURL, + types.ModelTypeEmbedding: ModelScopeBaseURL, + types.ModelTypeVLLM: ModelScopeBaseURL, + }, + ModelTypes: []types.ModelType{ + types.ModelTypeKnowledgeQA, + types.ModelTypeEmbedding, + types.ModelTypeVLLM, + }, + RequiresAuth: true, + } +} + +// ValidateConfig 验证 ModelScope provider 配置 +func (p *ModelScopeProvider) ValidateConfig(config *Config) error { + if config.BaseURL == "" { + return fmt.Errorf("base URL is required for ModelScope provider") + } + if config.APIKey == "" { + return fmt.Errorf("API key is required for ModelScope provider") + } + if config.ModelName == "" { + return fmt.Errorf("model name is required") + } + return nil +} diff --git a/internal/models/provider/moonshot.go b/internal/models/provider/moonshot.go new file mode 100644 index 00000000..3c6b31ee --- /dev/null +++ b/internal/models/provider/moonshot.go @@ -0,0 +1,50 @@ +package provider + +import ( + "fmt" + + "github.com/Tencent/WeKnora/internal/types" +) + +const ( + MoonshotBaseURL = "https://api.moonshot.ai/v1" +) + +// MoonshotProvider 实现 Moonshot AI (Kimi) 的 Provider 接口 +type MoonshotProvider struct{} + +func init() { + Register(&MoonshotProvider{}) +} + +// Info 返回 Moonshot provider 的元数据 +func (p *MoonshotProvider) Info() ProviderInfo { + return ProviderInfo{ + Name: ProviderMoonshot, + DisplayName: "月之暗面 Moonshot", + Description: "kimi-k2-turbo-preview, moonshot-v1-8k-vision-preview, etc.", + DefaultURLs: map[types.ModelType]string{ + types.ModelTypeKnowledgeQA: MoonshotBaseURL, + types.ModelTypeVLLM: MoonshotBaseURL, + }, + ModelTypes: []types.ModelType{ + types.ModelTypeKnowledgeQA, + types.ModelTypeVLLM, + }, + RequiresAuth: true, + } +} + +// ValidateConfig 验证 Moonshot provider 配置 +func (p *MoonshotProvider) ValidateConfig(config *Config) error { + if config.BaseURL == "" { + return fmt.Errorf("base URL is required for Moonshot provider") + } + if config.APIKey == "" { + return fmt.Errorf("API key is required for Moonshot provider") + } + if config.ModelName == "" { + return fmt.Errorf("model name is required") + } + return nil +} diff --git a/internal/models/provider/provider.go b/internal/models/provider/provider.go index 1d35892f..9742ac07 100644 --- a/internal/models/provider/provider.go +++ b/internal/models/provider/provider.go @@ -41,6 +41,16 @@ const ( ProviderMimo ProviderName = "mimo" // GPUStack (私有化部署) ProviderGPUStack ProviderName = "gpustack" + // 月之暗面 Moonshot (Kimi) + ProviderMoonshot ProviderName = "moonshot" + // 魔搭 ModelScope + ProviderModelScope ProviderName = "modelscope" + // 百度千帆 + ProviderQianfan ProviderName = "qianfan" + // 七牛云 + ProviderQiniu ProviderName = "qiniu" + // 美团 LongCat AI + ProviderLongCat ProviderName = "longcat" ) // AllProviders 返回所有注册的提供者名称 @@ -54,11 +64,16 @@ func AllProviders() []ProviderName { ProviderSiliconFlow, ProviderDeepSeek, ProviderMiniMax, + ProviderMoonshot, + ProviderModelScope, + ProviderQianfan, + ProviderQiniu, ProviderOpenAI, ProviderGemini, ProviderOpenRouter, ProviderJina, ProviderMimo, + ProviderLongCat, ProviderGPUStack, } } @@ -213,6 +228,16 @@ func DetectProvider(baseURL string) ProviderName { return ProviderMimo case containsAny(baseURL, "gpustack"): return ProviderGPUStack + case containsAny(baseURL, "modelscope.cn"): + return ProviderModelScope + case containsAny(baseURL, "qiniuapi.com", "qiniu"): + return ProviderQiniu + case containsAny(baseURL, "moonshot.ai"): + return ProviderMoonshot + case containsAny(baseURL, "qianfan.baidubce.com", "baidubce.com"): + return ProviderQianfan + case containsAny(baseURL, "longcat.chat"): + return ProviderLongCat default: return ProviderGeneric } diff --git a/internal/models/provider/qianfan.go b/internal/models/provider/qianfan.go new file mode 100644 index 00000000..aac91882 --- /dev/null +++ b/internal/models/provider/qianfan.go @@ -0,0 +1,54 @@ +package provider + +import ( + "fmt" + + "github.com/Tencent/WeKnora/internal/types" +) + +const ( + QianfanBaseURL = "https://qianfan.baidubce.com/v2" +) + +// QianfanProvider 实现百度千帆的 Provider 接口 +type QianfanProvider struct{} + +func init() { + Register(&QianfanProvider{}) +} + +// Info 返回百度千帆 provider 的元数据 +func (p *QianfanProvider) Info() ProviderInfo { + return ProviderInfo{ + Name: ProviderQianfan, + DisplayName: "百度千帆 Baidu Cloud", + Description: "ernie-5.0-thinking-preview, embedding-v1, bce-reranker-base, etc.", + DefaultURLs: 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, + }, + RequiresAuth: true, + } +} + +// ValidateConfig 验证百度千帆 provider 配置 +func (p *QianfanProvider) ValidateConfig(config *Config) error { + if config.BaseURL == "" { + return fmt.Errorf("base URL is required for Qianfan provider") + } + if config.APIKey == "" { + return fmt.Errorf("API key is required for Qianfan provider") + } + if config.ModelName == "" { + return fmt.Errorf("model name is required") + } + return nil +} diff --git a/internal/models/provider/qiniu.go b/internal/models/provider/qiniu.go new file mode 100644 index 00000000..816e5994 --- /dev/null +++ b/internal/models/provider/qiniu.go @@ -0,0 +1,49 @@ +package provider + +import ( + "fmt" + + "github.com/Tencent/WeKnora/internal/types" +) + +const ( + // QiniuBaseURL 七牛云 API BaseURL (OpenAI 兼容模式) + QiniuBaseURL = "https://api.qnaigc.com/v1" +) + +// QiniuProvider 实现七牛云的 Provider 接口 +type QiniuProvider struct{} + +func init() { + Register(&QiniuProvider{}) +} + +// Info 返回七牛云 provider 的元数据 +func (p *QiniuProvider) Info() ProviderInfo { + return ProviderInfo{ + Name: ProviderQiniu, + DisplayName: "七牛云 Qiniu", + Description: "deepseek/deepseek-v3.2-251201, z-ai/glm-4.7, etc.", + DefaultURLs: map[types.ModelType]string{ + types.ModelTypeKnowledgeQA: QiniuBaseURL, + }, + ModelTypes: []types.ModelType{ + types.ModelTypeKnowledgeQA, + }, + RequiresAuth: true, + } +} + +// ValidateConfig 验证七牛云 provider 配置 +func (p *QiniuProvider) ValidateConfig(config *Config) error { + if config.BaseURL == "" { + return fmt.Errorf("base URL is required for Qiniu provider") + } + if config.APIKey == "" { + return fmt.Errorf("API key is required for Qiniu provider") + } + if config.ModelName == "" { + return fmt.Errorf("model name is required") + } + return nil +}