lekkalar commited on
Commit
11f2063
1 Parent(s): 6939f3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -34,12 +34,10 @@ def pdf_changes(pdf_doc, open_ai_key):
34
  return "Please provide an OpenAI API key"
35
 
36
 
37
- def infer(question):
38
- query = question
39
- result = pdf_qa({"question": query})
40
- print(result)
41
- return result["answer"]
42
-
43
  css="""
44
  #col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
45
  """
@@ -68,12 +66,10 @@ with gr.Blocks(css=css) as demo:
68
  chatbot = gr.Chatbot([], elem_id="chatbot").style(height=350)
69
  question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter ")
70
  submit_btn = gr.Button("Send Message")
 
71
  load_pdf.click(loading_pdf, None, langchain_status, queue=False)
72
  load_pdf.click(pdf_changes, inputs=[pdf_doc, openai_key], outputs=[langchain_status], queue=False)
73
- question.submit( [chatbot, question], [chatbot, question]).then(
74
- bot, chatbot, chatbot
75
- )
76
- submit_btn.click( [chatbot, question], [chatbot, question]).then(
77
- bot, chatbot, chatbot)
78
 
79
  demo.launch()
 
34
  return "Please provide an OpenAI API key"
35
 
36
 
37
+ def answer_query(query):
38
+ question = query
39
+ return pdf_qa.run(question)
40
+
 
 
41
  css="""
42
  #col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
43
  """
 
66
  chatbot = gr.Chatbot([], elem_id="chatbot").style(height=350)
67
  question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter ")
68
  submit_btn = gr.Button("Send Message")
69
+
70
  load_pdf.click(loading_pdf, None, langchain_status, queue=False)
71
  load_pdf.click(pdf_changes, inputs=[pdf_doc, openai_key], outputs=[langchain_status], queue=False)
72
+ submit_query.click(answer_query,inputs,ouputs)
73
+
 
 
 
74
 
75
  demo.launch()