feat: Handle exceptions in tactic generation
This commit is contained in:
parent
9fc035d466
commit
8196493258
|
@ -58,23 +58,27 @@ class LLMAgent(Agent):
|
||||||
new_state = None
|
new_state = None
|
||||||
for ii in range(self.n_trials):
|
for ii in range(self.n_trials):
|
||||||
print(f"===============trail {str(ii)}============")
|
print(f"===============trail {str(ii)}============")
|
||||||
s = select_tactic.run(
|
try:
|
||||||
server=self.server,
|
s = select_tactic.run(
|
||||||
state=state,
|
server=self.server,
|
||||||
goal_id=goal_id,
|
state=state,
|
||||||
informal_stmt=self.informal_stmt,
|
goal_id=goal_id,
|
||||||
informal_proof=self.informal_proof,
|
informal_stmt=self.informal_stmt,
|
||||||
feedback_turns=self.feedback_turns)
|
informal_proof=self.informal_proof,
|
||||||
tactic, new_state = s.ret_value
|
feedback_turns=self.feedback_turns)
|
||||||
for m in s.messages():
|
tactic, new_state = s.ret_value
|
||||||
print(m["role"], ":", m["content"])
|
for m in s.messages():
|
||||||
|
print(m["role"], ":", m["content"])
|
||||||
|
|
||||||
print("\n-- new state --\n", new_state)
|
print("\n-- new state --\n", new_state)
|
||||||
if tactic:
|
if tactic:
|
||||||
if not isinstance(tactic, Tactic):
|
if not isinstance(tactic, Tactic):
|
||||||
print(colored("[Tactic] Failed:", "red"), tactic)
|
print(colored("[Tactic] Failed:", "red"), tactic)
|
||||||
return None
|
return None
|
||||||
return tactic
|
return tactic
|
||||||
|
except Exception as e:
|
||||||
|
print(colored(str(e), "red"))
|
||||||
|
return None
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
self.goal_tactic_id_map[key] = i + 1
|
self.goal_tactic_id_map[key] = i + 1
|
||||||
|
|
Loading…
Reference in New Issue