Spaces:
Runtime error
Runtime error
File size: 3,037 Bytes
074f838 961a746 074f838 241e0dd ffffc8f f3746a4 241e0dd 3034c72 241e0dd 3034c72 b3f0412 241e0dd 074f838 90bd918 b03c313 074f838 015b642 074f838 72275cb 074f838 ce0b170 961a746 858064d 961a746 074f838 241e0dd 8f73221 241e0dd 0ea76bb 864289d 0ea76bb 074f838 015b642 a886e2b ce0b170 961a746 72ca0f0 961a746 864289d 105f709 074f838 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
import gradio as gr
import functions as functions
# pre-defined questions
questions = [
"What did the study investigate?",
"Can you provide a summary of this paper?",
"what are the methodologies used in this study?",
"what are the data intervals used in this study? Give me the start dates and end dates?",
"what are the main limitations of this study?",
"what are the main shortcomings of this study?",
"what are the main findings of the study?",
"what are the main results of the study?",
"what are the main contributions of this study?",
"what is the conclusion of this paper?",
"what are the input features used in this study?",
"what is the dependent variable in this study?",
]
title = 'PDF GPT Turbo'
description = """ 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."""
with gr.Blocks(css="""#chatbot { font-size: 14px; min-height: 1200; }""") as demo:
gr.Markdown(f'<center><h3>{title}</h3></center>')
gr.Markdown(description)
with gr.Row():
with gr.Group():
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>')
with gr.Accordion("API Key"):
openAI_key = gr.Textbox(label='Enter your OpenAI API key here', password=True)
url = gr.Textbox(label='Enter PDF URL here (Example: https://arxiv.org/pdf/1706.03762.pdf )')
gr.Markdown("<center><h4>OR<h4></center>")
files = gr.File(label='Upload your PDF/ Research Paper / Book here', file_types=['.pdf'], file_count="multiple")
question = gr.Textbox(label='Enter your question here')
gr.Examples(
[[q] for q in questions],
inputs=[question],
label="PRE-DEFINED QUESTIONS: Click on a question to auto-fill the input box, then press Enter!",
)
model = gr.Radio([
'gpt-3.5-turbo',
'gpt-3.5-turbo-16k',
'gpt-3.5-turbo-0613',
'gpt-3.5-turbo-16k-0613',
'text-davinci-003',
'gpt-4',
'gpt-4-32k'
], label='Select Model', default='gpt-3.5-turbo')
btn = gr.Button(value='Submit')
btn.style(full_width=True)
with gr.Group():
chatbot = gr.Chatbot(placeholder="Chat History", label="Chat History", lines=50, elem_id="chatbot")
# Bind the click event of the button to the question_answer function
btn.click(
functions.question_answer,
inputs=[chatbot, url, files, question, openAI_key, model],
outputs=[chatbot],
)
demo.launch()
|