- Introduced the Knowledge Base (KB) API by creating a new kb package with various endpoints for collection and document management, segment management, and search functionalities. - Updated the OpenAPI router to attach the KB API, ensuring OAuth protection for all endpoints. - Implemented logging for configuration validation to enhance error handling and user feedback.
38 lines
1 KiB
Go
38 lines
1 KiB
Go
package kb
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/yaoapp/yao/kb"
|
|
)
|
|
|
|
// Collection Management Handlers
|
|
|
|
// CreateCollection creates a new collection
|
|
func CreateCollection(c *gin.Context) {
|
|
// TODO: Implement create collection logic
|
|
c.JSON(http.StatusCreated, gin.H{"message": "Collection created"})
|
|
}
|
|
|
|
// RemoveCollection removes an existing collection
|
|
func RemoveCollection(c *gin.Context) {
|
|
// TODO: Implement remove collection logic
|
|
c.JSON(http.StatusOK, gin.H{"message": "Collection removed"})
|
|
}
|
|
|
|
// CollectionExists checks if a collection exists
|
|
func CollectionExists(c *gin.Context) {
|
|
// TODO: Implement collection exists check logic
|
|
c.JSON(http.StatusOK, gin.H{"exists": false})
|
|
}
|
|
|
|
// GetCollections retrieves collections with optional filtering
|
|
func GetCollections(c *gin.Context) {
|
|
collections, err := kb.Instance.GetCollections(c.Request.Context(), map[string]interface{}{})
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, collections)
|
|
}
|