Update app.py
Browse files
app.py
CHANGED
@@ -117,9 +117,8 @@ def main(initial_prompt, run_mode, num_runs, console_output, command_input):
|
|
117 |
|
118 |
while True:
|
119 |
console_output += "\nMenu:\n1. Generate and test a function π¨\n2. Exit π\n"
|
120 |
-
yield console_output
|
121 |
-
choice =
|
122 |
-
command_input = ""
|
123 |
|
124 |
if choice == "1":
|
125 |
if run_mode == "1":
|
@@ -129,18 +128,18 @@ def main(initial_prompt, run_mode, num_runs, console_output, command_input):
|
|
129 |
initial_prompt = f"Continue developing the function:\n{generated_function}"
|
130 |
else:
|
131 |
console_output += "Function test failed. π\n"
|
132 |
-
yield console_output
|
133 |
elif run_mode == "2":
|
134 |
for i in range(int(num_runs)):
|
135 |
console_output += f"\nRun {i+1}:\n"
|
136 |
-
yield console_output
|
137 |
success, error, generated_function = generate_and_test_function(initial_prompt)
|
138 |
if success:
|
139 |
generated_function = handle_post_success_actions(generated_function)
|
140 |
initial_prompt = f"Continue developing the function:\n{generated_function}"
|
141 |
else:
|
142 |
console_output += "Function test failed. π\n"
|
143 |
-
yield console_output
|
144 |
elif run_mode == "3":
|
145 |
while True:
|
146 |
success, error, generated_function = generate_and_test_function(initial_prompt)
|
@@ -149,19 +148,14 @@ def main(initial_prompt, run_mode, num_runs, console_output, command_input):
|
|
149 |
initial_prompt = f"Continue developing the function:\n{generated_function}"
|
150 |
else:
|
151 |
console_output += "Function test failed. Retrying...\n"
|
152 |
-
yield console_output
|
153 |
elif choice == "2":
|
154 |
console_output += "Exiting... Goodbye! π\n"
|
155 |
-
yield console_output
|
156 |
break
|
157 |
else:
|
158 |
console_output += "Invalid choice. Please try again. π
\n"
|
159 |
-
yield console_output
|
160 |
-
|
161 |
-
yield console_output
|
162 |
-
|
163 |
-
|
164 |
-
yield console_output
|
165 |
|
166 |
with gr.Blocks() as demo:
|
167 |
gr.Markdown("# LLM-Powered Function Generator")
|
|
|
117 |
|
118 |
while True:
|
119 |
console_output += "\nMenu:\n1. Generate and test a function π¨\n2. Exit π\n"
|
120 |
+
yield console_output, gr.update(value="") # Clear the command input
|
121 |
+
choice = yield console_output, gr.update(interactive=True) # Wait for user input
|
|
|
122 |
|
123 |
if choice == "1":
|
124 |
if run_mode == "1":
|
|
|
128 |
initial_prompt = f"Continue developing the function:\n{generated_function}"
|
129 |
else:
|
130 |
console_output += "Function test failed. π\n"
|
131 |
+
yield console_output, gr.update(interactive=True)
|
132 |
elif run_mode == "2":
|
133 |
for i in range(int(num_runs)):
|
134 |
console_output += f"\nRun {i+1}:\n"
|
135 |
+
yield console_output, gr.update(interactive=True)
|
136 |
success, error, generated_function = generate_and_test_function(initial_prompt)
|
137 |
if success:
|
138 |
generated_function = handle_post_success_actions(generated_function)
|
139 |
initial_prompt = f"Continue developing the function:\n{generated_function}"
|
140 |
else:
|
141 |
console_output += "Function test failed. π\n"
|
142 |
+
yield console_output, gr.update(interactive=True)
|
143 |
elif run_mode == "3":
|
144 |
while True:
|
145 |
success, error, generated_function = generate_and_test_function(initial_prompt)
|
|
|
148 |
initial_prompt = f"Continue developing the function:\n{generated_function}"
|
149 |
else:
|
150 |
console_output += "Function test failed. Retrying...\n"
|
151 |
+
yield console_output, gr.update(interactive=True)
|
152 |
elif choice == "2":
|
153 |
console_output += "Exiting... Goodbye! π\n"
|
154 |
+
yield console_output, gr.update(interactive=False)
|
155 |
break
|
156 |
else:
|
157 |
console_output += "Invalid choice. Please try again. π
\n"
|
158 |
+
yield console_output, gr.update(interactive=True)
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
with gr.Blocks() as demo:
|
161 |
gr.Markdown("# LLM-Powered Function Generator")
|