feat: add LiteLLM as a model provider (#2923)
* feat(provider): add LiteLLM as an OpenAI-compatible provider * docs: use revive-compliant comment for ProviderLiteLLM const * fix(provider): stop defaulting LiteLLM to localhost under SSRF The catalog URL localhost:4000 is blocked by default SSRF and does not match DetectProvider, so UI/CLI could neither save nor auto-detect it. Use a placeholder host, keep thinking aligned with generic, and sync ModelSource across types, Swagger, and docs. --------- Co-authored-by: wizardchen <wizardchen@tencent.com>main
parent
a55f4b7834
commit
db05a64caa
|
|
@ -48,6 +48,7 @@ const (
|
|||
ModelSourceSiliconFlow ModelSource = "siliconflow" // SiliconFlow model
|
||||
ModelSourceJina ModelSource = "jina" // Jina AI model
|
||||
ModelSourceOpenRouter ModelSource = "openrouter" // OpenRouter model
|
||||
ModelSourceLiteLLM ModelSource = "litellm" // LiteLLM proxy model
|
||||
ModelSourceRequesty ModelSource = "requesty" // Requesty model
|
||||
ModelSourceNvidia ModelSource = "nvidia" // NVIDIA model
|
||||
ModelSourceNovita ModelSource = "novita" // Novita AI model
|
||||
|
|
@ -64,7 +65,8 @@ func AllModelSources() []ModelSource {
|
|||
ModelSourceLocal, ModelSourceRemote, ModelSourceAliyun, ModelSourceZhipu,
|
||||
ModelSourceVolcengine, ModelSourceDeepseek, ModelSourceHunyuan, ModelSourceMinimax,
|
||||
ModelSourceOpenAI, ModelSourceGemini, ModelSourceMimo, ModelSourceSiliconFlow,
|
||||
ModelSourceJina, ModelSourceOpenRouter, ModelSourceRequesty, ModelSourceNvidia, ModelSourceNovita,
|
||||
ModelSourceJina, ModelSourceOpenRouter, ModelSourceLiteLLM, ModelSourceRequesty,
|
||||
ModelSourceNvidia, ModelSourceNovita,
|
||||
ModelSourceAzureOpenAI,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ services:
|
|||
|
||||
### 方式二:直接 SQL 插入
|
||||
|
||||
支持的 provider:`generic`(自定义)、`openai`、`aliyun`、`zhipu`、`volcengine`、`hunyuan`、`deepseek`、`minimax`、`mimo`、`siliconflow`、`jina`、`openrouter`、`requesty`、`gemini`、`modelscope`、`moonshot`、`qianfan`、`qiniu`、`longcat`、`gpustack`
|
||||
支持的 provider:`generic`(自定义)、`openai`、`aliyun`、`zhipu`、`volcengine`、`hunyuan`、`deepseek`、`minimax`、`mimo`、`siliconflow`、`jina`、`openrouter`、`litellm`、`requesty`、`gemini`、`modelscope`、`moonshot`、`qianfan`、`qiniu`、`longcat`、`gpustack`
|
||||
|
||||
```sql
|
||||
-- 示例:LLM 内置模型
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ WeKnora 支持多种主流 AI 模型服务商,在创建模型时可通过 `par
|
|||
| `siliconflow` | 硅基流动 SiliconFlow | Chat, Embedding, Rerank, VLLM |
|
||||
| `jina` | Jina | Embedding, Rerank |
|
||||
| `openrouter` | OpenRouter | Chat, VLLM |
|
||||
| `litellm` | LiteLLM (self-hosted proxy) | Chat, Embedding, VLLM |
|
||||
| `requesty` | Requesty | Chat, Embedding, VLLM |
|
||||
| `gemini` | Google Gemini | Chat |
|
||||
| `modelscope` | 魔搭 ModelScope | Chat, Embedding, VLLM |
|
||||
|
|
@ -43,6 +44,8 @@ WeKnora 支持多种主流 AI 模型服务商,在创建模型时可通过 `par
|
|||
| `gpustack` | GPUStack | Chat, Embedding, Rerank, VLLM |
|
||||
|
||||
> 实际可用的服务商以 `GET /models/providers` 返回为准。
|
||||
>
|
||||
> `litellm` 的目录默认地址是占位符 `http://your_litellm_proxy/v1`,保存前请换成实际可解析的主机名。`localhost` / `127.0.0.1` / `host.docker.internal` 默认会被 SSRF 拦截;自托管时把该主机加入 `SSRF_WHITELIST`。创建模型时 `source` 仍为 `remote`,厂商写在 `parameters.provider`。
|
||||
|
||||
## GET `/models/providers` - 获取模型服务商列表
|
||||
|
||||
|
|
|
|||
|
|
@ -19908,6 +19908,7 @@ const docTemplate = `{
|
|||
"siliconflow",
|
||||
"jina",
|
||||
"openrouter",
|
||||
"litellm",
|
||||
"requesty",
|
||||
"nvidia",
|
||||
"novita",
|
||||
|
|
@ -19927,6 +19928,7 @@ const docTemplate = `{
|
|||
"ModelSourceNvidia": "NVIDIA model",
|
||||
"ModelSourceOpenAI": "OpenAI model",
|
||||
"ModelSourceOpenRouter": "OpenRouter model",
|
||||
"ModelSourceLiteLLM": "LiteLLM proxy model",
|
||||
"ModelSourceRemote": "Remote model",
|
||||
"ModelSourceRequesty": "Requesty model",
|
||||
"ModelSourceSiliconFlow": "SiliconFlow model",
|
||||
|
|
@ -19948,6 +19950,7 @@ const docTemplate = `{
|
|||
"SiliconFlow model",
|
||||
"Jina AI model",
|
||||
"OpenRouter model",
|
||||
"LiteLLM proxy model",
|
||||
"Requesty model",
|
||||
"NVIDIA model",
|
||||
"Novita AI model",
|
||||
|
|
@ -19968,6 +19971,7 @@ const docTemplate = `{
|
|||
"ModelSourceSiliconFlow",
|
||||
"ModelSourceJina",
|
||||
"ModelSourceOpenRouter",
|
||||
"ModelSourceLiteLLM",
|
||||
"ModelSourceRequesty",
|
||||
"ModelSourceNvidia",
|
||||
"ModelSourceNovita",
|
||||
|
|
|
|||
|
|
@ -19901,6 +19901,7 @@
|
|||
"siliconflow",
|
||||
"jina",
|
||||
"openrouter",
|
||||
"litellm",
|
||||
"requesty",
|
||||
"nvidia",
|
||||
"novita",
|
||||
|
|
@ -19920,6 +19921,7 @@
|
|||
"ModelSourceNvidia": "NVIDIA model",
|
||||
"ModelSourceOpenAI": "OpenAI model",
|
||||
"ModelSourceOpenRouter": "OpenRouter model",
|
||||
"ModelSourceLiteLLM": "LiteLLM proxy model",
|
||||
"ModelSourceRemote": "Remote model",
|
||||
"ModelSourceRequesty": "Requesty model",
|
||||
"ModelSourceSiliconFlow": "SiliconFlow model",
|
||||
|
|
@ -19941,6 +19943,7 @@
|
|||
"SiliconFlow model",
|
||||
"Jina AI model",
|
||||
"OpenRouter model",
|
||||
"LiteLLM proxy model",
|
||||
"Requesty model",
|
||||
"NVIDIA model",
|
||||
"Novita AI model",
|
||||
|
|
@ -19961,6 +19964,7 @@
|
|||
"ModelSourceSiliconFlow",
|
||||
"ModelSourceJina",
|
||||
"ModelSourceOpenRouter",
|
||||
"ModelSourceLiteLLM",
|
||||
"ModelSourceRequesty",
|
||||
"ModelSourceNvidia",
|
||||
"ModelSourceNovita",
|
||||
|
|
|
|||
|
|
@ -2468,6 +2468,7 @@ definitions:
|
|||
- siliconflow
|
||||
- jina
|
||||
- openrouter
|
||||
- litellm
|
||||
- requesty
|
||||
- nvidia
|
||||
- novita
|
||||
|
|
@ -2487,6 +2488,7 @@ definitions:
|
|||
ModelSourceNvidia: NVIDIA model
|
||||
ModelSourceOpenAI: OpenAI model
|
||||
ModelSourceOpenRouter: OpenRouter model
|
||||
ModelSourceLiteLLM: LiteLLM proxy model
|
||||
ModelSourceRemote: Remote model
|
||||
ModelSourceRequesty: Requesty model
|
||||
ModelSourceSiliconFlow: SiliconFlow model
|
||||
|
|
@ -2507,6 +2509,7 @@ definitions:
|
|||
- SiliconFlow model
|
||||
- Jina AI model
|
||||
- OpenRouter model
|
||||
- LiteLLM proxy model
|
||||
- Requesty model
|
||||
- NVIDIA model
|
||||
- Novita AI model
|
||||
|
|
@ -2526,6 +2529,7 @@ definitions:
|
|||
- ModelSourceSiliconFlow
|
||||
- ModelSourceJina
|
||||
- ModelSourceOpenRouter
|
||||
- ModelSourceLiteLLM
|
||||
- ModelSourceRequesty
|
||||
- ModelSourceNvidia
|
||||
- ModelSourceNovita
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ source: BUILTIN_MODELS.md
|
|||
- 模型参数(parameters):包括 base_url、api_key、provider 等
|
||||
- 空间ID(tenant_id):建议使用小于10000的空间ID
|
||||
|
||||
**支持的服务商(provider)**:`generic`、`openai`、`aliyun`、`zhipu`、`volcengine`、`hunyuan`、`deepseek`、`minimax`、`mimo`、`siliconflow`、`jina`、`openrouter`、`requesty`、`gemini`、`modelscope`、`moonshot`、`qianfan`、`qiniu`、`longcat`、`gpustack`
|
||||
**支持的服务商(provider)**:`generic`、`openai`、`aliyun`、`zhipu`、`volcengine`、`hunyuan`、`deepseek`、`minimax`、`mimo`、`siliconflow`、`jina`、`openrouter`、`litellm`、`requesty`、`gemini`、`modelscope`、`moonshot`、`qianfan`、`qiniu`、`longcat`、`gpustack`
|
||||
|
||||
### 2. 执行 SQL 插入语句
|
||||
|
||||
|
|
|
|||
|
|
@ -550,6 +550,17 @@ const fallbackProviderOptions = computed(() => [
|
|||
description: t('model.editor.providers.openrouter.description'),
|
||||
modelTypes: ['chat', 'embedding']
|
||||
},
|
||||
{
|
||||
value: 'litellm',
|
||||
label: t('model.editor.providers.litellm.label'),
|
||||
defaultUrls: {
|
||||
chat: 'http://your_litellm_proxy/v1',
|
||||
embedding: 'http://your_litellm_proxy/v1',
|
||||
vllm: 'http://your_litellm_proxy/v1'
|
||||
},
|
||||
description: t('model.editor.providers.litellm.description'),
|
||||
modelTypes: ['chat', 'embedding', 'vllm']
|
||||
},
|
||||
{
|
||||
value: 'requesty',
|
||||
label: t('model.editor.providers.requesty.label'),
|
||||
|
|
|
|||
|
|
@ -4272,6 +4272,10 @@ export default {
|
|||
label: 'OpenRouter',
|
||||
description: 'openai/gpt-5.2-chat, google/gemini-3-flash-preview, etc.'
|
||||
},
|
||||
litellm: {
|
||||
label: 'LiteLLM',
|
||||
description: 'Self-hosted proxy to 100+ providers (OpenAI, Anthropic, Gemini, Bedrock, etc.). Replace the placeholder URL; loopback hosts need SSRF_WHITELIST.'
|
||||
},
|
||||
requesty: {
|
||||
label: 'Requesty',
|
||||
description: 'openai/gpt-4o-mini, anthropic/claude-sonnet-4-5, etc.'
|
||||
|
|
|
|||
|
|
@ -2452,6 +2452,10 @@ export default {
|
|||
label: 'OpenRouter',
|
||||
description: 'openai/gpt-5.2-chat, google/gemini-3-flash-preview 등'
|
||||
},
|
||||
litellm: {
|
||||
label: 'LiteLLM',
|
||||
description: '자체 호스팅 프록시로 OpenAI, Anthropic, Gemini, Bedrock 등 100+ 공급자를 연결합니다. 플레이스홀더 URL을 실제 주소로 바꾸세요. localhost는 SSRF_WHITELIST에 추가해야 합니다.'
|
||||
},
|
||||
zhipu: {
|
||||
label: 'Zhipu BigModel',
|
||||
description: 'glm-4.7, embedding-3, rerank, etc.'
|
||||
|
|
|
|||
|
|
@ -2452,6 +2452,10 @@ export default {
|
|||
label: 'OpenRouter',
|
||||
description: 'openai/gpt-5.2-chat, google/gemini-3-flash-preview, etc.'
|
||||
},
|
||||
litellm: {
|
||||
label: 'LiteLLM',
|
||||
description: 'Self-hosted прокси к 100+ провайдерам (OpenAI, Anthropic, Gemini, Bedrock и др.). Замените URL-заглушку; localhost нужно добавить в SSRF_WHITELIST.'
|
||||
},
|
||||
zhipu: {
|
||||
label: 'Zhipu BigModel',
|
||||
description: 'glm-4.7, embedding-3, rerank, etc.'
|
||||
|
|
|
|||
|
|
@ -2454,6 +2454,10 @@ export default {
|
|||
label: 'OpenRouter',
|
||||
description: 'openai/gpt-5.2-chat, google/gemini-3-flash-preview, etc.'
|
||||
},
|
||||
litellm: {
|
||||
label: 'LiteLLM',
|
||||
description: '自托管代理,统一接入 OpenAI、Anthropic、Gemini、Bedrock 等 100+ 厂商。请将占位 URL 换成可访问地址;localhost 需加入 SSRF_WHITELIST。'
|
||||
},
|
||||
zhipu: {
|
||||
label: '智谱 BigModel',
|
||||
description: 'glm-4.7, embedding-3, rerank, etc.'
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ test('defaultThinkingControl matches backend provider adapters', () => {
|
|||
const cases: Array<[string, string, ReturnType<typeof defaultThinkingControl>]> = [
|
||||
['generic', 'anything', 'chat_template_kwargs'],
|
||||
['nvidia', 'anything', 'chat_template_kwargs'],
|
||||
['litellm', 'anything', 'chat_template_kwargs'],
|
||||
['volcengine', 'doubao', 'thinking_type'],
|
||||
['aliyun', 'qwen3-32b', 'enable_thinking'],
|
||||
['aliyun', 'qwen-plus', 'enable_thinking'],
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ export function defaultThinkingControl(
|
|||
return 'thinking_type'
|
||||
case 'generic':
|
||||
case 'nvidia':
|
||||
case 'litellm':
|
||||
return 'chat_template_kwargs'
|
||||
case 'volcengine':
|
||||
return 'thinking_type'
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ func (deepseekProvider) ShapeRequest(req *openai.ChatCompletionRequest, opts *Ch
|
|||
}
|
||||
}
|
||||
|
||||
// --- Generic (vLLM) / NVIDIA: thinking via chat_template_kwargs ---
|
||||
// --- Generic (vLLM) / NVIDIA / LiteLLM: thinking via chat_template_kwargs ---
|
||||
|
||||
type genericProvider struct{ baseProvider }
|
||||
|
||||
|
|
@ -168,6 +168,11 @@ type nvidiaProvider struct{ baseProvider }
|
|||
func (nvidiaProvider) Name() provider.ProviderName { return provider.ProviderNvidia }
|
||||
func (nvidiaProvider) Thinking() ThinkingStrategy { return chatTemplateKwargs{} }
|
||||
|
||||
type liteLLMProvider struct{ baseProvider }
|
||||
|
||||
func (liteLLMProvider) Name() provider.ProviderName { return provider.ProviderLiteLLM }
|
||||
func (liteLLMProvider) Thinking() ThinkingStrategy { return chatTemplateKwargs{} }
|
||||
|
||||
// --- Gemini OpenAI compatibility: tool thought signatures live in extra_content ---
|
||||
|
||||
type geminiProvider struct{ baseProvider }
|
||||
|
|
@ -277,6 +282,7 @@ var providerRegistry = []providerAdapter{
|
|||
lkeapProvider{},
|
||||
deepseekProvider{},
|
||||
genericProvider{},
|
||||
liteLLMProvider{},
|
||||
geminiProvider{},
|
||||
volcengineProvider{},
|
||||
nvidiaProvider{},
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ func TestResolveProvider(t *testing.T) {
|
|||
{"lkeap r1 falls back", provider.ProviderLKEAP, "deepseek-r1", baseProvider{}},
|
||||
{"qwen thinking", provider.ProviderAliyun, "qwen3-32b", qwenThinkingProvider{}},
|
||||
{"generic", provider.ProviderGeneric, "anything", genericProvider{}},
|
||||
{"litellm", provider.ProviderLiteLLM, "anything", liteLLMProvider{}},
|
||||
{"gemini", provider.ProviderGemini, "gemini-3-flash-preview", geminiProvider{}},
|
||||
{"nvidia", provider.ProviderNvidia, "anything", nvidiaProvider{}},
|
||||
{"volcengine", provider.ProviderVolcengine, "doubao", volcengineProvider{}},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
package provider
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
)
|
||||
|
||||
const (
|
||||
// LiteLLMBaseURL is a placeholder the user must replace with a reachable
|
||||
// LiteLLM proxy. Loopback defaults (localhost:4000) are rejected by SSRF
|
||||
// unless the host is added to SSRF_WHITELIST; Docker also cannot reach a
|
||||
// proxy on the host via localhost. The hostname contains "litellm" so
|
||||
// DetectProvider recognises the catalog default.
|
||||
LiteLLMBaseURL = "http://your_litellm_proxy/v1"
|
||||
)
|
||||
|
||||
// LiteLLMProvider implements the Provider interface for LiteLLM
|
||||
// (https://github.com/BerriAI/litellm). LiteLLM exposes a single
|
||||
// OpenAI-compatible endpoint that routes to 100+ providers (OpenAI, Anthropic,
|
||||
// Gemini, Bedrock, Vertex, Azure, ...) behind one base URL and key, so it plugs
|
||||
// into WeKnora's OpenAI-compatible transport like the other gateway providers.
|
||||
type LiteLLMProvider struct{}
|
||||
|
||||
func init() {
|
||||
Register(&LiteLLMProvider{})
|
||||
}
|
||||
|
||||
// Info returns the metadata for the LiteLLM provider.
|
||||
func (p *LiteLLMProvider) Info() ProviderInfo {
|
||||
return ProviderInfo{
|
||||
Name: ProviderLiteLLM,
|
||||
DisplayName: "LiteLLM",
|
||||
Description: "Self-hosted LiteLLM proxy: one OpenAI-compatible endpoint to 100+ providers.",
|
||||
DefaultURLs: map[types.ModelType]string{
|
||||
types.ModelTypeKnowledgeQA: LiteLLMBaseURL,
|
||||
types.ModelTypeEmbedding: LiteLLMBaseURL,
|
||||
types.ModelTypeVLLM: LiteLLMBaseURL,
|
||||
},
|
||||
ModelTypes: []types.ModelType{
|
||||
types.ModelTypeKnowledgeQA,
|
||||
types.ModelTypeEmbedding,
|
||||
types.ModelTypeVLLM,
|
||||
},
|
||||
RequiresAuth: true,
|
||||
}
|
||||
}
|
||||
|
||||
// ValidateConfig validates the LiteLLM provider configuration.
|
||||
func (p *LiteLLMProvider) ValidateConfig(config *Config) error {
|
||||
if config.APIKey == "" {
|
||||
return fmt.Errorf("API key is required for LiteLLM provider")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -23,6 +23,8 @@ const (
|
|||
ProviderZhipu ProviderName = "zhipu"
|
||||
// OpenRouter
|
||||
ProviderOpenRouter ProviderName = "openrouter"
|
||||
// ProviderLiteLLM is the LiteLLM self-hosted proxy (OpenAI-compatible gateway to 100+ providers).
|
||||
ProviderLiteLLM ProviderName = "litellm"
|
||||
// Requesty
|
||||
ProviderRequesty ProviderName = "requesty"
|
||||
// 硅基流动
|
||||
|
|
@ -85,6 +87,7 @@ func AllProviders() []ProviderName {
|
|||
ProviderAnthropic,
|
||||
ProviderGemini,
|
||||
ProviderOpenRouter,
|
||||
ProviderLiteLLM,
|
||||
ProviderRequesty,
|
||||
ProviderJina,
|
||||
ProviderMimo,
|
||||
|
|
@ -227,6 +230,11 @@ func DetectProvider(baseURL string) ProviderName {
|
|||
return ProviderZhipu
|
||||
case containsAny(baseURL, "openrouter.ai"):
|
||||
return ProviderOpenRouter
|
||||
// Hostname/path containing "litellm" (including the catalog placeholder
|
||||
// your_litellm_proxy). Loopback URLs such as localhost:4000 stay generic
|
||||
// because they are SSRF-blocked unless explicitly whitelisted.
|
||||
case containsAny(baseURL, "litellm"):
|
||||
return ProviderLiteLLM
|
||||
case containsAny(baseURL, "router.requesty.ai", "requesty.ai"):
|
||||
return ProviderRequesty
|
||||
case containsAny(baseURL, "siliconflow.cn"):
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ func TestDetectProvider(t *testing.T) {
|
|||
{"https://api.openai.com/v1", ProviderOpenAI},
|
||||
{"https://api.anthropic.com/v1", ProviderAnthropic},
|
||||
{"https://openrouter.ai/api/v1", ProviderOpenRouter},
|
||||
{"https://litellm.example.com/v1", ProviderLiteLLM},
|
||||
{LiteLLMBaseURL, ProviderLiteLLM},
|
||||
{"http://localhost:4000/v1", ProviderGeneric},
|
||||
{"https://router.requesty.ai/v1", ProviderRequesty},
|
||||
{"https://dashscope.aliyuncs.com/compatible-mode/v1", ProviderAliyun},
|
||||
{"https://open.bigmodel.cn/api/paas/v4", ProviderZhipu},
|
||||
|
|
@ -317,3 +320,62 @@ func TestListByModelType(t *testing.T) {
|
|||
assert.True(t, found, "Gemini should support embedding via the native Gemini API")
|
||||
})
|
||||
}
|
||||
|
||||
func TestLiteLLMProviderValidation(t *testing.T) {
|
||||
p := &LiteLLMProvider{}
|
||||
|
||||
t.Run("valid config", func(t *testing.T) {
|
||||
config := &Config{
|
||||
APIKey: "test-key",
|
||||
ModelName: "gpt-4.1-mini",
|
||||
}
|
||||
err := p.ValidateConfig(config)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("missing API key", func(t *testing.T) {
|
||||
config := &Config{
|
||||
ModelName: "gpt-4.1-mini",
|
||||
}
|
||||
err := p.ValidateConfig(config)
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "API key")
|
||||
})
|
||||
|
||||
t.Run("info", func(t *testing.T) {
|
||||
info := p.Info()
|
||||
assert.Equal(t, ProviderLiteLLM, info.Name)
|
||||
assert.Equal(t, "LiteLLM", info.DisplayName)
|
||||
assert.True(t, info.RequiresAuth)
|
||||
assert.Equal(t, LiteLLMBaseURL, info.DefaultURLs[types.ModelTypeKnowledgeQA])
|
||||
assert.Equal(t, LiteLLMBaseURL, info.DefaultURLs[types.ModelTypeEmbedding])
|
||||
assert.Equal(t, LiteLLMBaseURL, info.DefaultURLs[types.ModelTypeVLLM])
|
||||
assert.Contains(t, info.ModelTypes, types.ModelTypeKnowledgeQA)
|
||||
assert.Contains(t, info.ModelTypes, types.ModelTypeEmbedding)
|
||||
assert.Contains(t, info.ModelTypes, types.ModelTypeVLLM)
|
||||
})
|
||||
|
||||
t.Run("registered and listed", func(t *testing.T) {
|
||||
got, ok := Get(ProviderLiteLLM)
|
||||
require.True(t, ok)
|
||||
require.NotNil(t, got)
|
||||
|
||||
foundChat := false
|
||||
for _, info := range ListByModelType(types.ModelTypeKnowledgeQA) {
|
||||
if info.Name == ProviderLiteLLM {
|
||||
foundChat = true
|
||||
break
|
||||
}
|
||||
}
|
||||
assert.True(t, foundChat, "LiteLLM should appear for chat models")
|
||||
|
||||
foundEmbed := false
|
||||
for _, info := range ListByModelType(types.ModelTypeEmbedding) {
|
||||
if info.Name == ProviderLiteLLM {
|
||||
foundEmbed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
assert.True(t, foundEmbed, "LiteLLM should appear for embedding models")
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ const (
|
|||
ModelSourceSiliconFlow ModelSource = "siliconflow" // SiliconFlow model
|
||||
ModelSourceJina ModelSource = "jina" // Jina AI model
|
||||
ModelSourceOpenRouter ModelSource = "openrouter" // OpenRouter model
|
||||
ModelSourceLiteLLM ModelSource = "litellm" // LiteLLM proxy model
|
||||
ModelSourceRequesty ModelSource = "requesty" // Requesty model
|
||||
ModelSourceNvidia ModelSource = "nvidia" // NVIDIA model
|
||||
ModelSourceNovita ModelSource = "novita" // Novita AI model
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ WeKnora(维娜拉)是腾讯开源的知识库问答系统,做的事情是
|
|||
| --- | --- |
|
||||
| 会话 Session | 一次多轮对话。记录 `LastRequestState`(上次提问时选中的 Agent、模型、知识库范围、Web 搜索、MCP 服务),重开会话时恢复;上下文压缩策略(`sliding_window` / `smart` LLM 摘要)来自 `ContextConfig` |
|
||||
| 消息 Message | `user` / `assistant` 角色消息,支持图片、附件、@提及(知识库/文档/标签/MCP/Skill),并统计 `TokenUsage`(含 prompt cache 命中情况) |
|
||||
| 模型 Model | 模型注册项。`Type`:`KnowledgeQA`(对话 LLM)/ `Embedding` / `Rerank` / `VLLM`(视觉)/ `ASR`(语音);`Source`:`local`(Ollama)、`remote` 及 `openai`、`azure_openai`、`gemini`、`deepseek`、`aliyun`、`zhipu`、`volcengine`、`hunyuan`、`siliconflow`、`openrouter`、`jina` 等厂商;`ManagedBy: "yaml"` 表示由 `config/builtin_models.yaml` 声明式管理 |
|
||||
| 模型 Model | 模型注册项。`Type`:`KnowledgeQA`(对话 LLM)/ `Embedding` / `Rerank` / `VLLM`(视觉)/ `ASR`(语音);`Source`:`local`(Ollama)、`remote` 及 `openai`、`azure_openai`、`gemini`、`deepseek`、`aliyun`、`zhipu`、`volcengine`、`hunyuan`、`siliconflow`、`openrouter`、`litellm`、`jina` 等厂商;`ManagedBy: "yaml"` 表示由 `config/builtin_models.yaml` 声明式管理 |
|
||||
| Agent(自定义智能体) CustomAgent | 两种模式:`quick-answer`(经典 RAG 管线)与 `smart-reasoning`(ReAct 多步推理 + 工具调用)。smart-reasoning 下有类型预设 `AgentType`:`rag-qa` / `wiki-qa` / `hybrid-rag-wiki` / `data-analysis` / `custom`(定义见 `config/agent_type_presets.yaml`) |
|
||||
| 内置 Agent | 开箱可用:`builtin-quick-answer`(快速问答)、`builtin-smart-reasoning`(智能推理)、`builtin-data-analyst`(数据分析)、`builtin-wiki-researcher`(Wiki 研究员)、`builtin-wiki-fixer`(Wiki 修复员)等 |
|
||||
| MCP 服务 MCPService | Model Context Protocol 工具接入:`sse` / `http-streamable` / `stdio` 三种传输;认证支持 API Key / Bearer / OAuth2;Agent 可按 `all` / `selected` / `none` 选用其工具 |
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ type Provider interface {
|
|||
|
||||
### 支持的厂商清单
|
||||
|
||||
`AllProviders()`(`provider/provider.go`)返回的完整列表(共 26 个,每个厂商在自己的文件里 `init()` 注册)。表格最后一行的 Ollama 不在其中,它走 `source=local` 这条独立路径,列在这里只为方便对照:
|
||||
`AllProviders()`(`provider/provider.go`)返回的完整列表(共 27 个,每个厂商在自己的文件里 `init()` 注册)。表格最后一行的 Ollama 不在其中,它走 `source=local` 这条独立路径,列在这里只为方便对照:
|
||||
|
||||
| Provider 标识 | 名称 | 说明 |
|
||||
|---------------|------|------|
|
||||
|
|
@ -78,6 +78,7 @@ type Provider interface {
|
|||
| `anthropic` | Anthropic Claude | 独立 Messages 协议实现 |
|
||||
| `gemini` | Google Gemini | Embedding 走专用 API |
|
||||
| `openrouter` | OpenRouter | |
|
||||
| `litellm` | LiteLLM(自托管 OpenAI 兼容代理) | 默认 URL 为占位符,loopback 需加入 `SSRF_WHITELIST` |
|
||||
| `requesty` | Requesty | |
|
||||
| `jina` | Jina AI | Embedding 与 Rerank |
|
||||
| `mimo` | 小米 MiMo | |
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ type Reranker interface {
|
|||
|
||||
### 现有实现
|
||||
|
||||
`internal/models/provider/provider.go` 中已定义 26 个 `ProviderName` 常量:openai、anthropic、aliyun、zhipu、openrouter、requesty、siliconflow、jina、generic、deepseek、gemini、volcengine、hunyuan、minimax、mimo、gpustack、moonshot、modelscope、qianfan、qiniu、longcat、lkeap、nvidia 等。具体 Provider 实现分布在 `internal/models/provider/` 下的各文件(如 `zhipu.go`、`gemini.go`、`hunyuan.go`、`generic.go`);特殊 embedding 实现如 `internal/models/embedding/jina.go`、`volcengine.go`、`nvidia.go`。
|
||||
`internal/models/provider/provider.go` 中已定义 27 个 `ProviderName` 常量:openai、anthropic、aliyun、zhipu、openrouter、litellm、requesty、siliconflow、jina、generic、deepseek、gemini、volcengine、hunyuan、minimax、mimo、gpustack、moonshot、modelscope、qianfan、qiniu、longcat、lkeap、nvidia 等。具体 Provider 实现分布在 `internal/models/provider/` 下的各文件(如 `zhipu.go`、`gemini.go`、`hunyuan.go`、`generic.go`);特殊 embedding 实现如 `internal/models/embedding/jina.go`、`volcengine.go`、`nvidia.go`。
|
||||
|
||||
### 新增步骤
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue