From 1cd3709e1941d6cf5a3a176e7460b8e9ea7b42e1 Mon Sep 17 00:00:00 2001 From: Josef Erben Date: Sat, 13 Jan 2024 16:01:39 +0100 Subject: [PATCH] fix: forward kwargs to conversable agent + fix typing (#1193) * fix: forwards kwargs to conversable agent + typing * add description unit test * add documentation for description --- autogen/agentchat/contrib/compressible_agent.py | 6 ++++++ test/agentchat/contrib/test_compressible_agent.py | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/autogen/agentchat/contrib/compressible_agent.py b/autogen/agentchat/contrib/compressible_agent.py index 72f31b6f3ea..a8a186edc43 100644 --- a/autogen/agentchat/contrib/compressible_agent.py +++ b/autogen/agentchat/contrib/compressible_agent.py @@ -63,6 +63,8 @@ def __init__( llm_config: Optional[Union[Dict, bool]] = None, default_auto_reply: Optional[Union[str, Dict, None]] = "", compress_config: Optional[Dict] = False, + description: Optional[str] = None, + **kwargs, ): """ Args: @@ -93,6 +95,8 @@ def __init__( - "broadcast" (Optional, bool, default to True): whether to update the compressed message history to sender. - "verbose" (Optional, bool, default to False): Whether to print the content before and after compression. Used when mode="COMPRESS". - "leave_last_n" (Optional, int, default to 0): If provided, the last n messages will not be compressed. Used when mode="COMPRESS". + description (str): a short description of the agent. This description is used by other agents + (e.g. the GroupChatManager) to decide when to call upon this agent. (Default: system_message) **kwargs (dict): Please refer to other kwargs in [ConversableAgent](../conversable_agent#__init__). """ @@ -106,6 +110,8 @@ def __init__( code_execution_config=code_execution_config, llm_config=llm_config, default_auto_reply=default_auto_reply, + description=description, + **kwargs, ) self._set_compress_config(compress_config) diff --git a/test/agentchat/contrib/test_compressible_agent.py b/test/agentchat/contrib/test_compressible_agent.py index 4682e042072..c5ef784f64b 100644 --- a/test/agentchat/contrib/test_compressible_agent.py +++ b/test/agentchat/contrib/test_compressible_agent.py @@ -211,8 +211,19 @@ def test_mode_terminate(): assert final, "Terminating the conversation at max token limit is not working." +@pytest.mark.skipif( + sys.platform in ["darwin", "win32"] or skip, + reason="do not run on MacOS or windows OR dependency is not installed OR requested to skip", +) +def test_new_compressible_agent_description(): + assistant = CompressibleAgent(name="assistant", description="this is a description") + + assert assistant.description == "this is a description", "description is not set correctly" + + if __name__ == "__main__": test_mode_compress() test_mode_customized() test_compress_message() test_mode_terminate() + test_new_compressible_agent_description()