Spaces:
Sleeping
Sleeping
Commit
·
3edae51
1
Parent(s):
1c52547
adding online PDF loader
Browse files
app.py
CHANGED
@@ -44,17 +44,17 @@ def chat_application(llm_service,key):
|
|
44 |
llm_model = get_openai_chat_model(API_key=key)
|
45 |
|
46 |
|
47 |
-
def document_loader(
|
48 |
embedding_model = SentenceTransformerEmbeddings(model_name='all-mpnet-base-v2',model_kwargs={"device": DEVICE})
|
49 |
document = None
|
50 |
if doc_type == 'pdf':
|
51 |
-
document = process_pdf_document(document_file=
|
52 |
elif doc_type == 'text':
|
53 |
-
document = process_text_document(document_file=
|
54 |
elif doc_type == 'csv':
|
55 |
-
document = process_csv_document(document_file=
|
56 |
elif doc_type == 'word':
|
57 |
-
document = process_word_document(document_file=
|
58 |
if document:
|
59 |
texts = process_documents(documents=document)
|
60 |
vector_db = FAISS.from_documents(documents=texts, embedding= embedding_model)
|
|
|
44 |
llm_model = get_openai_chat_model(API_key=key)
|
45 |
|
46 |
|
47 |
+
def document_loader(file_path,api_key,doc_type='pdf',llm='Huggingface'):
|
48 |
embedding_model = SentenceTransformerEmbeddings(model_name='all-mpnet-base-v2',model_kwargs={"device": DEVICE})
|
49 |
document = None
|
50 |
if doc_type == 'pdf':
|
51 |
+
document = process_pdf_document(document_file=file_path)
|
52 |
elif doc_type == 'text':
|
53 |
+
document = process_text_document(document_file=file_path)
|
54 |
elif doc_type == 'csv':
|
55 |
+
document = process_csv_document(document_file=file_path)
|
56 |
elif doc_type == 'word':
|
57 |
+
document = process_word_document(document_file=file_path)
|
58 |
if document:
|
59 |
texts = process_documents(documents=document)
|
60 |
vector_db = FAISS.from_documents(documents=texts, embedding= embedding_model)
|