Improve NOFXi agent product handling

This commit is contained in:
lky-spec
2026-05-02 22:55:10 +08:00
parent 25d0b30ea9
commit 159f27dfdd
19 changed files with 449 additions and 54 deletions

View File

@@ -938,6 +938,8 @@ type safeModelToolConfig struct {
HasAPIKey bool `json:"has_api_key"`
CustomAPIURL string `json:"custom_api_url,omitempty"`
CustomModelName string `json:"custom_model_name,omitempty"`
WalletAddress string `json:"wallet_address,omitempty"`
BalanceUSDC string `json:"balance_usdc,omitempty"`
}
type safeTraderToolConfig struct {
@@ -1115,7 +1117,7 @@ func extractTraderInitialBalance(balanceInfo map[string]interface{}) (float64, b
}
func safeModelForTool(model *store.AIModel) safeModelToolConfig {
return safeModelToolConfig{
safeModel := safeModelToolConfig{
ID: model.ID,
Name: model.Name,
Provider: model.Provider,
@@ -1124,6 +1126,18 @@ func safeModelForTool(model *store.AIModel) safeModelToolConfig {
CustomAPIURL: model.CustomAPIURL,
CustomModelName: model.CustomModelName,
}
if agentProviderSupportsUSDCBalance(model.Provider) {
privateKey := strings.TrimSpace(string(model.APIKey))
if privateKey != "" {
if walletAddress, err := agentWalletAddressFromPrivateKey(privateKey); err == nil && strings.TrimSpace(walletAddress) != "" {
safeModel.WalletAddress = walletAddress
if balance, balanceErr := agentQueryUSDCBalanceCached(walletAddress); balanceErr == nil {
safeModel.BalanceUSDC = fmt.Sprintf("%.6f", balance)
}
}
}
}
return safeModel
}
func modelConfigUsable(provider, modelID, apiKey, customAPIURL, customModelName string) bool {