MCPcopy Create free account
hub / github.com/53AI/53AIHub / resolveBatchCollection

Method resolveBatchCollection

api/service/rag/search.go:756–781  ·  view source on GitHub ↗
(eid int64, reqs []*SearchRequest)

Source from the content-addressed store, hash-verified

754}
755
756func (s *SearchService) resolveBatchCollection(eid int64, reqs []*SearchRequest) (string, error) {
757 if len(reqs) == 0 {
758 return "", fmt.Errorf("搜索请求不能为空")
759 }
760 if len(reqs[0].LibraryIDs) != 1 {
761 return "", fmt.Errorf("批量搜索仅支持单知识库")
762 }
763
764 libraryID := reqs[0].LibraryIDs[0]
765 for i := 1; i < len(reqs); i++ {
766 if len(reqs[i].LibraryIDs) != 1 || reqs[i].LibraryIDs[0] != libraryID {
767 return "", fmt.Errorf("批量搜索需要相同的知识库范围")
768 }
769 }
770
771 libraries, err := s.batchGetLibrariesByIDs(eid, []int64{libraryID})
772 if err != nil {
773 return "", err
774 }
775 library, ok := libraries[libraryID]
776 if !ok || library == nil {
777 return "", fmt.Errorf("知识库不存在: %d", libraryID)
778 }
779
780 return model.GetVectorCollectionName(library.UUID), nil
781}
782
783func (s *SearchService) resolveBatchCollections(eid int64, reqs []*SearchRequest) ([]batchVectorCollection, error) {
784 if len(reqs) == 0 {

Callers

nothing calls this directly

Calls 2

ErrorfMethod · 0.80

Tested by

no test coverage detected