Load reads from the io.Reader and returns a single document with the data.
(_ context.Context)
| 25 | |
| 26 | // Load reads from the io.Reader and returns a single document with the data. |
| 27 | func (l Text) Load(_ context.Context) ([]schema.Document, error) { |
| 28 | buf := new(bytes.Buffer) |
| 29 | _, err := io.Copy(buf, l.r) |
| 30 | if err != nil { |
| 31 | return nil, err |
| 32 | } |
| 33 | |
| 34 | return []schema.Document{ |
| 35 | { |
| 36 | PageContent: buf.String(), |
| 37 | Metadata: map[string]any{}, |
| 38 | }, |
| 39 | }, nil |
| 40 | } |
| 41 | |
| 42 | // LoadAndSplit reads text data from the io.Reader and splits it into multiple |
| 43 | // documents using a text splitter. |