Skip to content

Commit

Permalink
Merge branch 'main' into fixcompress
Browse files Browse the repository at this point in the history
  • Loading branch information
yiranwu0 authored Nov 11, 2023
2 parents 37a923d + 6bb7acc commit c49a1a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions autogen/agentchat/conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ def last_message(self, agent: Optional[Agent] = None) -> Dict:
for conversation in self._oai_messages.values():
return conversation[-1]
raise ValueError("More than one conversation is found. Please specify the sender to get the last message.")
if agent not in self._oai_messages.keys():
raise KeyError(
f"The agent '{agent.name}' is not present in any conversation. No history available for this agent."
)
return self._oai_messages[agent][-1]

@property
Expand Down
8 changes: 6 additions & 2 deletions test/agentchat/test_conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ def test_conversable_agent():
dummy_agent_1.update_system_message("new system message")
assert dummy_agent_1.system_message == "new system message"

dummy_agent_3 = ConversableAgent(name="dummy_agent_3", llm_config=False, human_input_mode="TERMINATE")
with pytest.raises(KeyError):
dummy_agent_1.last_message(dummy_agent_3)


def test_generate_reply():
def add_num(num_to_be_added):
Expand Down Expand Up @@ -242,7 +246,7 @@ async def test_a_generate_reply_raises_on_messages_and_sender_none(conversable_a


if __name__ == "__main__":
test_trigger()
# test_trigger()
# test_context()
# test_max_consecutive_auto_reply()
# test_conversable_agent(pytest.monkeypatch)
test_conversable_agent()

0 comments on commit c49a1a2

Please sign in to comment.