MCPcopy Create free account
hub / github.com/InferCore/InferCore / MergeRetrievalIntoInput

Function MergeRetrievalIntoInput

internal/retrieval/merge.go:10–22  ·  view source on GitHub ↗

MergeRetrievalIntoInput writes retrieval/rerank output into req.Input (retrieved_context, retrieved_chunks).

(req *types.AIRequest, res types.RetrievalResult)

Source from the content-addressed store, hash-verified

8
9// MergeRetrievalIntoInput writes retrieval/rerank output into req.Input (retrieved_context, retrieved_chunks).
10func MergeRetrievalIntoInput(req *types.AIRequest, res types.RetrievalResult) {
11 var parts []string
12 var metas []any
13 for _, c := range res.Chunks {
14 parts = append(parts, c.Text)
15 metas = append(metas, map[string]any{"text": c.Text, "source": c.Source, "score": c.Score})
16 }
17 if req.Input == nil {
18 req.Input = map[string]any{}
19 }
20 req.Input["retrieved_context"] = strings.Join(parts, "\n\n")
21 req.Input["retrieved_chunks"] = metas
22}

Callers 2

runRAGRetrieveFunction · 0.92
runRAGPipelineMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected