yao/openapi/chat/chat.go
Max 7285972aa9 Add endpoint to append messages to running completions
- Introduced a new POST endpoint `/completions/:context_id/append` to allow appending messages to ongoing chat completions.
- Implemented `GinAppendMessages` function to handle request validation, including context ID and message requirements.
- Added `AppendMessagesRequest` struct to define the request body format, ensuring proper handling of interrupt types and messages.
- Enhanced error responses for invalid requests to improve user feedback and debugging capabilities.
2025-11-22 18:15:40 +08:00

40 lines
1 KiB
Go

package chat
import (
"github.com/gin-gonic/gin"
"github.com/yaoapp/yao/openapi/oauth/types"
"github.com/yaoapp/yao/openapi/response"
)
// Attach attaches the agent handlers to the router
func Attach(group *gin.RouterGroup, oauth types.OAuth) {
// Protect all endpoints with OAuth
group.Use(oauth.Guard)
// List Chat Completions
group.GET("/completions", placeholder)
// Create Chat Completion
group.POST("/completions", GinCreateCompletions)
// Update Chat Completion Metadata
group.PUT("/completions", GinUpdateCompletions)
// Get Chat Completion Details
group.GET("/completions/:completion_id", placeholder)
// Get Chat Messages
group.GET("/completions/:completion_id/messages", placeholder)
// Delete Chat Completion
group.DELETE("/completions/:completion_id", placeholder)
// Append messages to running completion
group.POST("/completions/:context_id/append", GinAppendMessages)
}
func placeholder(c *gin.Context) {
response.RespondWithSuccess(c, response.StatusOK, gin.H{"message": "placeholder"})
}