Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -314,25 +314,29 @@ NAME_TO_FUNC = {
|
|
| 314 |
|
| 315 |
|
| 316 |
def run_action(purpose, task, history, directory, action_name, action_input):
|
| 317 |
-
|
| 318 |
-
action_name
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
if
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
action_name
|
| 329 |
-
|
| 330 |
-
action_name
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
|
|
|
|
|
|
|
|
|
| 335 |
|
|
|
|
| 336 |
|
| 337 |
def run(purpose,hist):
|
| 338 |
|
|
|
|
| 314 |
|
| 315 |
|
| 316 |
def run_action(purpose, task, history, directory, action_name, action_input):
|
| 317 |
+
try:
|
| 318 |
+
if "RESPONSE" in action_name or "COMPLETE" in action_name:
|
| 319 |
+
action_name="COMPLETE"
|
| 320 |
+
task="END"
|
| 321 |
+
return action_name, action_input, history, task
|
| 322 |
+
|
| 323 |
+
# compress the history when it is long
|
| 324 |
+
if len(history.split("\n")) > MAX_HISTORY:
|
| 325 |
+
if VERBOSE:
|
| 326 |
+
print("COMPRESSING HISTORY")
|
| 327 |
+
history = compress_history(purpose, task, history, directory)
|
| 328 |
+
if not action_name in NAME_TO_FUNC:
|
| 329 |
+
action_name="MAIN"
|
| 330 |
+
if action_name == "" or action_name == None:
|
| 331 |
+
action_name="MAIN"
|
| 332 |
+
assert action_name in NAME_TO_FUNC
|
| 333 |
+
|
| 334 |
+
print("RUN: ", action_name, action_input)
|
| 335 |
+
return NAME_TO_FUNC[action_name](purpose, task, history, directory, action_input)
|
| 336 |
+
except Exception as e:
|
| 337 |
+
history += "observation: the previous command did not produce any useful output, I need to check the commands syntax, or use a different command\n"
|
| 338 |
|
| 339 |
+
return "MAIN", None, history, task
|
| 340 |
|
| 341 |
def run(purpose,hist):
|
| 342 |
|