feat: 新增对多家平台的模型适配

This commit is contained in:
nullkey
2025-12-29 01:31:27 +08:00
committed by lyingbug
parent 0b711a6739
commit e9a2a7b3e5
38 changed files with 2963 additions and 132 deletions
+44
View File
@@ -0,0 +1,44 @@
package provider
import (
"fmt"
"github.com/Tencent/WeKnora/internal/types"
)
const (
OpenRouterBaseURL = "https://openrouter.ai/api/v1"
)
// OpenRouterProvider 实现 OpenRouter 的 Provider 接口
type OpenRouterProvider struct{}
func init() {
Register(&OpenRouterProvider{})
}
// Info 返回 OpenRouter provider 的元数据
func (p *OpenRouterProvider) Info() ProviderInfo {
return ProviderInfo{
Name: ProviderOpenRouter,
DisplayName: "OpenRouter",
Description: "openai/gpt-5.2-chat, google/gemini-3-flash-preview, etc.",
DefaultURLs: map[types.ModelType]string{
types.ModelTypeKnowledgeQA: OpenRouterBaseURL,
types.ModelTypeVLLM: OpenRouterBaseURL,
},
ModelTypes: []types.ModelType{
types.ModelTypeKnowledgeQA,
types.ModelTypeVLLM,
},
RequiresAuth: true,
}
}
// ValidateConfig 验证 OpenRouter provider 配置
func (p *OpenRouterProvider) ValidateConfig(config *Config) error {
if config.APIKey == "" {
return fmt.Errorf("API key is required for OpenRouter provider")
}
return nil
}