mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-18 01:44:38 +08:00
Improve(interface): replace some struct with interface for testing (#994)
* fix(trader): get peakPnlPct using posKey * fix(docs): keep readme at the same page * improve(interface): replace with interface * refactor mcp --------- Co-authored-by: zbhan <zbhan@freewheel.tv>
This commit is contained in:
53
mcp/qwen_client.go
Normal file
53
mcp/qwen_client.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package mcp
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const (
|
||||
ProviderQwen = "qwen"
|
||||
DefaultQwenBaseURL = "https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||
DefaultQwenModel = "qwen3-max"
|
||||
)
|
||||
|
||||
type QwenClient struct {
|
||||
*Client
|
||||
}
|
||||
|
||||
func NewQwenClient() AIClient {
|
||||
client := New().(*Client)
|
||||
client.Provider = ProviderQwen
|
||||
client.Model = DefaultQwenModel
|
||||
client.BaseURL = DefaultQwenBaseURL
|
||||
return &QwenClient{
|
||||
Client: client,
|
||||
}
|
||||
}
|
||||
|
||||
func (qwenClient *QwenClient) SetAPIKey(apiKey string, customURL string, customModel string) {
|
||||
if qwenClient.Client == nil {
|
||||
qwenClient.Client = New().(*Client)
|
||||
}
|
||||
qwenClient.Client.APIKey = apiKey
|
||||
|
||||
if len(apiKey) > 8 {
|
||||
log.Printf("🔧 [MCP] Qwen API Key: %s...%s", apiKey[:4], apiKey[len(apiKey)-4:])
|
||||
}
|
||||
if customURL != "" {
|
||||
qwenClient.Client.BaseURL = customURL
|
||||
log.Printf("🔧 [MCP] Qwen 使用自定义 BaseURL: %s", customURL)
|
||||
} else {
|
||||
log.Printf("🔧 [MCP] Qwen 使用默认 BaseURL: %s", qwenClient.Client.BaseURL)
|
||||
}
|
||||
if customModel != "" {
|
||||
qwenClient.Client.Model = customModel
|
||||
log.Printf("🔧 [MCP] Qwen 使用自定义 Model: %s", customModel)
|
||||
} else {
|
||||
log.Printf("🔧 [MCP] Qwen 使用默认 Model: %s", qwenClient.Client.Model)
|
||||
}
|
||||
}
|
||||
|
||||
func (qwenClient *QwenClient) setAuthHeader(reqHeaders http.Header) {
|
||||
qwenClient.Client.setAuthHeader(reqHeaders)
|
||||
}
|
||||
Reference in New Issue
Block a user