mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-14 00:07:01 +08:00
Feature: Add support for custom OpenAI-compatible API
This update enables users to configure any OpenAI-compatible API endpoint, allowing the use of: - OpenAI official API (GPT-4, GPT-4o, etc.) - OpenRouter (access to multiple models) - Local deployed models (Ollama, LM Studio, etc.) - Other OpenAI-format compatible API services Changes: - config: Add custom_api_url, custom_api_key, custom_model_name fields - mcp: Add SetCustomAPI function and ProviderCustom constant - trader: Update AI initialization logic to support custom API - manager: Pass custom API config to trader instances - Add CUSTOM_API.md documentation with usage examples - Update config.json.example with custom API sample 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
@@ -16,6 +16,7 @@ type Provider string
|
||||
const (
|
||||
ProviderDeepSeek Provider = "deepseek"
|
||||
ProviderQwen Provider = "qwen"
|
||||
ProviderCustom Provider = "custom"
|
||||
)
|
||||
|
||||
// Config AI API配置
|
||||
@@ -53,6 +54,15 @@ func SetQwenAPIKey(apiKey, secretKey string) {
|
||||
defaultConfig.Model = "qwen-plus" // 可选: qwen-turbo, qwen-plus, qwen-max
|
||||
}
|
||||
|
||||
// SetCustomAPI 设置自定义OpenAI兼容API
|
||||
func SetCustomAPI(apiURL, apiKey, modelName string) {
|
||||
defaultConfig.Provider = ProviderCustom
|
||||
defaultConfig.APIKey = apiKey
|
||||
defaultConfig.BaseURL = apiURL
|
||||
defaultConfig.Model = modelName
|
||||
defaultConfig.Timeout = 120 * time.Second
|
||||
}
|
||||
|
||||
// SetConfig 设置完整的AI配置(高级用户)
|
||||
func SetConfig(config Config) {
|
||||
if config.Timeout == 0 {
|
||||
|
||||
Reference in New Issue
Block a user