Files
Enterprise-Knowledge-Base/internal/models/provider/openai.go
T
wizardchen 624e24ba49 feat(asr): integrate Automatic Speech Recognition (ASR) support
- Added ASR configuration options to the knowledge base and model settings.
- Implemented ASR model selection and transcription capabilities in the knowledge processing pipeline.
- Enhanced file upload support to include audio formats for ASR processing.
- Updated localization files to include ASR-related labels and descriptions.
- Refactored model handling to accommodate ASR as a new model type.
2026-04-02 21:27:27 +08:00

54 lines
1.2 KiB
Go

package provider
import (
"fmt"
"github.com/Tencent/WeKnora/internal/types"
)
const (
OpenAIBaseURL = "https://api.openai.com/v1"
)
// OpenAIProvider 实现 OpenAI 的 Provider 接口
type OpenAIProvider struct{}
func init() {
Register(&OpenAIProvider{})
}
// Info 返回 OpenAI provider 的元数据
func (p *OpenAIProvider) Info() ProviderInfo {
return ProviderInfo{
Name: ProviderOpenAI,
DisplayName: "OpenAI",
Description: "gpt-5.2, gpt-5-mini, etc.",
DefaultURLs: map[types.ModelType]string{
types.ModelTypeKnowledgeQA: OpenAIBaseURL,
types.ModelTypeEmbedding: OpenAIBaseURL,
types.ModelTypeRerank: OpenAIBaseURL,
types.ModelTypeVLLM: OpenAIBaseURL,
types.ModelTypeASR: OpenAIBaseURL,
},
ModelTypes: []types.ModelType{
types.ModelTypeKnowledgeQA,
types.ModelTypeEmbedding,
types.ModelTypeRerank,
types.ModelTypeVLLM,
types.ModelTypeASR,
},
RequiresAuth: true,
}
}
// ValidateConfig 验证 OpenAI provider 配置
func (p *OpenAIProvider) ValidateConfig(config *Config) error {
if config.APIKey == "" {
return fmt.Errorf("API key is required for OpenAI provider")
}
if config.ModelName == "" {
return fmt.Errorf("model name is required")
}
return nil
}