sc_ma commited on
Commit
2c0ffed
1 Parent(s): 4a233ea

Retry 2 additional times to avoid random time out error.

Browse files
Files changed (2) hide show
  1. app.py +2 -2
  2. auto_backgrounds.py +14 -0
app.py CHANGED
@@ -8,10 +8,10 @@ from utils.file_operations import hash_name
8
  # 2. update QQ group and Organization cards
9
  # 4. add auto_polishing function
10
  # 5. Use some simple method for simple tasks (including: writing abstract, conclusion, generate keywords, generate figures...)
11
- # 5.1 Use GPT 3.5 for abstract, conclusion, ...
12
  # 5.2 Use local LLM to generate keywords, figures, ...
13
  # 5.3 Use embedding to find most related papers (find a paper dataset)
14
- # 5.4 Use Segmantic Scholar API instead of Arxiv API.
15
  # 6. get logs when the procedure is not completed.
16
 
17
  openai_key = os.getenv("OPENAI_API_KEY")
 
8
  # 2. update QQ group and Organization cards
9
  # 4. add auto_polishing function
10
  # 5. Use some simple method for simple tasks (including: writing abstract, conclusion, generate keywords, generate figures...)
11
+ # 5.1 Use GPT 3.5 for abstract, conclusion, ... (or may not)
12
  # 5.2 Use local LLM to generate keywords, figures, ...
13
  # 5.3 Use embedding to find most related papers (find a paper dataset)
14
+ # 5.4 Use Semantic Scholar API instead of Arxiv API.
15
  # 6. get logs when the procedure is not completed.
16
 
17
  openai_key = os.getenv("OPENAI_API_KEY")
auto_backgrounds.py CHANGED
@@ -2,6 +2,7 @@ from utils.references import References
2
  from utils.file_operations import hash_name, make_archive, copy_templates
3
  from section_generator import section_generation_bg, keywords_generation, figures_generation, section_generation
4
  import logging
 
5
 
6
  TOTAL_TOKENS = 0
7
  TOTAL_PROMPTS_TOKENS = 0
@@ -104,6 +105,19 @@ def generate_draft(title, description="", template="ICLR2022", model="gpt-4"):
104
  message = f"Failed to generate {section}. {type(e).__name__} was raised: {e}"
105
  print(message)
106
  logging.info(message)
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
  input_dict = {"title": title, "description": description, "generator": "generate_draft"}
109
  filename = hash_name(input_dict) + ".zip"
 
2
  from utils.file_operations import hash_name, make_archive, copy_templates
3
  from section_generator import section_generation_bg, keywords_generation, figures_generation, section_generation
4
  import logging
5
+ import time
6
 
7
  TOTAL_TOKENS = 0
8
  TOTAL_PROMPTS_TOKENS = 0
 
105
  message = f"Failed to generate {section}. {type(e).__name__} was raised: {e}"
106
  print(message)
107
  logging.info(message)
108
+ max_attempts = 2
109
+ # re-try `max_attempts` time
110
+ for i in range(max_attempts):
111
+ time.sleep(20)
112
+ try:
113
+ usage = section_generation(paper, section, destination_folder, model=model)
114
+ log_usage(usage, section)
115
+ e = None
116
+ except Exception as e:
117
+ pass
118
+ if e is None:
119
+ break
120
+
121
 
122
  input_dict = {"title": title, "description": description, "generator": "generate_draft"}
123
  filename = hash_name(input_dict) + ".zip"