Spaces:
Running
Running
Commit
·
7f71192
1
Parent(s):
3501948
Update app.py
Browse files
app.py
CHANGED
@@ -155,30 +155,37 @@ def question_answer(url, file, question):
|
|
155 |
load_recommender(file_name)
|
156 |
|
157 |
if question.strip() == '':
|
158 |
-
return '[ERROR]: Question field is empty
|
159 |
|
160 |
return generate_answer(question)
|
161 |
|
162 |
|
163 |
title = 'PDF GPT'
|
164 |
description = """PDF GPT allows you to chat with a PDF file using GPT functionalities. The application intelligently breaks the document into smaller chunks and employs a powerful Deep Averaging Network Encoder to generate embeddings. To generate a summary for each chunk, PDF GPT utilizes Open AI as its data layer.
|
165 |
-
PDF GPT uses a KNN algorithm to return the top-n embedding from each chunk and uses
|
166 |
can even provide the page number where the information is located, adding credibility to the responses and helping to locate pertinent information quickly."""
|
167 |
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
)
|
180 |
-
|
181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
|
183 |
|
184 |
# import streamlit as st
|
|
|
155 |
load_recommender(file_name)
|
156 |
|
157 |
if question.strip() == '':
|
158 |
+
return '[ERROR]: Question field is empty
|
159 |
|
160 |
return generate_answer(question)
|
161 |
|
162 |
|
163 |
title = 'PDF GPT'
|
164 |
description = """PDF GPT allows you to chat with a PDF file using GPT functionalities. The application intelligently breaks the document into smaller chunks and employs a powerful Deep Averaging Network Encoder to generate embeddings. To generate a summary for each chunk, PDF GPT utilizes Open AI as its data layer.
|
165 |
+
PDF GPT uses a KNN algorithm to return the top-n embedding from each chunk and uses custom logic to generate a response. The application also leverages important document sections to generate precise responses, and
|
166 |
can even provide the page number where the information is located, adding credibility to the responses and helping to locate pertinent information quickly."""
|
167 |
|
168 |
+
with gr.Blocks() as demo:
|
169 |
+
|
170 |
+
gr.Markdown(f'<center><h1>{title}</h1></center>')
|
171 |
+
gr.Markdown(description)
|
172 |
+
|
173 |
+
with gr.Row():
|
174 |
+
|
175 |
+
with gr.Group():
|
176 |
+
url = gr.Textbox(label='Enter PDF URL here')
|
177 |
+
gr.Markdown("<center><h4>OR<h4></center>")
|
178 |
+
file = gr.File(label='Upload your PDF/ Research Paper / Book here', file_types=['.pdf'])
|
179 |
+
question = gr.Textbox(label='Enter your question here')
|
180 |
+
btn = gr.Button(value='Submit')
|
181 |
+
btn.style(full_width=True)
|
182 |
+
|
183 |
+
with gr.Group():
|
184 |
+
answer = gr.Textbox(label='The answer to your question is :')
|
185 |
+
|
186 |
+
btn.click(question_answer, inputs=[url, file, question], outputs=[answer])
|
187 |
+
|
188 |
+
demo.launch()
|
189 |
|
190 |
|
191 |
# import streamlit as st
|