Spaces:
Runtime error
Runtime error
bhaskartripathi
commited on
Commit
•
0ea76bb
1
Parent(s):
41123f1
Update app.py
Browse files
app.py
CHANGED
@@ -236,7 +236,7 @@ recommender = SemanticSearch()
|
|
236 |
title = 'PDF GPT Turbo'
|
237 |
description = """ PDF GPT Turbo allows you to chat with your PDF file using Universal Sentence Encoder and Open AI. It gives hallucination free response than other tools as the embeddings are better than OpenAI. The returned response can even cite the page number in square brackets([]) where the information is located, adding credibility to the responses and helping to locate pertinent information quickly."""
|
238 |
|
239 |
-
with gr.Blocks(css="""#chatbot { font-size: 14px; min-height:
|
240 |
|
241 |
gr.Markdown(f'<center><h1>{title}</h1></center>')
|
242 |
gr.Markdown(description)
|
@@ -246,7 +246,7 @@ with gr.Blocks(css="""#chatbot { font-size: 14px; min-height: 800px; }""") as de
|
|
246 |
with gr.Group():
|
247 |
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>')
|
248 |
openAI_key = gr.Textbox(label='Enter your OpenAI API key here', password=True)
|
249 |
-
url = gr.Textbox(label='Enter PDF URL here (Example: https://arxiv.org/pdf/1706.
|
250 |
gr.Markdown("<center><h4>OR<h4></center>")
|
251 |
file = gr.File(label='Upload your PDF/ Research Paper / Book here', file_types=['.pdf'])
|
252 |
question = gr.Textbox(label='Enter your question here')
|
@@ -255,16 +255,33 @@ with gr.Blocks(css="""#chatbot { font-size: 14px; min-height: 800px; }""") as de
|
|
255 |
inputs=[question],
|
256 |
label="PRE-DEFINED QUESTIONS: Click on a question to auto-fill the input box, then press Enter!",
|
257 |
)
|
258 |
-
model = gr.Radio([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
btn = gr.Button(value='Submit')
|
260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
|
262 |
btn.style(full_width=True)
|
263 |
|
264 |
with gr.Group():
|
265 |
-
#chatbot = gr.Chatbot(placeholder="Chat History", label="Chat History", lines=20)
|
266 |
chatbot = gr.Chatbot(placeholder="Chat History", label="Chat History", lines=20, elem_id="chatbot")
|
267 |
-
|
268 |
|
269 |
# Bind the click event of the button to the question_answer function
|
270 |
btn.click(
|
@@ -273,5 +290,5 @@ with gr.Blocks(css="""#chatbot { font-size: 14px; min-height: 800px; }""") as de
|
|
273 |
outputs=[chatbot],
|
274 |
)
|
275 |
|
276 |
-
#openai.api_key = os.getenv('Your_Key_Here')
|
277 |
demo.launch()
|
|
|
|
236 |
title = 'PDF GPT Turbo'
|
237 |
description = """ PDF GPT Turbo allows you to chat with your PDF file using Universal Sentence Encoder and Open AI. It gives hallucination free response than other tools as the embeddings are better than OpenAI. The returned response can even cite the page number in square brackets([]) where the information is located, adding credibility to the responses and helping to locate pertinent information quickly."""
|
238 |
|
239 |
+
with gr.Blocks(css="""#chatbot { font-size: 14px; min-height: 600; }""") as demo:
|
240 |
|
241 |
gr.Markdown(f'<center><h1>{title}</h1></center>')
|
242 |
gr.Markdown(description)
|
|
|
246 |
with gr.Group():
|
247 |
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>')
|
248 |
openAI_key = gr.Textbox(label='Enter your OpenAI API key here', password=True)
|
249 |
+
url = gr.Textbox(label='Enter PDF URL here (Example: https://arxiv.org/pdf/1706.06722.pdf )')
|
250 |
gr.Markdown("<center><h4>OR<h4></center>")
|
251 |
file = gr.File(label='Upload your PDF/ Research Paper / Book here', file_types=['.pdf'])
|
252 |
question = gr.Textbox(label='Enter your question here')
|
|
|
255 |
inputs=[question],
|
256 |
label="PRE-DEFINED QUESTIONS: Click on a question to auto-fill the input box, then press Enter!",
|
257 |
)
|
258 |
+
model = gr.Radio([
|
259 |
+
'gpt-3.5-turbo',
|
260 |
+
'gpt-3.5-turbo-16k',
|
261 |
+
'gpt-3.5-turbo-0613',
|
262 |
+
'gpt-3.5-turbo-16k-0613',
|
263 |
+
'text-davinci-003',
|
264 |
+
'gpt-4',
|
265 |
+
'gpt-4-32k'
|
266 |
+
], label='Select Model', default='gpt-3.5-turbo')
|
267 |
btn = gr.Button(value='Submit')
|
268 |
+
|
269 |
+
model_cost = gr.Markdown("""
|
270 |
+
**Model Cost**:
|
271 |
+
- gpt-3.5-turbo: Pricing not available
|
272 |
+
- gpt-3.5-turbo-16k: Pricing not available
|
273 |
+
- gpt-3.5-turbo-0613: $0.0015 per 1,000 input tokens + $0.0020 per 1,000 output tokens
|
274 |
+
- gpt-3.5-turbo-16k-0613: Pricing not available
|
275 |
+
- text-davinci-003: $0.02 per 1,000 tokens
|
276 |
+
- gpt-4: $0.03 per 1,000 input tokens + $0.06 per 1,000 output tokens
|
277 |
+
- gpt-4-32k: $0.06 per 1,000 input tokens + $0.12 per 1,000 output tokens
|
278 |
+
""")
|
279 |
|
280 |
btn.style(full_width=True)
|
281 |
|
282 |
with gr.Group():
|
283 |
+
#chatbot = gr.Chatbot(placeholder="Chat History", label="Chat History", lines=20, elem_id="chatbot")
|
284 |
chatbot = gr.Chatbot(placeholder="Chat History", label="Chat History", lines=20, elem_id="chatbot")
|
|
|
285 |
|
286 |
# Bind the click event of the button to the question_answer function
|
287 |
btn.click(
|
|
|
290 |
outputs=[chatbot],
|
291 |
)
|
292 |
|
|
|
293 |
demo.launch()
|
294 |
+
|