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

Function parseHTTPChunksJSON

internal/retrieval/http_kb.go:101–126  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

99}
100
101func parseHTTPChunksJSON(b []byte) (types.RetrievalResult, error) {
102 var env httpChunksEnvelope
103 if err := json.Unmarshal(b, &env); err != nil {
104 return types.RetrievalResult{}, fmt.Errorf("decode retrieval json: %w", err)
105 }
106 list := env.Chunks
107 if len(list) == 0 {
108 list = env.Results
109 }
110 out := make([]types.RetrievalChunk, 0, len(list))
111 for _, el := range list {
112 text := strings.TrimSpace(el.Text)
113 if text == "" {
114 text = strings.TrimSpace(el.Content)
115 }
116 if text == "" {
117 continue
118 }
119 out = append(out, types.RetrievalChunk{
120 Text: text,
121 Source: el.Source,
122 Score: el.Score,
123 })
124 }
125 return types.RetrievalResult{Chunks: out}, nil
126}

Callers 1

RetrieveMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected