MCPcopy Create free account
hub / github.com/CL-lau/SQL-GPT / load_documents

Method load_documents

model/data_connection.py:36–56  ·  view source on GitHub ↗

Loading PDF, Docx, CSV

(
        file: str,
        filetype: str = '.pdf'
    )

Source from the content-addressed store, hash-verified

34
35 @staticmethod
36 def load_documents(
37 file: str,
38 filetype: str = '.pdf'
39 ) -> list[Document] | list[Any]:
40 #) -> Union[CSVLoader, Docx2txtLoader, PyMuPDFLoader, TextLoader]:
41 """Loading PDF, Docx, CSV"""
42 try:
43 if filetype == '.pdf':
44 loader = PyMuPDFLoader(file)
45 elif filetype == '.docx':
46 loader = Docx2txtLoader(file)
47 elif filetype == '.csv':
48 loader = CSVLoader(file, encoding='utf-8')
49 elif filetype == '.txt':
50 loader = TextLoader(file, encoding='utf-8')
51
52 return loader.load()
53
54 except Exception as e:
55 print(f'\033[31m{e}')
56 return []
57
58 @staticmethod
59 def split_documents(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected