Spaces:
Sleeping
Sleeping
File size: 3,087 Bytes
bc9f64b 71b98c7 bc9f64b cb47b69 bc9f64b 2dae07c bc9f64b ea4d797 f82a1c7 57c0c93 bc9f64b 71b98c7 bc9f64b 2c8b880 |
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 70 |
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')
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',
'gpt-4-1106-preview'
], 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(debug=True, show_error=True)
|