feat(api): enhance strategy handling by integrating claw402 wallet key validation

Added validation for the claw402 model's wallet key during strategy test runs. If the selected AI model is claw402, the server now checks for a valid wallet key and returns appropriate error messages if it's missing or if the model fails to load. This ensures better error handling and user feedback when working with AI models.
This commit is contained in:
Dean
2026-04-15 18:15:32 +08:00
parent c2fc80e269
commit 1464cedeff
+24 -1
View File
@@ -516,8 +516,31 @@ func (s *Server) handleStrategyTestRun(c *gin.Context) {
req.PromptVariant = "balanced"
}
claw402WalletKey := ""
if req.AIModelID != "" {
model, err := s.store.AIModel().Get(userID, req.AIModelID)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"error": "Failed to load selected AI model",
"ai_response": "",
})
return
}
if model.Provider == "claw402" {
claw402WalletKey = string(model.APIKey)
if claw402WalletKey == "" {
c.JSON(http.StatusBadRequest, gin.H{
"error": "Selected claw402 model is missing wallet private key",
"ai_response": "",
})
return
}
}
}
// Create strategy engine to build prompt
engine := kernel.NewStrategyEngine(&req.Config)
engine := kernel.NewStrategyEngine(&req.Config, claw402WalletKey)
// Get candidate coins
candidates, err := engine.GetCandidateCoins()