MCPcopy Create free account
hub / github.com/Chainlit/cookbook / process_file

Function process_file

pdf-qa/app.py:34–45  ·  view source on GitHub ↗
(file: AskFileResponse)

Source from the content-addressed store, hash-verified

32
33
34def process_file(file: AskFileResponse):
35 if file.type == "text/plain":
36 Loader = TextLoader
37 elif file.type == "application/pdf":
38 Loader = PyPDFLoader
39
40 loader = Loader(file.path)
41 documents = loader.load()
42 docs = text_splitter.split_documents(documents)
43 for i, doc in enumerate(docs):
44 doc.metadata["source"] = f"source_{i}"
45 return docs
46
47
48def get_docsearch(file: AskFileResponse):

Callers 1

get_docsearchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected