From 4b4f2f3120e6ccdbda8be418fb7a8b383cd90705 Mon Sep 17 00:00:00 2001 From: "Joel Z. Leibo" Date: Mon, 4 Dec 2023 07:52:07 -0800 Subject: [PATCH] Fix bug which was causing agents to repeat a single phrase over and over PiperOrigin-RevId: 587719414 Change-Id: If284d44d7c9ae93d40299537326bf2afc37259d1 --- concordia/agents/basic_agent.py | 13 +++++-------- concordia/typing/agent.py | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/concordia/agents/basic_agent.py b/concordia/agents/basic_agent.py index 22b88be1..d1ae5360 100644 --- a/concordia/agents/basic_agent.py +++ b/concordia/agents/basic_agent.py @@ -70,7 +70,7 @@ def __init__( update_interval: how often to update components. In game time according to the clock argument. verbose: whether to print chains of thought or not - user_controlled: if True, would query user input for speach and action + user_controlled: if True, would query user input for speech and action print_colour: which colour to use for printing """ self._verbose = verbose @@ -261,19 +261,16 @@ def say(self, conversation: str) -> str: f'{self._agent_name} is in the following' f' conversation:\n{conversation}\n' ) - call_to_speach = ( - f'Given the above, what should {self._agent_name} say next? Respond in' - f' the format `{self._agent_name} says: "..."` For example, ' - 'Cristina says: "Hello! Mighty fine weather today, right?" ' - 'or Ichabod says: "I wonder if the alfalfa is ready to harvest.\n' + call_to_speech = agent.DEFAULT_CALL_TO_SPEECH.format( + agent_name=self._agent_name, ) if self._user_controlled: utterance = self._ask_for_input( - convo_context + call_to_speach, f'{self._agent_name}:' + convo_context + call_to_speech, f'{self._agent_name}:' ) else: utterance = self.act( - action_spec=agent.ActionSpec(convo_context + call_to_speach, 'FREE'), + action_spec=agent.ActionSpec(convo_context + call_to_speech, 'FREE'), ) return utterance diff --git a/concordia/typing/agent.py b/concordia/typing/agent.py index 1d4e4976..39257b7a 100644 --- a/concordia/typing/agent.py +++ b/concordia/typing/agent.py @@ -47,7 +47,7 @@ class ActionSpec: OUTPUT_TYPES = ['FREE', 'CHOICE', 'FLOAT'] DEFAULT_CALL_TO_SPEECH = ( - 'Given the above, what did {agent_name} say? Respond in' + 'Given the above, what is {agent_name} likely to say next? Respond in' ' the format `{agent_name} says: "..."` For example, ' 'Cristina says: "Hello! Mighty fine weather today, right?" ' 'or Ichabod says: "I wonder if the alfalfa is ready to harvest.\n'