sc_ma commited on
Commit
6fe5041
1 Parent(s): a0d1776

add anoncement. remove some comments.

Browse files
Files changed (3) hide show
  1. app.py +17 -12
  2. auto_backgrounds.py +1 -3
  3. utils/storage.py +1 -1
app.py CHANGED
@@ -4,6 +4,12 @@ import openai
4
  from auto_backgrounds import generate_backgrounds, fake_generator
5
  from auto_draft import generate_draft
6
 
 
 
 
 
 
 
7
  openai_key = os.getenv("OPENAI_API_KEY")
8
  access_key_id = os.getenv('AWS_ACCESS_KEY_ID')
9
  secret_access_key = os.getenv('AWS_SECRET_ACCESS_KEY')
@@ -17,7 +23,6 @@ if openai_key is None:
17
  print("OPENAI_API_KEY is not found in environment variables. The output may not be generated.\n")
18
  IS_OPENAI_API_KEY_AVAILABLE = False
19
  else:
20
- # todo: check if this key is available or not
21
  openai.api_key = openai_key
22
  try:
23
  openai.Model.list()
@@ -55,7 +60,7 @@ def wrapped_generator(title, description, openai_key = None,
55
  return file_name
56
  else:
57
  # generate the result.
58
- # output = fake_generate_backgrounds(title, description, openai_key)
59
  output = generate_backgrounds(title, description, template, "gpt-4")
60
  upload_file(file_name)
61
  return output
@@ -66,29 +71,28 @@ def wrapped_generator(title, description, openai_key = None,
66
 
67
 
68
  theme = gr.themes.Monochrome(font=gr.themes.GoogleFont("Questrial")).set(
69
- background_fill_primary='#F6F6F6',
70
- button_primary_background_fill="#281A39",
71
- input_background_fill='#E5E4E2'
72
  )
73
 
74
  with gr.Blocks(theme=theme) as demo:
75
  gr.Markdown('''
76
- # Auto-Draft: 文献整理辅助工具-限量免费使用
77
 
78
  本Demo提供对[Auto-Draft](https://github.com/CCCBora/auto-draft)的auto_backgrounds功能的测试。通过输入一个领域的名称(比如Deep Reinforcement Learning),即可自动对这个领域的相关文献进行归纳总结.
79
 
80
- ***2023-04-30 Update***: 如果有更多想法和建议欢迎加入群里交流, 群号: ***249738228***.
81
-
82
- ***2023-04-26 Update***: 我本月的余额用完了, 感谢乐乐老师帮忙宣传, 也感觉大家的体验和反馈! 我会按照大家的意见对功能进行改进. 下个月会把Space的访问权限限制在Huggingface的Organization里, 欢迎有兴趣的同学通过下面的链接加入! [AUTO-ACADEMIC](https://huggingface.co/organizations/auto-academic/share/HPjgazDSlkwLNCWKiAiZoYtXaJIatkWDYM)
83
 
84
  ## 用法
85
 
86
- 输入一个领域的名称(比如Deep Reinforcement Learning), 点击Submit, 等待大概十分钟, 下载output.zip,在Overleaf上编译浏览.
87
  ''')
88
  with gr.Row():
89
  with gr.Column(scale=2):
90
  key = gr.Textbox(value=openai_key, lines=1, max_lines=1, label="OpenAI Key", visible=not IS_OPENAI_API_KEY_AVAILABLE)
91
- # key = gr.Textbox(value=openai_key, lines=1, max_lines=1, label="OpenAI Key", visible=False)
92
  title = gr.Textbox(value="Deep Reinforcement Learning", lines=1, max_lines=1, label="Title")
93
  description = gr.Textbox(lines=5, label="Description (Optional)")
94
 
@@ -100,7 +104,8 @@ with gr.Blocks(theme=theme) as demo:
100
  availability_mapping = {True: "AVAILABLE", False: "NOT AVAILABLE"}
101
  gr.Markdown(f'''## Huggingface Space Status
102
  当`OpenAI API`显示AVAILABLE的时候这个Space可以直接使用.
103
- 当`OpenAI API`显示NOT AVAILABLE的时候这个Space可以通过在左侧输入OPENAI KEY来使用.
 
104
  `OpenAI API`: <span style="{style_mapping[IS_OPENAI_API_KEY_AVAILABLE]}">{availability_mapping[IS_OPENAI_API_KEY_AVAILABLE]}</span>. `Cache`: <span style="{style_mapping[IS_CACHE_AVAILABLE]}">{availability_mapping[IS_CACHE_AVAILABLE]}</span>.''')
105
  file_output = gr.File(label="Output")
106
 
 
4
  from auto_backgrounds import generate_backgrounds, fake_generator
5
  from auto_draft import generate_draft
6
 
7
+ # todo:
8
+ # 1. update README.md and introduction in app.py
9
+ # 2. update QQ group and Organization cards
10
+ # 3. update autodraft.py to generate a whole paper
11
+ # 4. add auto_polishing function
12
+
13
  openai_key = os.getenv("OPENAI_API_KEY")
14
  access_key_id = os.getenv('AWS_ACCESS_KEY_ID')
15
  secret_access_key = os.getenv('AWS_SECRET_ACCESS_KEY')
 
23
  print("OPENAI_API_KEY is not found in environment variables. The output may not be generated.\n")
24
  IS_OPENAI_API_KEY_AVAILABLE = False
25
  else:
 
26
  openai.api_key = openai_key
27
  try:
28
  openai.Model.list()
 
60
  return file_name
61
  else:
62
  # generate the result.
63
+ # output = fake_generate_backgrounds(title, description, openai_key) # todo: use `generator` to control which function to use.
64
  output = generate_backgrounds(title, description, template, "gpt-4")
65
  upload_file(file_name)
66
  return output
 
71
 
72
 
73
  theme = gr.themes.Monochrome(font=gr.themes.GoogleFont("Questrial")).set(
74
+ background_fill_primary='#E5E4E2',
75
+ background_fill_secondary = '#F6F6F6',
76
+ button_primary_background_fill="#281A39"
77
  )
78
 
79
  with gr.Blocks(theme=theme) as demo:
80
  gr.Markdown('''
81
+ # Auto-Draft: 文献整理辅助工具
82
 
83
  本Demo提供对[Auto-Draft](https://github.com/CCCBora/auto-draft)的auto_backgrounds功能的测试。通过输入一个领域的名称(比如Deep Reinforcement Learning),即可自动对这个领域的相关文献进行归纳总结.
84
 
85
+ ***2023-05-03 Update***: 在这个版本中为大家提供了输入OpenAI API Key的地址, 如果有GPT-4的API KEY的话可以在这里体验!
86
+ 我也会在近期提供一定的免费体验在这个Huggingface Organization里: [AUTO-ACADEMIC](https://huggingface.co/organizations/auto-academic/share/HPjgazDSlkwLNCWKiAiZoYtXaJIatkWDYM).
87
+ 如果有更多想法和建议欢迎加入QQ群里交流, 如果我在Space里更新了Key我会第一时间通知大家. 群号: ***249738228***.
88
 
89
  ## 用法
90
 
91
+ 输入一个领域的名称(比如Deep Reinforcement Learning), 点击Submit, 等待大概十分钟, 下载.zip格式的输出,在Overleaf上编译浏览.
92
  ''')
93
  with gr.Row():
94
  with gr.Column(scale=2):
95
  key = gr.Textbox(value=openai_key, lines=1, max_lines=1, label="OpenAI Key", visible=not IS_OPENAI_API_KEY_AVAILABLE)
 
96
  title = gr.Textbox(value="Deep Reinforcement Learning", lines=1, max_lines=1, label="Title")
97
  description = gr.Textbox(lines=5, label="Description (Optional)")
98
 
 
104
  availability_mapping = {True: "AVAILABLE", False: "NOT AVAILABLE"}
105
  gr.Markdown(f'''## Huggingface Space Status
106
  当`OpenAI API`显示AVAILABLE的时候这个Space可以直接使用.
107
+ 当`OpenAI API`显示NOT AVAILABLE的时候这个Space可以通过在左侧输入OPENAI KEY来使用. 需要有GPT-4的API权限, 不然会报错.
108
+ 当`Cache`显示AVAILABLE的时候, 所有的输入和输出会被备份到我的云储存中. 显示NOT AVAILABLE的时候可以正常使用.
109
  `OpenAI API`: <span style="{style_mapping[IS_OPENAI_API_KEY_AVAILABLE]}">{availability_mapping[IS_OPENAI_API_KEY_AVAILABLE]}</span>. `Cache`: <span style="{style_mapping[IS_CACHE_AVAILABLE]}">{availability_mapping[IS_CACHE_AVAILABLE]}</span>.''')
110
  file_output = gr.File(label="Output")
111
 
auto_backgrounds.py CHANGED
@@ -49,19 +49,17 @@ def generate_backgrounds(title, description="", template="ICLR2022", model="gpt-
49
 
50
  paper["title"] = title
51
  paper["description"] = description
52
- paper["references"] = ref.to_prompts() # to_prompts(top_papers)
53
  paper["body"] = paper_body
54
  paper["bibtex"] = bibtex_path
55
 
56
  for section in ["introduction", "related works", "backgrounds"]:
57
  try:
58
- # usage = pipeline(paper, section, destination_folder, model=model)
59
  usage = section_generation_bg(paper, section, destination_folder, model=model)
60
  log_usage(usage, section)
61
  except Exception as e:
62
  print(f"Failed to generate {section} due to the error: {e}")
63
  print(f"The paper {title} has been generated. Saved to {destination_folder}.")
64
- # shutil.make_archive("output.zip", 'zip', save_to_path)
65
 
66
  input_dict = {"title": title, "description": description, "generator": "generate_backgrounds"}
67
  filename = hash_name(input_dict) + ".zip"
 
49
 
50
  paper["title"] = title
51
  paper["description"] = description
52
+ paper["references"] = ref.to_prompts()
53
  paper["body"] = paper_body
54
  paper["bibtex"] = bibtex_path
55
 
56
  for section in ["introduction", "related works", "backgrounds"]:
57
  try:
 
58
  usage = section_generation_bg(paper, section, destination_folder, model=model)
59
  log_usage(usage, section)
60
  except Exception as e:
61
  print(f"Failed to generate {section} due to the error: {e}")
62
  print(f"The paper {title} has been generated. Saved to {destination_folder}.")
 
63
 
64
  input_dict = {"title": title, "description": description, "generator": "generate_backgrounds"}
65
  filename = hash_name(input_dict) + ".zip"
utils/storage.py CHANGED
@@ -33,7 +33,7 @@ if (access_key_id is not None) and (secret_access_key is not None):
33
  return [obj.key for obj in bucket.objects.all()]
34
 
35
  def download_file(file_name):
36
- ''' Download `file_name` from the bucket. todo:check existence before downloading!
37
  Bucket (str) – The name of the bucket to download from.
38
  Key (str) – The name of the key to download from.
39
  Filename (str) – The path to the file to download to.
 
33
  return [obj.key for obj in bucket.objects.all()]
34
 
35
  def download_file(file_name):
36
+ ''' Download `file_name` from the bucket.
37
  Bucket (str) – The name of the bucket to download from.
38
  Key (str) – The name of the key to download from.
39
  Filename (str) – The path to the file to download to.