feat: 添加智能体文件类型限制,内置数据分析师智能体
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/errors"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
@@ -791,11 +792,12 @@ func (h *KnowledgeHandler) UpdateImageInfo(c *gin.Context) {
|
||||
// @Tags Knowledge
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param keyword query string false "Keyword to search"
|
||||
// @Param offset query int false "Offset for pagination"
|
||||
// @Param limit query int false "Limit for pagination (default 20)"
|
||||
// @Success 200 {object} map[string]interface{} "Search results"
|
||||
// @Failure 400 {object} errors.AppError "Invalid request"
|
||||
// @Param keyword query string false "Keyword to search"
|
||||
// @Param offset query int false "Offset for pagination"
|
||||
// @Param limit query int false "Limit for pagination (default 20)"
|
||||
// @Param file_types query string false "Comma-separated file extensions to filter (e.g., csv,xlsx)"
|
||||
// @Success 200 {object} map[string]interface{} "Search results"
|
||||
// @Failure 400 {object} errors.AppError "Invalid request"
|
||||
// @Security Bearer
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /knowledge/search [get]
|
||||
@@ -805,8 +807,19 @@ func (h *KnowledgeHandler) SearchKnowledge(c *gin.Context) {
|
||||
offset, _ := strconv.Atoi(c.DefaultQuery("offset", "0"))
|
||||
limit, _ := strconv.Atoi(c.DefaultQuery("limit", "20"))
|
||||
|
||||
// Parse file_types parameter (comma-separated)
|
||||
var fileTypes []string
|
||||
if fileTypesStr := c.Query("file_types"); fileTypesStr != "" {
|
||||
for _, ft := range strings.Split(fileTypesStr, ",") {
|
||||
ft = strings.TrimSpace(ft)
|
||||
if ft != "" {
|
||||
fileTypes = append(fileTypes, ft)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve knowledge entries (empty keyword returns recent files)
|
||||
knowledges, hasMore, err := h.kgService.SearchKnowledge(ctx, keyword, offset, limit)
|
||||
knowledges, hasMore, err := h.kgService.SearchKnowledge(ctx, keyword, offset, limit, fileTypes)
|
||||
if err != nil {
|
||||
logger.ErrorWithFields(ctx, err, nil)
|
||||
c.Error(errors.NewInternalServerError("Failed to search knowledge").WithDetails(err.Error()))
|
||||
|
||||
Reference in New Issue
Block a user