Spaces:
Runtime error
Runtime error
Commit
·
efb89c8
1
Parent(s):
d5435f4
Update app.py
Browse files
app.py
CHANGED
@@ -166,20 +166,42 @@ recommender = SemanticSearch()
|
|
166 |
title = 'PDF GPT'
|
167 |
description = """ PDF GPT allows you to chat with your PDF file using Universal Sentence Encoder and Open AI. It gives hallucination free response than other tools as the embeddings are better than OpenAI. The returned response can even cite the page number in square brackets([]) where the information is located, adding credibility to the responses and helping to locate pertinent information quickly."""
|
168 |
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
with gr.Blocks() as demo:
|
171 |
-
|
172 |
gr.Markdown(f'<center><h1>{title}</h1></center>')
|
173 |
gr.Markdown(description)
|
174 |
|
175 |
with gr.Row():
|
176 |
-
|
177 |
with gr.Group():
|
178 |
gr.Markdown(f'<p style="text-align:center">Get your Open AI API key <a href="https://platform.openai.com/account/api-keys">here</a></p>')
|
179 |
openAI_key=gr.Textbox(label='Enter your OpenAI API key here')
|
180 |
url = gr.Textbox(label='Enter PDF URL here')
|
181 |
gr.Markdown("<center><h4>OR<h4></center>")
|
182 |
file = gr.File(label='Upload your PDF/ Research Paper / Book here', file_types=['.pdf'])
|
|
|
|
|
|
|
183 |
question = gr.Textbox(label='Enter your question here')
|
184 |
btn = gr.Button(value='Submit')
|
185 |
btn.style(full_width=True)
|
@@ -187,6 +209,7 @@ with gr.Blocks() as demo:
|
|
187 |
with gr.Group():
|
188 |
answer = gr.Textbox(label='The answer to your question is :')
|
189 |
|
190 |
-
btn.click(question_answer, inputs=[url, file, question,openAI_key], outputs=[answer])
|
|
|
191 |
#openai.api_key = os.getenv('Your_Key_Here')
|
192 |
demo.launch()
|
|
|
166 |
title = 'PDF GPT'
|
167 |
description = """ PDF GPT allows you to chat with your PDF file using Universal Sentence Encoder and Open AI. It gives hallucination free response than other tools as the embeddings are better than OpenAI. The returned response can even cite the page number in square brackets([]) where the information is located, adding credibility to the responses and helping to locate pertinent information quickly."""
|
168 |
|
169 |
+
questions = [
|
170 |
+
"what did the study investigate?",
|
171 |
+
"what are the methods used in this study?",
|
172 |
+
"what are the data intervals used in this study? Give me the start dates and end dates?",
|
173 |
+
"what are the main limitations of this study?",
|
174 |
+
"what are the main shortcomings of this study?",
|
175 |
+
"what are the main findings of the study?",
|
176 |
+
"what are the main results of the study?",
|
177 |
+
"what are the input features used in this study?",
|
178 |
+
"what is the dependent variable in this study?"
|
179 |
+
]
|
180 |
+
question = gr.Textbox(label='Enter your question here')
|
181 |
+
|
182 |
+
# Create a button for each question, which will call set_question_text when clicked
|
183 |
+
question_buttons = [gr.Button(f"{q}", fn=set_question_text) for q in questions]
|
184 |
+
|
185 |
+
|
186 |
+
# Create a function to set the text of the question Textbox
|
187 |
+
def set_question_text(q):
|
188 |
+
question.set_value(q)
|
189 |
+
|
190 |
+
# Add the question buttons to the Gradio interface
|
191 |
with gr.Blocks() as demo:
|
|
|
192 |
gr.Markdown(f'<center><h1>{title}</h1></center>')
|
193 |
gr.Markdown(description)
|
194 |
|
195 |
with gr.Row():
|
|
|
196 |
with gr.Group():
|
197 |
gr.Markdown(f'<p style="text-align:center">Get your Open AI API key <a href="https://platform.openai.com/account/api-keys">here</a></p>')
|
198 |
openAI_key=gr.Textbox(label='Enter your OpenAI API key here')
|
199 |
url = gr.Textbox(label='Enter PDF URL here')
|
200 |
gr.Markdown("<center><h4>OR<h4></center>")
|
201 |
file = gr.File(label='Upload your PDF/ Research Paper / Book here', file_types=['.pdf'])
|
202 |
+
# Add the question buttons to the Gradio interface
|
203 |
+
for btn in question_buttons:
|
204 |
+
gr.Block(btn)
|
205 |
question = gr.Textbox(label='Enter your question here')
|
206 |
btn = gr.Button(value='Submit')
|
207 |
btn.style(full_width=True)
|
|
|
209 |
with gr.Group():
|
210 |
answer = gr.Textbox(label='The answer to your question is :')
|
211 |
|
212 |
+
btn.click(question_answer, inputs=[url, file, question, openAI_key], outputs=[answer])
|
213 |
+
|
214 |
#openai.api_key = os.getenv('Your_Key_Here')
|
215 |
demo.launch()
|