Skip to content

Commit

Permalink
fix: forward kwargs to conversable agent + fix typing (microsoft#1193)
Browse files Browse the repository at this point in the history
* fix: forwards kwargs to conversable agent + typing

* add description unit test

* add documentation for description
  • Loading branch information
joseferben committed Jan 13, 2024
1 parent 2018b2c commit 1cd3709
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions autogen/agentchat/contrib/compressible_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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__).
"""
Expand All @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions test/agentchat/contrib/test_compressible_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 1cd3709

Please sign in to comment.