feat: 更新 Server 后端服务

- 更新 agent handler 和 service 层
- 新增 chat_group handler 和 service
- 删除废弃的 chat_handler
- 更新 tool 相关处理
- 更新 API 文档和依赖

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 21:26:27 +08:00
parent 237ab9f6d7
commit 71e8cc59d5
24 changed files with 5007 additions and 347 deletions

View File

@@ -164,3 +164,46 @@ func (h *ToolHandler) Delete(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "tool deleted"})
}
// SyncFromPythonRequest 从Python同步工具请求
type SyncFromPythonRequest struct {
Tools []PythonTool `json:"tools" binding:"required"`
}
// PythonTool Python端工具结构
type PythonTool struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters string `json:"parameters"`
Category string `json:"category"`
}
// SyncFromPython 从Python端同步工具
// @Summary 从Python端同步工具
// @Description 接收Python Agent同步过来的工具列表并存储到数据库
// @Tags 工具管理
// @Accept json
// @Produce json
// @Param tools body SyncFromPythonRequest true "工具列表"
// @Success 200 {object} map[string]interface{}
// @Router /tool/sync-from-python [post]
func (h *ToolHandler) SyncFromPython(c *gin.Context) {
var req struct {
Tools []map[string]interface{} `json:"tools" binding:"required"`
}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
count, err := h.toolService.SyncToolsFromPython(req.Tools)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{
"message": "tools synced from python",
"synced_count": count,
})
}