Skip to content

Commit

Permalink
fix chatroom example
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-x-c committed Oct 16, 2024
1 parent e6f7dc3 commit 6bf0fb5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ def main(args: argparse.Namespace) -> None:
carol.join(r)

# Start the chat
r.chatting(delay={carol.agent_id: 0, bob.agent_id: 5})
r.chat_freely(
delay=10,
interval=10,
max_round=10,
)


if __name__ == "__main__":
Expand Down
13 changes: 7 additions & 6 deletions examples/environments/chatroom/envs/chatroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ def get_history(self, agent_name: str) -> List[Msg]:

def describe(self, agent_name: str, **kwargs: Any) -> str:
"""Get the description of the chatroom."""
ann = self.announcement if self.announcement else "EMPTY"
ann = (
self.announcement.content if self.announcement.content else "EMPTY"
)
history = "\n\n".join(
[
f"{msg.name}: {msg.content}"
Expand Down Expand Up @@ -265,10 +267,10 @@ def chat_freely(
task.join()

def chat_in_sequence(self, agent_name_order: List[str] = None) -> None:
"""Let all agents to chat in a sequence
"""Let all agents chat in sequence
Args:
sequence (`List[str]`): Order of speakers' names.
agent_name_order (`List[str]`): Order of speakers' names.
"""
for agent_name in agent_name_order:
self.children[agent_name].chat()
Expand Down Expand Up @@ -361,9 +363,8 @@ def _want_to_speak(self, hint: str) -> bool:
prompt,
max_retries=3,
).text
speak = "yes" in response.lower()
logger.debug(f"[SPEAK OR NOT] {self.name}: {response}")
return speak
logger.info(f"[SPEAK OR NOT] {self.name}: {response}")
return "yes" in response.lower()

def speak(
self,
Expand Down

0 comments on commit 6bf0fb5

Please sign in to comment.