- Implemented UpdateAssistant method in Mongo, Redis, and Xun stores to allow partial updates of assistant fields. - Updated Store interface to include the new UpdateAssistant method, enhancing the flexibility of assistant management. - Added comprehensive tests for UpdateAssistant functionality, covering various scenarios including single and multiple field updates, JSON field handling, and error cases. - Updated API routes to support PUT requests for updating assistants, ensuring proper permission checks and response handling.
29 lines
1.3 KiB
Go
29 lines
1.3 KiB
Go
package agent
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/yaoapp/yao/agent"
|
|
"github.com/yaoapp/yao/openapi/oauth/types"
|
|
)
|
|
|
|
// Attach attaches the agent (assistant) API handlers to the router with OAuth protection
|
|
// This provides OAuth-protected endpoints for assistant management, mirroring the agent assistant API
|
|
func Attach(group *gin.RouterGroup, oauth types.OAuth) {
|
|
|
|
// Get the Agent instance
|
|
n := agent.GetAgent()
|
|
|
|
// Apply OAuth guard to all routes
|
|
group.Use(oauth.Guard)
|
|
|
|
// Assistant CRUD - Standard REST endpoints
|
|
group.GET("/assistants", ListAssistants) // GET /assistants - List assistants
|
|
group.POST("/assistants", CreateAssistant) // POST /assistants - Create assistant
|
|
group.GET("/assistants/tags", ListAssistantTags) // GET /assistants/tags - Get all assistant tags with permission filtering
|
|
group.GET("/assistants/:id", GetAssistant) // GET /assistants/:id - Get assistant details with permission verification
|
|
group.PUT("/assistants/:id", UpdateAssistant) // PUT /assistants/:id - Update assistant
|
|
group.DELETE("/assistants/:id", n.HandleAssistantDelete) // DELETE /assistants/:id - Delete assistant
|
|
|
|
// Assistant Actions
|
|
group.POST("/assistants/:id/call", n.HandleAssistantCall) // POST /assistants/:id/call - Execute assistant API
|
|
}
|