Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,19 +47,11 @@ def pdf_changes(pdf_doc):
|
|
| 47 |
)
|
| 48 |
return "Ready"
|
| 49 |
|
| 50 |
-
def
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
response = infer(history[-1][0] , history)
|
| 56 |
-
history[-1][1] = response['answer']
|
| 57 |
-
return history
|
| 58 |
-
|
| 59 |
-
def infer(question , history):
|
| 60 |
-
hist = history[:-1]
|
| 61 |
-
result = qa({'question': question , 'chat_history': hist})
|
| 62 |
-
return result
|
| 63 |
|
| 64 |
css="""
|
| 65 |
#col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
|
|
@@ -82,12 +74,8 @@ with gr.Blocks(css=css) as demo:
|
|
| 82 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter ")
|
| 83 |
submit_btn = gr.Button("Send message")
|
| 84 |
load_pdf.click(pdf_changes, inputs=[pdf_doc], outputs=[langchain_status], queue=False)
|
| 85 |
-
question.submit(
|
| 86 |
-
|
| 87 |
-
)
|
| 88 |
-
submit_btn.click(add_text, [chatbot, question], [chatbot, question]).then(
|
| 89 |
-
bot, chatbot, chatbot
|
| 90 |
-
)
|
| 91 |
|
| 92 |
demo.launch()
|
| 93 |
|
|
|
|
| 47 |
)
|
| 48 |
return "Ready"
|
| 49 |
|
| 50 |
+
def text(history, text):
|
| 51 |
+
result = qa_chain({'question': text, 'chat_history': history})
|
| 52 |
+
history.append((text, result['answer']))
|
| 53 |
+
|
| 54 |
+
return history,""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
css="""
|
| 57 |
#col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
|
|
|
|
| 74 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter ")
|
| 75 |
submit_btn = gr.Button("Send message")
|
| 76 |
load_pdf.click(pdf_changes, inputs=[pdf_doc], outputs=[langchain_status], queue=False)
|
| 77 |
+
question.submit(text, [chatbot, question], [chatbot, question])
|
| 78 |
+
submit_btn.click(text, [chatbot, question], [chatbot, question])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
demo.launch()
|
| 81 |
|