Spaces:
Sleeping
Sleeping
Commit
·
4d8a5d0
1
Parent(s):
57005dc
adding summarization
Browse files
app.py
CHANGED
@@ -44,6 +44,9 @@ def chat_application(llm_service,key):
|
|
44 |
llm = get_openai_chat_model(API_key=key)
|
45 |
return llm
|
46 |
|
|
|
|
|
|
|
47 |
|
48 |
def document_loader(file_path,api_key,doc_type='pdf',llm='Huggingface'):
|
49 |
embedding_model = SentenceTransformerEmbeddings(model_name='all-mpnet-base-v2',model_kwargs={"device": DEVICE})
|
@@ -126,15 +129,20 @@ with gr.Blocks(css=css) as demo:
|
|
126 |
pdf_doc = gr.File(label="Upload File to start QA", file_types=FILE_EXT, type="file")
|
127 |
with gr.Row():
|
128 |
langchain_status = gr.Textbox(label="Status", placeholder="", interactive=True)
|
129 |
-
load_pdf = gr.Button("Upload
|
130 |
-
|
|
|
|
|
|
|
131 |
chatbot = gr.Chatbot()
|
132 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
|
133 |
submit_button = gr.Button("Send Message")
|
134 |
-
|
135 |
load_pdf.click(loading_file, None, langchain_status, queue=False)
|
136 |
load_pdf.click(document_loader, inputs=[pdf_doc,API_key,file_extension,LLM_option], outputs=[langchain_status], queue=False)
|
137 |
|
|
|
|
|
138 |
# question.submit(add_text, [chatbot, question], [chatbot, question]).then(
|
139 |
# bot, chatbot, chatbot
|
140 |
# )
|
|
|
44 |
llm = get_openai_chat_model(API_key=key)
|
45 |
return llm
|
46 |
|
47 |
+
def summarize_contents():
|
48 |
+
question = "Generate a summary of the contents. Do not return the response in json format"
|
49 |
+
return qa.run(question)
|
50 |
|
51 |
def document_loader(file_path,api_key,doc_type='pdf',llm='Huggingface'):
|
52 |
embedding_model = SentenceTransformerEmbeddings(model_name='all-mpnet-base-v2',model_kwargs={"device": DEVICE})
|
|
|
129 |
pdf_doc = gr.File(label="Upload File to start QA", file_types=FILE_EXT, type="file")
|
130 |
with gr.Row():
|
131 |
langchain_status = gr.Textbox(label="Status", placeholder="", interactive=True)
|
132 |
+
load_pdf = gr.Button("Upload File & Generate Embeddings",).style(full_width=False)
|
133 |
+
with gr.Row():
|
134 |
+
summary = gr.Textbox(label="Summary")
|
135 |
+
summarize_pdf = gr.Button("Summarize the Contents").style(full_width=False)
|
136 |
+
|
137 |
chatbot = gr.Chatbot()
|
138 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
|
139 |
submit_button = gr.Button("Send Message")
|
140 |
+
|
141 |
load_pdf.click(loading_file, None, langchain_status, queue=False)
|
142 |
load_pdf.click(document_loader, inputs=[pdf_doc,API_key,file_extension,LLM_option], outputs=[langchain_status], queue=False)
|
143 |
|
144 |
+
summarize_pdf.click(summarize_contents,outputs=summary)
|
145 |
+
|
146 |
# question.submit(add_text, [chatbot, question], [chatbot, question]).then(
|
147 |
# bot, chatbot, chatbot
|
148 |
# )
|