SearchEntityFiles godoc @Summary 根据实体名称搜索文件 @Description 根据实体名称在向量库中检索,返回命中的实体信息、分数及关联的文件ID列表 @Tags 实体管理 @Accept json @Produce json @Security BearerAuth @Param name query string true "实体名称" @Param top_k query int false "返回结果数量" default(10) @Success 200 {object} model.CommonResponse{data=[]rag.Entity
(c *gin.Context)
| 633 | // @Success 200 {object} model.CommonResponse{data=[]rag.EntitySearchHit} |
| 634 | // @Router /api/entities/search-files [get] |
| 635 | func SearchEntityFiles(c *gin.Context) { |
| 636 | eid := config.GetEID(c) |
| 637 | if eid <= 0 { |
| 638 | c.JSON(http.StatusBadRequest, model.ParamError.ToNewErrorResponse(model.InvalidEnterpriseID)) |
| 639 | return |
| 640 | } |
| 641 | |
| 642 | var req SearchEntityFilesRequest |
| 643 | if err := c.ShouldBindQuery(&req); err != nil { |
| 644 | c.JSON(http.StatusBadRequest, model.ParamError.ToResponse(err)) |
| 645 | return |
| 646 | } |
| 647 | |
| 648 | svc := rag.NewEntityVectorService(model.DB) |
| 649 | hits, err := svc.SearchEntityFiles(eid, req.Name, req.TopK) |
| 650 | if err != nil { |
| 651 | c.JSON(http.StatusInternalServerError, model.SystemError.ToResponse(err)) |
| 652 | return |
| 653 | } |
| 654 | |
| 655 | c.JSON(http.StatusOK, model.Success.ToResponse(hits)) |
| 656 | } |
nothing calls this directly
no test coverage detected