Update app.py
Browse files
app.py
CHANGED
@@ -36,16 +36,25 @@ def pdf_to_text(pdf_file, query):
|
|
36 |
qa = VectorDBQA.from_chain_type(llm=OpenAI(), chain_type="stuff", vectorstore=vectorstore)
|
37 |
return qa.run(query)
|
38 |
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
|
42 |
|
43 |
# Define the Gradio interface
|
44 |
-
pdf_input = [gr.inputs.File(label="PDF File")]
|
45 |
-
query_input = gr.inputs.Textbox(label="Query")
|
46 |
-
outputs = gr.outputs.Textbox(label="Chatbot Response")
|
47 |
|
48 |
-
interface = gr.Interface(fn=pdf_to_text,
|
|
|
|
|
|
|
|
|
49 |
|
50 |
# Run the interface
|
51 |
-
interface.launch(
|
|
|
36 |
qa = VectorDBQA.from_chain_type(llm=OpenAI(), chain_type="stuff", vectorstore=vectorstore)
|
37 |
return qa.run(query)
|
38 |
|
39 |
+
examples = [
|
40 |
+
[os.path.abspath("NASDAQ_AAPL_2020.pdf"), "how much are the outstanding shares ?"],
|
41 |
+
[os.path.abspath("NASDAQ_AAPL_2020.pdf"), "what is competitors strategy ?"],
|
42 |
+
[os.path.abspath("NASDAQ_AAPL_2020.pdf"), "who is the chief executive officer ?"],
|
43 |
+
[os.path.abspath("NASDAQ_MSFT_2020.pdf"), "How much is the guided revenue for next quarter?"]
|
44 |
+
]
|
45 |
|
46 |
|
47 |
|
48 |
# Define the Gradio interface
|
49 |
+
#pdf_input = [gr.inputs.File(label="PDF File")]
|
50 |
+
#query_input = gr.inputs.Textbox(label="Query")
|
51 |
+
#outputs = gr.outputs.Textbox(label="Chatbot Response")
|
52 |
|
53 |
+
interface = gr.Interface(fn=pdf_to_text,
|
54 |
+
inputs= [gr.inputs.File(label="input pdf file"), gr.inputs.Textbox(label="Question:")],
|
55 |
+
outputs =gr.outputs.Textbox(label="Chatbot Response"),
|
56 |
+
examples = examples,
|
57 |
+
title="Q/A")
|
58 |
|
59 |
# Run the interface
|
60 |
+
interface.launch(enable_queue = True)
|