Spaces:
Running
Running
update
Browse files
app.py
CHANGED
@@ -83,16 +83,18 @@ def create_pptx(api_key, instruction, model_name="gpt-4o", max_tokens=4096):
|
|
83 |
generated_code = generated_code.replace("generate_image(", f"generate_image({repr(api_key)},")
|
84 |
generated_code = "from SlidesLib import *\n\n" + generated_code
|
85 |
|
86 |
-
|
87 |
-
|
|
|
|
|
88 |
f.write(generated_code)
|
89 |
|
90 |
-
#
|
91 |
result = subprocess.run(
|
92 |
-
["python",
|
93 |
-
capture_output=True,
|
94 |
-
text=True,
|
95 |
-
check=True,
|
96 |
cwd=working_dir
|
97 |
)
|
98 |
print(result.stdout)
|
@@ -121,12 +123,14 @@ content.text = "{instruction}"
|
|
121 |
|
122 |
ppt.save("output.pptx")
|
123 |
"""
|
124 |
-
|
125 |
-
|
|
|
|
|
126 |
f.write(default_code)
|
127 |
|
128 |
subprocess.run(
|
129 |
-
["python",
|
130 |
capture_output=True,
|
131 |
text=True,
|
132 |
check=True,
|
|
|
83 |
generated_code = generated_code.replace("generate_image(", f"generate_image({repr(api_key)},")
|
84 |
generated_code = "from SlidesLib import *\n\n" + generated_code
|
85 |
|
86 |
+
code_filename = "generated_slide_code.py"
|
87 |
+
code_file_path = os.path.join(working_dir, code_filename)
|
88 |
+
|
89 |
+
with open(code_file_path, "w", encoding="utf-8") as f:
|
90 |
f.write(generated_code)
|
91 |
|
92 |
+
# >>> FIX: Pass only the filename to python, and specify cwd
|
93 |
result = subprocess.run(
|
94 |
+
["python", code_filename],
|
95 |
+
capture_output=True,
|
96 |
+
text=True,
|
97 |
+
check=True,
|
98 |
cwd=working_dir
|
99 |
)
|
100 |
print(result.stdout)
|
|
|
123 |
|
124 |
ppt.save("output.pptx")
|
125 |
"""
|
126 |
+
code_filename = "default_slide_code.py"
|
127 |
+
code_file_path = os.path.join(working_dir, code_filename)
|
128 |
+
|
129 |
+
with open(code_file_path, "w", encoding="utf-8") as f:
|
130 |
f.write(default_code)
|
131 |
|
132 |
subprocess.run(
|
133 |
+
["python", code_filename],
|
134 |
capture_output=True,
|
135 |
text=True,
|
136 |
check=True,
|