diff --git a/autogen/agentchat/contrib/society_of_mind_agent.py b/autogen/agentchat/contrib/society_of_mind_agent.py index 2f6be5088a4d..e76768187c9f 100644 --- a/autogen/agentchat/contrib/society_of_mind_agent.py +++ b/autogen/agentchat/contrib/society_of_mind_agent.py @@ -39,6 +39,7 @@ def __init__( code_execution_config: Union[Dict, Literal[False]] = False, llm_config: Optional[Union[Dict, Literal[False]]] = False, default_auto_reply: Optional[Union[str, Dict, None]] = "", + **kwargs, ): super().__init__( name=name, @@ -50,6 +51,7 @@ def __init__( code_execution_config=code_execution_config, llm_config=llm_config, default_auto_reply=default_auto_reply, + **kwargs, ) self.update_chat_manager(chat_manager) diff --git a/autogen/agentchat/contrib/web_surfer.py b/autogen/agentchat/contrib/web_surfer.py index af07be6d3432..f74915a9b403 100644 --- a/autogen/agentchat/contrib/web_surfer.py +++ b/autogen/agentchat/contrib/web_surfer.py @@ -41,6 +41,7 @@ def __init__( summarizer_llm_config: Optional[Union[Dict, Literal[False]]] = None, default_auto_reply: Optional[Union[str, Dict, None]] = "", browser_config: Optional[Union[Dict, None]] = None, + **kwargs, ): super().__init__( name=name, @@ -53,6 +54,7 @@ def __init__( code_execution_config=code_execution_config, llm_config=llm_config, default_auto_reply=default_auto_reply, + **kwargs, ) self._create_summarizer_client(summarizer_llm_config, llm_config) diff --git a/autogen/agentchat/conversable_agent.py b/autogen/agentchat/conversable_agent.py index ca1a538e0802..a088c491082e 100644 --- a/autogen/agentchat/conversable_agent.py +++ b/autogen/agentchat/conversable_agent.py @@ -78,6 +78,7 @@ def __init__( default_auto_reply: Union[str, Dict] = "", description: Optional[str] = None, chat_messages: Optional[Dict[Agent, List[Dict]]] = None, + silent: Optional[bool] = None, ): """ Args: @@ -126,6 +127,8 @@ def __init__( chat_messages (dict or None): the previous chat messages that this agent had in the past with other agents. Can be used to give the agent a memory by providing the chat history. This will allow the agent to resume previous had conversations. Defaults to an empty chat history. + silent (bool or None): (Experimental) whether to print the message sent. If None, will use the value of + silent in each function. """ # we change code_execution_config below and we have to make sure we don't change the input # in case of UserProxyAgent, without this we could even change the default value {} @@ -147,6 +150,7 @@ def __init__( if is_termination_msg is not None else (lambda x: content_str(x.get("content")) == "TERMINATE") ) + self.silent = silent # Take a copy to avoid modifying the given dict if isinstance(llm_config, dict): try: @@ -263,6 +267,10 @@ def _validate_llm_config(self, llm_config): ) self.client = None if self.llm_config is False else OpenAIWrapper(**self.llm_config) + @staticmethod + def _is_silent(agent: Agent, silent: Optional[bool] = False) -> bool: + return agent.silent if agent.silent is not None else silent + @property def name(self) -> str: """Get the name of the agent.""" @@ -606,7 +614,9 @@ def _process_message_before_send( """Process the message before sending it to the recipient.""" hook_list = self.hook_lists["process_message_before_send"] for hook in hook_list: - message = hook(sender=self, message=message, recipient=recipient, silent=silent) + message = hook( + sender=self, message=message, recipient=recipient, silent=ConversableAgent._is_silent(self, silent) + ) return message def send( @@ -648,7 +658,7 @@ def send( Raises: ValueError: if the message can't be converted into a valid ChatCompletion message. """ - message = self._process_message_before_send(message, recipient, silent) + message = self._process_message_before_send(message, recipient, ConversableAgent._is_silent(self, silent)) # When the agent composes and sends the message, the role of the message is "assistant" # unless it's "function". valid = self._append_oai_message(message, "assistant", recipient) @@ -698,7 +708,7 @@ async def a_send( Raises: ValueError: if the message can't be converted into a valid ChatCompletion message. """ - message = self._process_message_before_send(message, recipient, silent) + message = self._process_message_before_send(message, recipient, ConversableAgent._is_silent(self, silent)) # When the agent composes and sends the message, the role of the message is "assistant" # unless it's "function". valid = self._append_oai_message(message, "assistant", recipient) @@ -780,7 +790,8 @@ def _process_received_message(self, message: Union[Dict, str], sender: Agent, si raise ValueError( "Received message can't be converted into a valid ChatCompletion message. Either content or function_call must be provided." ) - if not silent: + + if not ConversableAgent._is_silent(sender, silent): self._print_received_message(message, sender) def receive( diff --git a/autogen/agentchat/user_proxy_agent.py b/autogen/agentchat/user_proxy_agent.py index a80296a8355a..d50e4d8b89c5 100644 --- a/autogen/agentchat/user_proxy_agent.py +++ b/autogen/agentchat/user_proxy_agent.py @@ -35,6 +35,7 @@ def __init__( llm_config: Optional[Union[Dict, Literal[False]]] = False, system_message: Optional[Union[str, List]] = "", description: Optional[str] = None, + **kwargs, ): """ Args: @@ -79,6 +80,8 @@ def __init__( Only used when llm_config is not False. Use it to reprogram the agent. 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__). """ super().__init__( name=name, @@ -93,6 +96,7 @@ def __init__( description=( description if description is not None else self.DEFAULT_USER_PROXY_AGENT_DESCRIPTIONS[human_input_mode] ), + **kwargs, ) if logging_enabled(): diff --git a/test/agentchat/test_tool_calls.py b/test/agentchat/test_tool_calls.py index 6a12d2d96edf..e7d45c5918d9 100755 --- a/test/agentchat/test_tool_calls.py +++ b/test/agentchat/test_tool_calls.py @@ -208,6 +208,7 @@ class FakeAgent(autogen.Agent): def __init__(self, name): self._name = name self.received = [] + self.silent = False @property def name(self): @@ -303,6 +304,7 @@ class FakeAgent(autogen.Agent): def __init__(self, name): self._name = name self.received = [] + self.silent = False @property def name(self):