MCPcopy Create free account
hub / github.com/tmc/langchaingo / Load

Method Load

documentloaders/text.go:27–40  ·  view source on GitHub ↗

Load reads from the io.Reader and returns a single document with the data.

(_ context.Context)

Source from the content-addressed store, hash-verified

25
26// Load reads from the io.Reader and returns a single document with the data.
27func (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.

Callers 2

LoadAndSplitMethod · 0.95
TestTextLoaderFunction · 0.95

Calls 1

StringMethod · 0.65

Tested by 1

TestTextLoaderFunction · 0.76