Spaces:
Sleeping
Sleeping
Commit
·
ab70839
1
Parent(s):
f4988ff
Adding sources
Browse files
app.py
CHANGED
|
@@ -59,8 +59,6 @@ def document_loader(file_path,api_key,doc_type='pdf',llm='Huggingface',temperatu
|
|
| 59 |
document = process_csv_document(document_file=file_path)
|
| 60 |
elif doc_type == 'word':
|
| 61 |
document = process_word_document(document_file=file_path)
|
| 62 |
-
|
| 63 |
-
print("Document :",document)
|
| 64 |
embedding_model = SentenceTransformerEmbeddings(model_name='thenlper/gte-base',model_kwargs={"device": DEVICE})
|
| 65 |
|
| 66 |
texts = process_documents(documents=document)
|
|
@@ -77,7 +75,6 @@ def document_loader(file_path,api_key,doc_type='pdf',llm='Huggingface',temperatu
|
|
| 77 |
return_source_documents=True
|
| 78 |
)
|
| 79 |
return "Document Processing completed ..."
|
| 80 |
-
|
| 81 |
|
| 82 |
def process_text_document(document_file):
|
| 83 |
loader = TextLoader(document_file.name)
|
|
@@ -89,20 +86,17 @@ def process_csv_document(document_file):
|
|
| 89 |
document = loader.load()
|
| 90 |
return document
|
| 91 |
|
| 92 |
-
|
| 93 |
def process_word_document(document_file):
|
| 94 |
loader = UnstructuredWordDocumentLoader(file_path=document_file.name)
|
| 95 |
document = loader.load()
|
| 96 |
return document
|
| 97 |
|
| 98 |
-
|
| 99 |
def process_pdf_document(document_file):
|
| 100 |
print("Document File Name :",document_file.name)
|
| 101 |
loader = PDFMinerLoader(document_file.name)
|
| 102 |
document = loader.load()
|
| 103 |
return document
|
| 104 |
|
| 105 |
-
|
| 106 |
def clear_chat():
|
| 107 |
return []
|
| 108 |
|
|
|
|
| 59 |
document = process_csv_document(document_file=file_path)
|
| 60 |
elif doc_type == 'word':
|
| 61 |
document = process_word_document(document_file=file_path)
|
|
|
|
|
|
|
| 62 |
embedding_model = SentenceTransformerEmbeddings(model_name='thenlper/gte-base',model_kwargs={"device": DEVICE})
|
| 63 |
|
| 64 |
texts = process_documents(documents=document)
|
|
|
|
| 75 |
return_source_documents=True
|
| 76 |
)
|
| 77 |
return "Document Processing completed ..."
|
|
|
|
| 78 |
|
| 79 |
def process_text_document(document_file):
|
| 80 |
loader = TextLoader(document_file.name)
|
|
|
|
| 86 |
document = loader.load()
|
| 87 |
return document
|
| 88 |
|
|
|
|
| 89 |
def process_word_document(document_file):
|
| 90 |
loader = UnstructuredWordDocumentLoader(file_path=document_file.name)
|
| 91 |
document = loader.load()
|
| 92 |
return document
|
| 93 |
|
|
|
|
| 94 |
def process_pdf_document(document_file):
|
| 95 |
print("Document File Name :",document_file.name)
|
| 96 |
loader = PDFMinerLoader(document_file.name)
|
| 97 |
document = loader.load()
|
| 98 |
return document
|
| 99 |
|
|
|
|
| 100 |
def clear_chat():
|
| 101 |
return []
|
| 102 |
|