MergeRetrievalIntoInput writes retrieval/rerank output into req.Input (retrieved_context, retrieved_chunks).
(req *types.AIRequest, res types.RetrievalResult)
| 8 | |
| 9 | // MergeRetrievalIntoInput writes retrieval/rerank output into req.Input (retrieved_context, retrieved_chunks). |
| 10 | func 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 | } |
no outgoing calls
no test coverage detected