Skip to content

Commit

Permalink
feat: raise error when only cmd and cmd wrong.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyr17 committed Aug 30, 2023
1 parent 86a412a commit 2151bcf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion agents/interaction_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,15 @@ def _get_cmd(self) -> Tuple[str, List[str]]:
cmd_num = int(cmd)
if cmd_num < 0 or cmd_num >= len(self.available_reqs):
print('invalid command number')
if self.only_use_command:
raise AssertionError()
continue
return self.available_reqs[cmd_num].name, i[1:]
except ValueError:
print('invalid command')
continue
if self.only_use_command:
raise AssertionError()
continue

def _colors_to_idx(self, color_names: List[str],
all: List[DieColor]) -> List[int]:
Expand Down Expand Up @@ -182,6 +186,8 @@ def generate_response(self, match: Match) -> Responses | None:
return self.resp_use_card(args, reqs) # type: ignore
except Exception as e:
print(f'error: {e}')
if self.only_use_command:
raise e
return self.generate_response(match)

def resp_switch_card(
Expand Down

0 comments on commit 2151bcf

Please sign in to comment.