Kedreamix commited on
Commit
2c90f5f
1 Parent(s): 01b0fc8
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +31 -27
  3. requirements.txt +1 -2
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🚀
4
  colorFrom: pink
5
  colorTo: purple
6
  sdk: gradio
7
- sdk_version: 3.20.1
8
  app_file: app.py
9
  pinned: false
10
  license: gpl-3.0
 
4
  colorFrom: pink
5
  colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 3.50.2
8
  app_file: app.py
9
  pinned: false
10
  license: gpl-3.0
app.py CHANGED
@@ -9,7 +9,7 @@ import argparse
9
  import configparser
10
  import fitz, io, os
11
  from PIL import Image
12
- import gradio
13
  import markdown
14
  import mistune
15
  import json
@@ -551,7 +551,6 @@ class Reader:
551
  ) or 'approach' in parse_key.lower():
552
  method_key = parse_key
553
  break
554
- # 找不到method的部分
555
  if method_key != '':
556
  text = ''
557
  method_text = ''
@@ -563,8 +562,8 @@ class Reader:
563
  chat_method_text, utoken2, ctoken2, ttoken2 = self.chat_method(
564
  text=text)
565
  else:
 
566
  utoken2, ctoken2, ttoken2 = 0, 0, 0
567
- chat_method_text = ''
568
  htmls.append(chat_method_text)
569
  htmls.append("\n")
570
 
@@ -585,8 +584,13 @@ class Reader:
585
  text = summary_text + "\n <Conclusion>:\n" + conclusion_text
586
  else:
587
  text = summary_text
588
- chat_conclusion_text, utoken3, ctoken3, ttoken3 = self.chat_conclusion(
589
- text=text)
 
 
 
 
 
590
  htmls.append(chat_conclusion_text)
591
  htmls.append("\n")
592
  # token统计
@@ -791,7 +795,7 @@ def upload_pdf(api_keys, text, model_name, p, temperature, file):
791
  temperature=temperature)
792
  sum_info, cost = reader.summary_with_chat(
793
  paper_list=paper_list) # type: ignore
794
- return cost, sum_info
795
 
796
 
797
  api_title = "api-key可用验证(ChatPaperFree Gemini Pro)"
@@ -818,18 +822,18 @@ Use Gemini Pro to summary the papers.Star our Github [🌟ChatPaperFree](https:/
818
  '''
819
 
820
  api_input = [
821
- gradio.inputs.Textbox(label="请输入你的API-key(必填, 多个API-key请用英文逗号隔开)",
822
- default="",
823
  type='password')
824
  ]
825
- api_gui = gradio.Interface(fn=valid_apikey,
826
  inputs=api_input,
827
  outputs="text",
828
  title=api_title,
829
  description=api_description)
830
 
831
  # 标题
832
- title = "ChatPaperFree (Gemini Pro)"
833
  # 描述
834
  description = api_description = '''<div align='left'>
835
 
@@ -852,39 +856,39 @@ Use Gemini Pro to summary the papers.Star our Github [🌟ChatPaperFree](https:/
852
 
853
  </div>
854
  '''
855
- # 创建Gradio界面
856
  ip = [
857
- gradio.inputs.Textbox(label="请输入你的API-key(必填, 多个API-key请用英文逗号隔开),不需要空格",
858
- default="",
859
  type='password'),
860
- gradio.inputs.Textbox(
861
  label="请输入论文大标题索引(用英文逗号隔开,必填)",
862
- default=
863
  "'Abstract,Introduction,Related Work,Background,Preliminary,Problem Formulation,Methods,Methodology,Method,Approach,Approaches,Materials and Methods,Experiment Settings,Experiment,Experimental Results,Evaluation,Experiments,Results,Findings,Data Analysis,Discussion,Results and Discussion,Conclusion,References'"
864
  ),
865
- gradio.inputs.Radio(choices=["gemini-Pro", "gemini-Pro-vision(comming Soon)"],
866
- default="gemini-Pro",
867
  label="Select model"),
868
- gradio.inputs.Slider(minimum=-0,
869
  maximum=1.0,
870
- default=1.0,
871
  step=0.05,
872
  label="Top-p (nucleus sampling)"),
873
- gradio.inputs.Slider(minimum=-0,
874
  maximum=5.0,
875
- default=0.5,
876
  step=0.5,
877
  label="Temperature"),
878
- gradio.inputs.File(label="请上传论文PDF(必填)")
879
  ]
880
 
881
- chatpaper_gui = gradio.Interface(fn=upload_pdf,
882
  inputs=ip,
883
- outputs=["json", "html"],
884
  title=title,
885
  description=description)
886
 
887
  # Start server
888
- gui = gradio.TabbedInterface(interface_list=[api_gui, chatpaper_gui],
889
- tab_names=["API-key", "ChatPaper"])
890
- gui.launch(quiet=True, show_api=False)
 
9
  import configparser
10
  import fitz, io, os
11
  from PIL import Image
12
+ import gradio as gr
13
  import markdown
14
  import mistune
15
  import json
 
551
  ) or 'approach' in parse_key.lower():
552
  method_key = parse_key
553
  break
 
554
  if method_key != '':
555
  text = ''
556
  method_text = ''
 
562
  chat_method_text, utoken2, ctoken2, ttoken2 = self.chat_method(
563
  text=text)
564
  else:
565
+ chat_method_text = 'Some Error for method (比如是不是没有Methods这个部分)'
566
  utoken2, ctoken2, ttoken2 = 0, 0, 0
 
567
  htmls.append(chat_method_text)
568
  htmls.append("\n")
569
 
 
584
  text = summary_text + "\n <Conclusion>:\n" + conclusion_text
585
  else:
586
  text = summary_text
587
+ try:
588
+ chat_conclusion_text, utoken3, ctoken3, ttoken3 = self.chat_conclusion(
589
+ text=text)
590
+ except Exception:
591
+ utoken3, ctoken3, ttoken3 = 0, 0, 0
592
+ print(Exception)
593
+ chat_conclusion_text = 'Some Error for conclusion (比如是不是没有Conclusion这个部分)'
594
  htmls.append(chat_conclusion_text)
595
  htmls.append("\n")
596
  # token统计
 
795
  temperature=temperature)
796
  sum_info, cost = reader.summary_with_chat(
797
  paper_list=paper_list) # type: ignore
798
+ return cost, sum_info, "output.md"
799
 
800
 
801
  api_title = "api-key可用验证(ChatPaperFree Gemini Pro)"
 
822
  '''
823
 
824
  api_input = [
825
+ gr.Textbox(label="请输入你的API-key(必填, 多个API-key请用英文逗号隔开)",
826
+ value="",
827
  type='password')
828
  ]
829
+ api_gui = gr.Interface(fn=valid_apikey,
830
  inputs=api_input,
831
  outputs="text",
832
  title=api_title,
833
  description=api_description)
834
 
835
  # 标题
836
+ title = "ChatPaper(Gemini Pro)"
837
  # 描述
838
  description = api_description = '''<div align='left'>
839
 
 
856
 
857
  </div>
858
  '''
859
+ # 创建gr界面
860
  ip = [
861
+ gr.Textbox(label="请输入你的API-key(必填, 多个API-key请用英文逗号隔开),不需要空格",
862
+ value="",
863
  type='password'),
864
+ gr.Textbox(
865
  label="请输入论文大标题索引(用英文逗号隔开,必填)",
866
+ value=
867
  "'Abstract,Introduction,Related Work,Background,Preliminary,Problem Formulation,Methods,Methodology,Method,Approach,Approaches,Materials and Methods,Experiment Settings,Experiment,Experimental Results,Evaluation,Experiments,Results,Findings,Data Analysis,Discussion,Results and Discussion,Conclusion,References'"
868
  ),
869
+ gr.Radio(choices=["gemini-Pro", "gemini-Pro-vision(comming Soon)"],
870
+ value="gemini-Pro",
871
  label="Select model"),
872
+ gr.Slider(minimum=-0,
873
  maximum=1.0,
874
+ value=1.0,
875
  step=0.05,
876
  label="Top-p (nucleus sampling)"),
877
+ gr.Slider(minimum=-0,
878
  maximum=5.0,
879
+ value=0.5,
880
  step=0.5,
881
  label="Temperature"),
882
+ gr.File(label="请上传论文PDF(必填)", file_types = ['.pdf']),
883
  ]
884
 
885
+ chatpaper_gui = gr.Interface(fn=upload_pdf,
886
  inputs=ip,
887
+ outputs=[gr.Json(label = 'ChatPaperFree Tokens'), gr.Markdown(label = "ChatPaperFree 结果"), gr.File(label = "下载文章")],
888
  title=title,
889
  description=description)
890
 
891
  # Start server
892
+ gui = gr.TabbedInterface(interface_list=[api_gui, chatpaper_gui],
893
+ tab_names=["API-key", "ChatPaperFree"])
894
+ gui.launch(quiet=True, show_api=False, debug=True)
requirements.txt CHANGED
@@ -5,10 +5,9 @@ tiktoken==0.2.0
5
  tenacity==8.2.2
6
  pybase64==1.2.3
7
  Pillow==9.4.0
8
- openai==0.27.0
9
  markdown
10
  mistune
11
- gradio==3.20.1
12
  google-generativeai==0.3.1
13
  pydantic==1.10.7
14
  #tiktoken
 
5
  tenacity==8.2.2
6
  pybase64==1.2.3
7
  Pillow==9.4.0
 
8
  markdown
9
  mistune
10
+ gradio==3.50.2
11
  google-generativeai==0.3.1
12
  pydantic==1.10.7
13
  #tiktoken