mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-10 14:27:00 +08:00
* 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>
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
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)
|
|
}
|