Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -366,34 +366,58 @@ description_2 = (
|
|
366 |
"PDF GPT Turbo allows you to chat with your PDF files. It uses Google's Universal Sentence Encoder with Deep averaging network (DAN) to give hallucination free response by improving the embedding quality of OpenAI. It cites the page number in square brackets([Page No.]) and shows where the information is located, adding credibility to the responses."
|
367 |
)
|
368 |
|
369 |
-
|
370 |
-
|
|
|
371 |
return_recommendations,
|
372 |
gr.Textbox(lines=1),
|
373 |
gr.Markdown(),
|
374 |
examples=examples_1,
|
375 |
-
title=
|
376 |
-
description=
|
377 |
)
|
378 |
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
gr.
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
|
398 |
-
#
|
399 |
-
|
|
|
|
366 |
"PDF GPT Turbo allows you to chat with your PDF files. It uses Google's Universal Sentence Encoder with Deep averaging network (DAN) to give hallucination free response by improving the embedding quality of OpenAI. It cites the page number in square brackets([Page No.]) and shows where the information is located, adding credibility to the responses."
|
367 |
)
|
368 |
|
369 |
+
with gr.Tab(title=title_1) as tab1:
|
370 |
+
gr.Markdown(description_1)
|
371 |
+
interface = gr.Interface(
|
372 |
return_recommendations,
|
373 |
gr.Textbox(lines=1),
|
374 |
gr.Markdown(),
|
375 |
examples=examples_1,
|
376 |
+
title=title,
|
377 |
+
description=description,
|
378 |
)
|
379 |
|
380 |
+
with gr.Tab(title=title2) as tab2:
|
381 |
+
gr.Markdown(f'<center><h3>{title_2}</h3></center>')
|
382 |
+
gr.Markdown(description_2)
|
383 |
+
with gr.Row():
|
384 |
+
with gr.Group():
|
385 |
+
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>')
|
386 |
+
with gr.Accordion("API Key"):
|
387 |
+
openAI_key = gr.Textbox(label='Enter your OpenAI API key here', password=True)
|
388 |
+
url = gr.Textbox(label='Enter PDF URL here (Example: https://arxiv.org/pdf/1706.03762.pdf )')
|
389 |
+
gr.Markdown("<center><h4>OR<h4></center>")
|
390 |
+
file = gr.File(label='Upload your PDF/ Research Paper / Book here', file_types=['.pdf'])
|
391 |
+
question = gr.Textbox(label='Enter your question here')
|
392 |
+
gr.Examples(
|
393 |
+
[[q] for q in questions],
|
394 |
+
inputs=[question],
|
395 |
+
label="PRE-DEFINED QUESTIONS: Click on a question to auto-fill the input box, then press Enter!",
|
396 |
+
)
|
397 |
+
model = gr.Radio([
|
398 |
+
'gpt-3.5-turbo',
|
399 |
+
'gpt-3.5-turbo-16k',
|
400 |
+
'gpt-3.5-turbo-0613',
|
401 |
+
'gpt-3.5-turbo-16k-0613',
|
402 |
+
'text-davinci-003',
|
403 |
+
'gpt-4',
|
404 |
+
'gpt-4-32k'
|
405 |
+
], label='Select Model', default='gpt-3.5-turbo')
|
406 |
+
btn = gr.Button(value='Submit')
|
407 |
+
|
408 |
+
btn.style(full_width=True)
|
409 |
+
|
410 |
+
with gr.Group():
|
411 |
+
chatbot = gr.Chatbot(placeholder="Chat History", label="Chat History", lines=50, elem_id="chatbot")
|
412 |
+
|
413 |
+
|
414 |
+
# Bind the click event of the button to the question_answer function
|
415 |
+
btn.click(
|
416 |
+
question_answer,
|
417 |
+
inputs=[chatbot, url, file, question, openAI_key, model],
|
418 |
+
outputs=[chatbot],
|
419 |
+
)
|
420 |
|
421 |
+
# 将两个界面放入一个 Tab 应用中
|
422 |
+
demo = gr.TabbedInterface([tab1, tab2], ["Tab 1", "Tab 2"])
|
423 |
+
demo.launch()
|