Spaces:
Runtime error
Runtime error
sc_ma
commited on
Commit
·
05783f8
1
Parent(s):
5c03695
bug fix. catch Timeout error.
Browse files- auto_backgrounds.py +10 -8
- section_generator.py +1 -1
auto_backgrounds.py
CHANGED
@@ -28,6 +28,9 @@ def log_usage(usage, generating_target, print_out=True):
|
|
28 |
logging.info(message)
|
29 |
|
30 |
def _generation_setup(title, description="", template="ICLR2022", model="gpt-4"):
|
|
|
|
|
|
|
31 |
paper = {}
|
32 |
paper_body = {}
|
33 |
|
@@ -65,8 +68,10 @@ def generate_backgrounds(title, description="", template="ICLR2022", model="gpt-
|
|
65 |
usage = section_generation_bg(paper, section, destination_folder, model=model)
|
66 |
log_usage(usage, section)
|
67 |
except Exception as e:
|
68 |
-
|
69 |
-
|
|
|
|
|
70 |
|
71 |
input_dict = {"title": title, "description": description, "generator": "generate_backgrounds"}
|
72 |
filename = hash_name(input_dict) + ".zip"
|
@@ -87,12 +92,7 @@ def generate_draft(title, description="", template="ICLR2022", model="gpt-4"):
|
|
87 |
|
88 |
print("Generating figures ...")
|
89 |
usage = figures_generation(paper, destination_folder, model="gpt-3.5-turbo")
|
90 |
-
# todo: use `figures_generation` function to complete remainings
|
91 |
-
# prompts = generate_experiments_prompts(paper)
|
92 |
-
# gpt_response, usage = get_responses(prompts, model)
|
93 |
-
# list_of_methods = list(extract_json(gpt_response))
|
94 |
log_usage(usage, "figures")
|
95 |
-
# generate_random_figures(list_of_methods, save_to_path + "comparison.png")
|
96 |
|
97 |
# for section in ["introduction", "related works", "backgrounds", "methodology", "experiments", "conclusion", "abstract"]:
|
98 |
for section in ["introduction", "related works", "backgrounds", "experiments", "conclusion", "abstract"]:
|
@@ -100,7 +100,9 @@ def generate_draft(title, description="", template="ICLR2022", model="gpt-4"):
|
|
100 |
usage = section_generation(paper, section, destination_folder, model=model)
|
101 |
log_usage(usage, section)
|
102 |
except Exception as e:
|
103 |
-
|
|
|
|
|
104 |
|
105 |
input_dict = {"title": title, "description": description, "generator": "generate_draft"}
|
106 |
filename = hash_name(input_dict) + ".zip"
|
|
|
28 |
logging.info(message)
|
29 |
|
30 |
def _generation_setup(title, description="", template="ICLR2022", model="gpt-4"):
|
31 |
+
'''
|
32 |
+
todo: use `model` to control which model to use; may use another method to generate keywords or collect references
|
33 |
+
'''
|
34 |
paper = {}
|
35 |
paper_body = {}
|
36 |
|
|
|
68 |
usage = section_generation_bg(paper, section, destination_folder, model=model)
|
69 |
log_usage(usage, section)
|
70 |
except Exception as e:
|
71 |
+
message = f"Failed to generate {section}. {type(e).__name__} was raised: {e}"
|
72 |
+
print(message)
|
73 |
+
logging.info(message)
|
74 |
+
print(f"The paper '{title}' has been generated. Saved to {destination_folder}.")
|
75 |
|
76 |
input_dict = {"title": title, "description": description, "generator": "generate_backgrounds"}
|
77 |
filename = hash_name(input_dict) + ".zip"
|
|
|
92 |
|
93 |
print("Generating figures ...")
|
94 |
usage = figures_generation(paper, destination_folder, model="gpt-3.5-turbo")
|
|
|
|
|
|
|
|
|
95 |
log_usage(usage, "figures")
|
|
|
96 |
|
97 |
# for section in ["introduction", "related works", "backgrounds", "methodology", "experiments", "conclusion", "abstract"]:
|
98 |
for section in ["introduction", "related works", "backgrounds", "experiments", "conclusion", "abstract"]:
|
|
|
100 |
usage = section_generation(paper, section, destination_folder, model=model)
|
101 |
log_usage(usage, section)
|
102 |
except Exception as e:
|
103 |
+
message = f"Failed to generate {section}. {type(e).__name__} was raised: {e}"
|
104 |
+
print(message)
|
105 |
+
logging.info(message)
|
106 |
|
107 |
input_dict = {"title": title, "description": description, "generator": "generate_draft"}
|
108 |
filename = hash_name(input_dict) + ".zip"
|
section_generator.py
CHANGED
@@ -72,7 +72,7 @@ def section_generation(paper, section, save_to_path, model):
|
|
72 |
f.write(f"\section{{{section.upper()}}}\n")
|
73 |
with open(tex_file, "a") as f:
|
74 |
f.write(output)
|
75 |
-
|
76 |
print(f"{section} has been generated. Saved to {tex_file}.")
|
77 |
return usage
|
78 |
|
|
|
72 |
f.write(f"\section{{{section.upper()}}}\n")
|
73 |
with open(tex_file, "a") as f:
|
74 |
f.write(output)
|
75 |
+
time.sleep(5)
|
76 |
print(f"{section} has been generated. Saved to {tex_file}.")
|
77 |
return usage
|
78 |
|