bhaskartripathi commited on
Commit
7f71192
·
1 Parent(s): 3501948

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -16
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 a 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
- gradio_interface = gr.Interface(
169
- fn=question_answer,
170
- inputs=[
171
- gr.inputs.Textbox(label="Enter PDF URL here"),
172
- gr.inputs.File(label="Upload your PDF/ Research Paper / Book here", type=".pdf"),
173
- gr.inputs.Textbox(label="Enter your question here")
174
- ],
175
- outputs=gr.outputs.Textbox(label="The answer to your question is:"),
176
- title=title,
177
- description=description,
178
- theme="dark"
179
- )
180
-
181
- gradio_interface.launch()
 
 
 
 
 
 
 
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