fix: 搜索走 SearXNG + 工具调用分页修复

- ai-core DevTools 启动配置补充 SEARXNG_URL,避免回退到 DuckDuckGo 导致超时
- 工具调用 API 加入 offset 分页,修复 page 参数不生效问题
- 响应新增 total_pages 字段,修复前端分页栏不渲染

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-26 20:58:37 +08:00
parent dffaf7e123
commit 12e9f7da6e
3 changed files with 38 additions and 21 deletions
+13 -7
View File
@@ -397,19 +397,25 @@ func main() {
if limit > 500 {
limit = 500
}
calls := toolRegistry.GetCallLogs(toolName, limit)
if calls == nil {
calls = []plgManager.CallLogRecord{}
}
page, _ := strconv.Atoi(r.URL.Query().Get("page"))
page, _ := strconv.Atoi(r.URL.Query().Get("page"))
if page < 1 {
page = 1
}
offset := (page - 1) * limit
calls, total := toolRegistry.GetCallLogs(toolName, limit, offset)
if calls == nil {
calls = []plgManager.CallLogRecord{}
}
totalPages := total / limit
if total%limit != 0 {
totalPages++
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]interface{}{
"calls": calls, "total": len(calls), "page": page, "limit": limit,
"calls": calls, "total": total, "total_pages": totalPages,
"page": page, "limit": limit,
})
})
})
// 工具调用统计
mux.HandleFunc("/api/v1/tools/calls/stats", func(w http.ResponseWriter, r *http.Request) {