Eric Botti commited on
Commit
bee27cc
·
1 Parent(s): 250cc97

enhanced output formatting

Browse files
src/agent_interfaces.py CHANGED
@@ -100,12 +100,12 @@ class HumanAgentInterface(BaseAgentInterface):
100
 
101
  is_human = True
102
 
103
- def respond_to_formatted(self, message: Message, output_format: Type[BaseModel], **kwargs) -> Type[BaseModel]:
104
  """For Human agents, we can trust them enough to format their own responses... for now"""
105
  response = super().respond_to(message)
106
  # only works because current outputs have only 1 field...
107
- field_name = output_format.model_fields.copy().popitem()[0]
108
- output = output_format.model_validate({field_name: response.content})
109
 
110
  return output
111
 
 
100
 
101
  is_human = True
102
 
103
+ def respond_to_formatted(self, message: Message, output_format: OutputFormat, **kwargs) -> OutputFormatModel:
104
  """For Human agents, we can trust them enough to format their own responses... for now"""
105
  response = super().respond_to(message)
106
  # only works because current outputs have only 1 field...
107
+ field_name = output_format.output_format_model.model_fields.copy().popitem()[0]
108
+ output = output_format.output_format_model.model_validate({field_name: response.content})
109
 
110
  return output
111
 
src/game.py CHANGED
@@ -68,7 +68,7 @@ class Game:
68
  self.players.append(Player(name, player_id, interface))
69
 
70
  # Add Observer - an Agent who can see all the messages, but doesn't actually play
71
- if self.verbose or self.debug and not self.human_index:
72
  self.observer = HumanAgentCLI("{self.game_id}-observer")
73
  else:
74
  self.observer = None
@@ -238,6 +238,7 @@ class Game:
238
  # Point Logic
239
  # If the Chameleon guesses the correct animal = +1 Point to the Chameleon
240
  if chameleon_animal_guess.lower() == herd_animal.lower():
 
241
  chameleon.points += 1
242
  # If the Chameleon guesses the incorrect animal = +1 Point to each Herd player
243
  else:
 
68
  self.players.append(Player(name, player_id, interface))
69
 
70
  # Add Observer - an Agent who can see all the messages, but doesn't actually play
71
+ if (self.verbose or self.debug) and not self.human_index:
72
  self.observer = HumanAgentCLI("{self.game_id}-observer")
73
  else:
74
  self.observer = None
 
238
  # Point Logic
239
  # If the Chameleon guesses the correct animal = +1 Point to the Chameleon
240
  if chameleon_animal_guess.lower() == herd_animal.lower():
241
+
242
  chameleon.points += 1
243
  # If the Chameleon guesses the incorrect animal = +1 Point to each Herd player
244
  else:
src/output_formats.py CHANGED
@@ -79,10 +79,10 @@ class ChameleonGuessFormat(BaseModel):
79
 
80
 
81
  class HerdVoteFormat(BaseModel):
82
- vote: str = Field("The name of the player you are voting for")
83
- """The name of the player you are voting for"""
84
  player_names: List[str] = Field([], exclude=True)
85
  """The names of the players in the game"""
 
 
86
 
87
  @field_validator('vote')
88
  @classmethod
 
79
 
80
 
81
  class HerdVoteFormat(BaseModel):
 
 
82
  player_names: List[str] = Field([], exclude=True)
83
  """The names of the players in the game"""
84
+ vote: str = Field("The name of the player you are voting for")
85
+ """The name of the player you are voting for"""
86
 
87
  @field_validator('vote')
88
  @classmethod
src/prompts.py CHANGED
@@ -37,16 +37,9 @@ Below are the responses from all the other players.
37
  {player_responses}
38
  """
39
 
40
- _chameleon_guess_decision = """\
41
- You now have the opportunity to guess what animal the other players are pretending to be.
42
- If you guess correctly you will WIN, if you guess incorrectly you will LOSE.
43
- If you believe you know what animal the other players are pretending to be make choose to GUESS, otherwise choose to PASS.
44
- Your response should be one of ("GUESS", "PASS")
45
- Your Response:
46
- """
47
-
48
  _chameleon_guess_animal = """\
49
  What animal do you think the other players are pretending to be?
 
50
  """
51
 
52
  _vote_prompt = """\
@@ -58,7 +51,6 @@ prompts = {
58
  "assign_herd": _assign_herd,
59
  "assign_chameleon": _assign_chameleon,
60
  "player_describe_animal": _player_describe_animal,
61
- "chameleon_guess_decision": _all_responses + _chameleon_guess_decision,
62
  "chameleon_guess_animal": _chameleon_guess_animal,
63
  "response": "Your response:",
64
  "vote": _all_responses + _vote_prompt
 
37
  {player_responses}
38
  """
39
 
 
 
 
 
 
 
 
 
40
  _chameleon_guess_animal = """\
41
  What animal do you think the other players are pretending to be?
42
+ Guess the name of the animal not it's plural form e.g. guess "animal" not "animals"
43
  """
44
 
45
  _vote_prompt = """\
 
51
  "assign_herd": _assign_herd,
52
  "assign_chameleon": _assign_chameleon,
53
  "player_describe_animal": _player_describe_animal,
 
54
  "chameleon_guess_animal": _chameleon_guess_animal,
55
  "response": "Your response:",
56
  "vote": _all_responses + _vote_prompt