mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-17 17:34:39 +08:00
feat: add Grok, OpenAI, Claude, Gemini, Kimi AI providers
- Add new MCP clients for Grok (xAI), OpenAI, Claude, Gemini, Kimi - Update auto_trader, backtest, and strategy to support all providers - Add provider icons and fix SVG gradient conflicts - Add API application links and hints in model config modal - Show model version in AI model list cards - Add Chinese/English translations for provider hints - Remove deprecated traders component files
This commit is contained in:
71
mcp/kimi_client.go
Normal file
71
mcp/kimi_client.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package mcp
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const (
|
||||
ProviderKimi = "kimi"
|
||||
DefaultKimiBaseURL = "https://api.moonshot.ai/v1" // Global endpoint (use api.moonshot.cn for China)
|
||||
DefaultKimiModel = "moonshot-v1-auto"
|
||||
)
|
||||
|
||||
type KimiClient struct {
|
||||
*Client
|
||||
}
|
||||
|
||||
// NewKimiClient creates Kimi (Moonshot) client (backward compatible)
|
||||
func NewKimiClient() AIClient {
|
||||
return NewKimiClientWithOptions()
|
||||
}
|
||||
|
||||
// NewKimiClientWithOptions creates Kimi client (supports options pattern)
|
||||
func NewKimiClientWithOptions(opts ...ClientOption) AIClient {
|
||||
// 1. Create Kimi preset options
|
||||
kimiOpts := []ClientOption{
|
||||
WithProvider(ProviderKimi),
|
||||
WithModel(DefaultKimiModel),
|
||||
WithBaseURL(DefaultKimiBaseURL),
|
||||
}
|
||||
|
||||
// 2. Merge user options (user options have higher priority)
|
||||
allOpts := append(kimiOpts, opts...)
|
||||
|
||||
// 3. Create base client
|
||||
baseClient := NewClient(allOpts...).(*Client)
|
||||
|
||||
// 4. Create Kimi client
|
||||
kimiClient := &KimiClient{
|
||||
Client: baseClient,
|
||||
}
|
||||
|
||||
// 5. Set hooks to point to KimiClient (implement dynamic dispatch)
|
||||
baseClient.hooks = kimiClient
|
||||
|
||||
return kimiClient
|
||||
}
|
||||
|
||||
func (c *KimiClient) SetAPIKey(apiKey string, customURL string, customModel string) {
|
||||
c.APIKey = apiKey
|
||||
|
||||
if len(apiKey) > 8 {
|
||||
c.logger.Infof("🔧 [MCP] Kimi API Key: %s...%s", apiKey[:4], apiKey[len(apiKey)-4:])
|
||||
}
|
||||
if customURL != "" {
|
||||
c.BaseURL = customURL
|
||||
c.logger.Infof("🔧 [MCP] Kimi using custom BaseURL: %s", customURL)
|
||||
} else {
|
||||
c.logger.Infof("🔧 [MCP] Kimi using default BaseURL: %s", c.BaseURL)
|
||||
}
|
||||
if customModel != "" {
|
||||
c.Model = customModel
|
||||
c.logger.Infof("🔧 [MCP] Kimi using custom Model: %s", customModel)
|
||||
} else {
|
||||
c.logger.Infof("🔧 [MCP] Kimi using default Model: %s", c.Model)
|
||||
}
|
||||
}
|
||||
|
||||
// Kimi uses standard OpenAI-compatible API, so we just use the base client methods
|
||||
func (c *KimiClient) setAuthHeader(reqHeaders http.Header) {
|
||||
c.Client.setAuthHeader(reqHeaders)
|
||||
}
|
||||
Reference in New Issue
Block a user