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

Method newLoader

documentloaders/directory.go:71–92  ·  view source on GitHub ↗
(f *os.File)

Source from the content-addressed store, hash-verified

69}
70
71func (l *RecursiveDirectoryLoader) newLoader(f *os.File) (Loader, error) {
72 ext := filepath.Ext(f.Name())
73 switch ext {
74 case ".txt", ".md":
75 return NewText(f), nil
76 case ".csv":
77 return NewCSV(f, l.Columns...), nil
78 case ".pdf":
79 finfo, err := f.Stat()
80 if err != nil {
81 return nil, err
82 }
83 if l.PDFPassword != "" {
84 return NewPDF(f, finfo.Size(), WithPassword(l.PDFPassword)), nil
85 }
86 return NewPDF(f, finfo.Size()), nil
87 case ".html", ".htm":
88 return NewHTML(f), nil
89 default:
90 return nil, fmt.Errorf("unsupported file extension %q", ext)
91 }
92}
93
94// Load retrieves data from a Notion directory and returns a list of schema.Document objects.
95func (l *RecursiveDirectoryLoader) Load(ctx context.Context) ([]schema.Document, error) {

Callers 1

LoadMethod · 0.95

Calls 6

NewTextFunction · 0.85
NewCSVFunction · 0.85
NewPDFFunction · 0.85
NewHTMLFunction · 0.85
WithPasswordFunction · 0.70
NameMethod · 0.65

Tested by

no test coverage detected