mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-10 06:20:58 +08:00
feat(agent): surface the AI500 index board in chat, tools, and sidebar
- provider/nofxos: GetAI500ListCached — 5min TTL cache with stale fallback on upstream failure; ResolveClient routes through the claw402 gateway when a wallet key is configured (user's claw402 model key -> CLAW402_WALLET_KEY env -> direct nofxos) - new GET /api/ai500 endpoint serving the score-sorted board - new get_ai500_list agent tool + prompt rule: when the user wants coin picks or creates a strategy without naming coins, consult AI500's high-scoring entries by default - web: AI500 sidebar panel (rank, score badge, gain since entry, 5min auto-refresh); clicking an entry asks the agent to analyze it
This commit is contained in:
43
api/handler_ai500.go
Normal file
43
api/handler_ai500.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"nofx/agent"
|
||||
)
|
||||
|
||||
// handleAI500List serves the AI500 index board for the agent UI panel.
|
||||
// Data is fetched through the user's claw402 wallet when one is configured
|
||||
// (falling back to the direct nofxos client) and served from a 5-minute
|
||||
// cache, so panel polling never hammers the upstream.
|
||||
func (s *Server) handleAI500List(c *gin.Context) {
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
limit := 0
|
||||
if raw := c.Query("limit"); raw != "" {
|
||||
parsed, err := strconv.Atoi(raw)
|
||||
if err != nil || parsed < 0 {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "limit must be a non-negative integer"})
|
||||
return
|
||||
}
|
||||
limit = parsed
|
||||
}
|
||||
|
||||
walletKey := agent.Claw402WalletKeyForStoreUser(s.store, userID)
|
||||
entries, err := agent.AI500Board(walletKey, limit)
|
||||
if err != nil {
|
||||
SafeInternalError(c, "Get AI500 list", err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": true,
|
||||
"data": gin.H{
|
||||
"coins": entries,
|
||||
"count": len(entries),
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user