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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user