Spaces:
Runtime error
Runtime error
Commit ·
446dbbb
1
Parent(s): 6814430
Adding status to document loading
Browse files
app.py
CHANGED
|
@@ -43,7 +43,7 @@ def chat_application(llm_model,key):
|
|
| 43 |
llm_model = get_openai_chat_model(API_key=key)
|
| 44 |
|
| 45 |
|
| 46 |
-
def document_loader(file_data,doc_type='pdf',key=None
|
| 47 |
embedding_model = SentenceTransformerEmbeddings(model_name='all-mpnet-base-v2',model_kwargs={"device": DEVICE})
|
| 48 |
document = None
|
| 49 |
if doc_type == 'pdf':
|
|
@@ -64,10 +64,6 @@ def document_loader(file_data,doc_type='pdf',key=None,llm_model='HuggingFace'):
|
|
| 64 |
|
| 65 |
return "Document loaded - Embeddings ready "
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
|
| 72 |
def process_text_document(document_file_name):
|
| 73 |
loader = TextLoader(document_file_name)
|
|
@@ -94,8 +90,6 @@ def process_pdf_document(document_file_name):
|
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
-
|
| 98 |
-
|
| 99 |
css="""
|
| 100 |
#col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
|
| 101 |
"""
|
|
@@ -130,7 +124,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 130 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
|
| 131 |
submit_button = gr.Button("Send Message")
|
| 132 |
load_pdf.click(loading_file, None, langchain_status, queue=False)
|
| 133 |
-
load_pdf.click(
|
| 134 |
# question.submit(add_text, [chatbot, question], [chatbot, question]).then(
|
| 135 |
# bot, chatbot, chatbot
|
| 136 |
# )
|
|
|
|
| 43 |
llm_model = get_openai_chat_model(API_key=key)
|
| 44 |
|
| 45 |
|
| 46 |
+
def document_loader(file_data,doc_type='pdf',key=None):
|
| 47 |
embedding_model = SentenceTransformerEmbeddings(model_name='all-mpnet-base-v2',model_kwargs={"device": DEVICE})
|
| 48 |
document = None
|
| 49 |
if doc_type == 'pdf':
|
|
|
|
| 64 |
|
| 65 |
return "Document loaded - Embeddings ready "
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
def process_text_document(document_file_name):
|
| 69 |
loader = TextLoader(document_file_name)
|
|
|
|
| 90 |
|
| 91 |
|
| 92 |
|
|
|
|
|
|
|
| 93 |
css="""
|
| 94 |
#col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
|
| 95 |
"""
|
|
|
|
| 124 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
|
| 125 |
submit_button = gr.Button("Send Message")
|
| 126 |
load_pdf.click(loading_file, None, langchain_status, queue=False)
|
| 127 |
+
load_pdf.click(document_loader, inputs=[pdf_doc,file_extension,API_key], outputs=[langchain_status], queue=False)
|
| 128 |
# question.submit(add_text, [chatbot, question], [chatbot, question]).then(
|
| 129 |
# bot, chatbot, chatbot
|
| 130 |
# )
|