Kexin2000 commited on
Commit
db8546e
1 Parent(s): 30367d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -77
app.py CHANGED
@@ -216,20 +216,20 @@ def generate_answer_text_davinci_003(question, openAI_key):
216
 
217
 
218
  # pre-defined questions
219
- questions = [
220
- "What did the study investigate?",
221
- "Can you provide a summary of this paper?",
222
- "what are the methodologies used in this study?",
223
- "what are the data intervals used in this study? Give me the start dates and end dates?",
224
- "what are the main limitations of this study?",
225
- "what are the main shortcomings of this study?",
226
- "what are the main findings of the study?",
227
- "what are the main results of the study?",
228
- "what are the main contributions of this study?",
229
- "what is the conclusion of this paper?",
230
- "what are the input features used in this study?",
231
- "what is the dependent variable in this study?",
232
- ]
233
 
234
  # =============================================================================
235
  CACHE_TIME = 60 * 60 * 6 # 6 hours
@@ -300,60 +300,12 @@ def return_recommendations(url):
300
 
301
  recommender = SemanticSearch()
302
 
303
- # title = 'PDF GPT Turbo'
304
- # 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."""
305
- #
306
- # with gr.Blocks(css="""#chatbot { font-size: 14px; min-height: 1200; }""") as demo:
307
- # gr.Markdown(f'<center><h3>{title}</h3></center>')
308
- # gr.Markdown(description)
309
- #
310
- # with gr.Row():
311
- # with gr.Group():
312
- # gr.Markdown(
313
- # f'<p style="text-align:center">Get your Open AI API key <a href="https://platform.openai.com/account/api-keys">here</a></p>')
314
- # with gr.Accordion("API Key"):
315
- # openAI_key = gr.Textbox(label='Enter your OpenAI API key here', password=True)
316
- # url = gr.Textbox(label='Enter PDF URL here (Example: https://arxiv.org/pdf/1706.03762.pdf )')
317
- # gr.Markdown("<center><h4>OR<h4></center>")
318
- # file = gr.File(label='Upload your PDF/ Research Paper / Book here', file_types=['.pdf'])
319
- # question = gr.Textbox(label='Enter your question here')
320
- # gr.Examples(
321
- # [[q] for q in questions],
322
- # inputs=[question],
323
- # label="PRE-DEFINED QUESTIONS: Click on a question to auto-fill the input box, then press Enter!",
324
- # )
325
- # model = gr.Radio([
326
- # 'gpt-3.5-turbo',
327
- # 'gpt-3.5-turbo-16k',
328
- # 'gpt-3.5-turbo-0613',
329
- # 'gpt-3.5-turbo-16k-0613',
330
- # 'text-davinci-003',
331
- # 'gpt-4',
332
- # 'gpt-4-32k'
333
- # ], label='Select Model', default='gpt-3.5-turbo')
334
- # btn = gr.Button(value='Submit')
335
- #
336
- # btn.style(full_width=True)
337
- #
338
- # with gr.Group():
339
- # chatbot = gr.Chatbot(placeholder="Chat History", label="Chat History", lines=50, elem_id="chatbot")
340
- #
341
- # #
342
- # # Bind the click event of the button to the question_answer function
343
- # btn.click(
344
- # question_answer,
345
- # inputs=[chatbot, url, file, question, openAI_key, model],
346
- # outputs=[chatbot],
347
- # )
348
- #
349
- # demo.launch()
350
 
351
  # 第一个文件的内容
352
- title_1 = "Semantic Scholar Paper Recommender"
353
  description_1 = (
354
- "Paste a link to a paper on Hugging Face Papers and get recommendations for similar"
355
- " papers from Semantic Scholar. **Note**: Some papers may not have recommendations"
356
- " yet if they are new or have not been indexed by Semantic Scholar."
357
  )
358
  examples_1 = [
359
  "https://huggingface.co/papers/2309.12307",
@@ -361,14 +313,13 @@ examples_1 = [
361
  ]
362
 
363
  # 第二个文件的内容
364
- title_2 = "PDF GPT Turbo"
365
  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
  with gr.Blocks() as tab1:
370
- gr.Markdown(f'<center><h3>{title_1}</h3></center>')
371
- gr.Markdown(description_1)
372
  interface = gr.Interface(
373
  return_recommendations,
374
  gr.Textbox(lines=1),
@@ -383,17 +334,17 @@ with gr.Blocks() as tab2:
383
  gr.Markdown(description_2)
384
  with gr.Row():
385
  with gr.Group():
386
- 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>')
387
  with gr.Accordion("API Key"):
388
- openAI_key = gr.Textbox(label='Enter your OpenAI API key here')
389
- url = gr.Textbox(label='Enter PDF URL here (Example: https://arxiv.org/pdf/1706.03762.pdf )')
390
  gr.Markdown("<center><h4>OR<h4></center>")
391
- file = gr.File(label='Upload your PDF/ Research Paper / Book here', file_types=['.pdf'])
392
- question = gr.Textbox(label='Enter your question here')
393
  gr.Examples(
394
  [[q] for q in questions],
395
  inputs=[question],
396
- label="PRE-DEFINED QUESTIONS: Click on a question to auto-fill the input box, then press Enter!",
397
  )
398
  model = gr.Radio([
399
  'gpt-3.5-turbo',
@@ -404,7 +355,7 @@ with gr.Blocks() as tab2:
404
  'gpt-4',
405
  'gpt-4-32k'
406
  ], label='Select Model')
407
- btn = gr.Button(value='Submit')
408
 
409
 
410
  with gr.Group():
@@ -419,5 +370,5 @@ with gr.Blocks() as tab2:
419
  )
420
 
421
  # 将两个界面放入一个 Tab 应用中
422
- demo = gr.TabbedInterface([tab1, tab2], ["Tab 1", "Tab 2"])
423
  demo.launch()
 
216
 
217
 
218
  # pre-defined questions
219
+ questions = ["这项研究调查了什么?",
220
+ "你能提供这篇论文的摘要吗?",
221
+ "这项研究使用了哪些方法论?",
222
+ "这项研究使用了哪些数据间隔?请告诉我开始日期和结束日期?",
223
+ "这项研究的主要局限性是什么?",
224
+ "这项研究的主要缺点是什么?",
225
+ "这项研究的主要发现是什么?",
226
+ "这项研究的主要结果是什么?",
227
+ "这项研究的主要贡献是什么?",
228
+ "这篇论文的结论是什么?",
229
+ "这项研究中使用了哪些输入特征?",
230
+ "这项研究中的因变量是什么?",
231
+ ]
232
+
233
 
234
  # =============================================================================
235
  CACHE_TIME = 60 * 60 * 6 # 6 hours
 
300
 
301
  recommender = SemanticSearch()
302
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
 
304
  # 第一个文件的内容
305
+ title_1 = "相关文献导航系统"
306
  description_1 = (
307
+ "将一篇论文的链接粘贴到下方方框处,然后从文献导航系统获取类似论文的推荐。"
308
+ "注意:如果论文是新的或尚未被文献导航系统索引,可能无法推荐。"
 
309
  )
310
  examples_1 = [
311
  "https://huggingface.co/papers/2309.12307",
 
313
  ]
314
 
315
  # 第二个文件的内容
316
+ title_2 = "论文解读系统"
317
  description_2 = (
318
+ "论文解读系统允许你与你的 PDF 文件进行对话。它使用谷歌的通用句子编码器和深度平均网络(DAN)来提供无幻觉的响应,通过提高 OpenAI 的嵌入质量。"
319
+ "它在方括号中注明页码([页码]),并显示信息的位置,增加了回应的可信度。"
320
  )
321
 
322
  with gr.Blocks() as tab1:
 
 
323
  interface = gr.Interface(
324
  return_recommendations,
325
  gr.Textbox(lines=1),
 
334
  gr.Markdown(description_2)
335
  with gr.Row():
336
  with gr.Group():
337
+ gr.Markdown(f'<p style="text-align:center">获取你的Open AI API key <a href="https://platform.openai.com/account/api-keys">here</a></p>')
338
  with gr.Accordion("API Key"):
339
+ openAI_key = gr.Textbox(label='在这里输入您的API key(老师如果需要测试,可以先用我的key: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)')
340
+ url = gr.Textbox(label='输入pdf链接 (Example: https://arxiv.org/pdf/1706.03762.pdf )')
341
  gr.Markdown("<center><h4>OR<h4></center>")
342
+ file = gr.File(label='在这里上传您的文件', file_types=['.pdf'])
343
+ question = gr.Textbox(label='输入您的问题')
344
  gr.Examples(
345
  [[q] for q in questions],
346
  inputs=[question],
347
+ label="您可能想问?",
348
  )
349
  model = gr.Radio([
350
  'gpt-3.5-turbo',
 
355
  'gpt-4',
356
  'gpt-4-32k'
357
  ], label='Select Model')
358
+ btn = gr.Button(value='提交')
359
 
360
 
361
  with gr.Group():
 
370
  )
371
 
372
  # 将两个界面放入一个 Tab 应用中
373
+ demo = gr.TabbedInterface([tab1, tab2], ["相关文献导航系统", "论文解读系统"])
374
  demo.launch()