johann22 commited on
Commit
ec2a28d
1 Parent(s): eb1783d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -18
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
- if "RESPONSE" in action_name or "COMPLETE" in action_name:
318
- action_name="COMPLETE"
319
- task="END"
320
- return action_name, action_input, history, task
321
-
322
- # compress the history when it is long
323
- if len(history.split("\n")) > MAX_HISTORY:
324
- if VERBOSE:
325
- print("COMPRESSING HISTORY")
326
- history = compress_history(purpose, task, history, directory)
327
- if not action_name in NAME_TO_FUNC:
328
- action_name="MAIN"
329
- if action_name == "" or action_name == None:
330
- action_name="MAIN"
331
- assert action_name in NAME_TO_FUNC
332
-
333
- print("RUN: ", action_name, action_input)
334
- return NAME_TO_FUNC[action_name](purpose, task, history, directory, action_input)
 
 
 
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