MCPcopy Create free account
hub / github.com/astercloud/aster / multiSourceRetrieval

Method multiSourceRetrieval

pkg/knowledge/rag.go:331–359  ·  view source on GitHub ↗

私有方法 multiSourceRetrieval 多源检索

(ctx context.Context, query string, opts *RAGOptions)

Source from the content-addressed store, hash-verified

329
330// multiSourceRetrieval 多源检索
331func (r *RAG) multiSourceRetrieval(ctx context.Context, query string, opts *RAGOptions) ([]*RetrievalItem, error) {
332 var allItems []*RetrievalItem
333
334 // 文本搜索
335 if r.config.TextSearchWeight > 0 {
336 textItems, err := r.textSearch(ctx, query, opts)
337 if err == nil {
338 allItems = append(allItems, textItems...)
339 }
340 }
341
342 // 向量搜索
343 if r.config.VectorSearchWeight > 0 {
344 vectorItems, err := r.vectorSearch(ctx, query, opts)
345 if err == nil {
346 allItems = append(allItems, vectorItems...)
347 }
348 }
349
350 // 图搜索
351 if r.config.GraphSearchWeight > 0 {
352 graphItems, err := r.graphSearch(ctx, query, opts)
353 if err == nil {
354 allItems = append(allItems, graphItems...)
355 }
356 }
357
358 return allItems, nil
359}
360
361// textSearch 文本搜索
362func (r *RAG) textSearch(ctx context.Context, query string, opts *RAGOptions) ([]*RetrievalItem, error) {

Callers 1

RetrieveMethod · 0.95

Calls 3

textSearchMethod · 0.95
vectorSearchMethod · 0.95
graphSearchMethod · 0.95

Tested by

no test coverage detected