Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,15 @@ def pdf_changes(pdf_doc):
|
|
25 |
qa = RetrievalQA.from_chain_type(llm=flan_ul2, chain_type="stuff", retriever=retriever, return_source_documents=True)
|
26 |
return "Ready"
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
def infer(question):
|
29 |
|
30 |
query = question
|
@@ -37,13 +46,16 @@ with gr.Blocks() as demo:
|
|
37 |
pdf_doc = gr.File(label="Load a pdf", file_types=['.pdf'], type="file")
|
38 |
langchain_status = gr.Textbox()
|
39 |
load_pdf = gr.Button("Load pdf to langchain")
|
40 |
-
question = gr.Textbox(label="Your Question")
|
41 |
-
answer = gr.Textbox(label="Anwser")
|
42 |
|
43 |
-
|
|
|
|
|
44 |
|
45 |
load_pdf.click(pdf_changes, pdf_doc, langchain_status, queue=False)
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
48 |
|
49 |
demo.launch()
|
|
|
25 |
qa = RetrievalQA.from_chain_type(llm=flan_ul2, chain_type="stuff", retriever=retriever, return_source_documents=True)
|
26 |
return "Ready"
|
27 |
|
28 |
+
def add_text(history, text):
|
29 |
+
history = history + [(text, None)]
|
30 |
+
return history, ""
|
31 |
+
|
32 |
+
def bot(history):
|
33 |
+
response = infer(history):
|
34 |
+
history[-1][1] = response
|
35 |
+
return history
|
36 |
+
|
37 |
def infer(question):
|
38 |
|
39 |
query = question
|
|
|
46 |
pdf_doc = gr.File(label="Load a pdf", file_types=['.pdf'], type="file")
|
47 |
langchain_status = gr.Textbox()
|
48 |
load_pdf = gr.Button("Load pdf to langchain")
|
|
|
|
|
49 |
|
50 |
+
chatbot = gr.Chatbot([], elem_id="chatbot").style(height=350)
|
51 |
+
question = gr.Textbox(label="Question")
|
52 |
+
|
53 |
|
54 |
load_pdf.click(pdf_changes, pdf_doc, langchain_status, queue=False)
|
55 |
+
|
56 |
+
|
57 |
+
question.submit(add_text, [chatbot, txt], [chatbot, txt]).then(
|
58 |
+
bot, chatbot, chatbot
|
59 |
+
)
|
60 |
|
61 |
demo.launch()
|