NewOpenAIProviderWithBaseURL 创建支持自定义 BaseURL 的 OpenAI 提供商
(config *types.ModelConfig)
| 24 | |
| 25 | // NewOpenAIProviderWithBaseURL 创建支持自定义 BaseURL 的 OpenAI 提供商 |
| 26 | func NewOpenAIProviderWithBaseURL(config *types.ModelConfig) (Provider, error) { |
| 27 | // 确定 BaseURL |
| 28 | baseURL := config.BaseURL |
| 29 | if baseURL == "" { |
| 30 | baseURL = OpenAIAPIBaseURL |
| 31 | } |
| 32 | |
| 33 | // OpenAI 配置选项 |
| 34 | options := &OpenAICompatibleOptions{ |
| 35 | RequireAPIKey: true, |
| 36 | DefaultModel: "gpt-4o", // 默认使用 GPT-4o |
| 37 | SupportReasoning: true, // 支持 o1/o3 推理模型 |
| 38 | SupportPromptCache: true, // 支持 Prompt Caching |
| 39 | SupportVision: true, // 支持图片输入 |
| 40 | SupportAudio: true, // 支持音频输入 |
| 41 | } |
| 42 | |
| 43 | // 创建 OpenAI 兼容 Provider |
| 44 | baseProvider, err := NewOpenAICompatibleProvider( |
| 45 | config, |
| 46 | baseURL, |
| 47 | "OpenAI", |
| 48 | options, |
| 49 | ) |
| 50 | if err != nil { |
| 51 | return nil, err |
| 52 | } |
| 53 | |
| 54 | return &OpenAIProvider{ |
| 55 | OpenAICompatibleProvider: baseProvider, |
| 56 | }, nil |
| 57 | } |
| 58 | |
| 59 | // Capabilities 返回 OpenAI 的能力 |
| 60 | func (p *OpenAIProvider) Capabilities() ProviderCapabilities { |
no test coverage detected