Skip to content

Commit

Permalink
Register async human input handler (#794)
Browse files Browse the repository at this point in the history
* Update conversable_agent.py

* Add files via upload

* Delete notebook/Async_human_input.ipynb

* Add files via upload

* refactor:formatter

* feat:updated position

---------

Co-authored-by: Chi Wang <[email protected]>
  • Loading branch information
ShobhitVishnoi30 and sonichi authored Dec 3, 2023
1 parent c19f234 commit 5c92fb3
Show file tree
Hide file tree
Showing 4 changed files with 379 additions and 2 deletions.
2 changes: 1 addition & 1 deletion autogen/agentchat/contrib/llava_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(
)

assert self.llm_config is not None, "llm_config must be provided."
self.register_reply([Agent, None], reply_func=LLaVAAgent._image_reply, position=1)
self.register_reply([Agent, None], reply_func=LLaVAAgent._image_reply, position=2)

def _image_reply(self, messages=None, sender=None, config=None):
# Note: we did not use "llm_config" yet.
Expand Down
2 changes: 1 addition & 1 deletion autogen/agentchat/contrib/retrieve_user_proxy_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def retrieve_docs(self, problem: str, n_results: int = 20, search_string: str =
self._is_termination_msg = (
self._is_termination_msg_retrievechat if is_termination_msg is None else is_termination_msg
)
self.register_reply(Agent, RetrieveUserProxyAgent._generate_retrieve_user_reply, position=1)
self.register_reply(Agent, RetrieveUserProxyAgent._generate_retrieve_user_reply, position=2)

def _is_termination_msg_retrievechat(self, message):
"""Check if a message is a termination message.
Expand Down
1 change: 1 addition & 0 deletions autogen/agentchat/conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def __init__(
self.register_reply([Agent, None], ConversableAgent.generate_function_call_reply)
self.register_reply([Agent, None], ConversableAgent.generate_async_function_call_reply)
self.register_reply([Agent, None], ConversableAgent.check_termination_and_human_reply)
self.register_reply([Agent, None], ConversableAgent.a_check_termination_and_human_reply)

def register_reply(
self,
Expand Down
Loading

3 comments on commit 5c92fb3

@momuno
Copy link
Member

@momuno momuno commented on 5c92fb3 Dec 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean for the other contributed agents built on ConversableAgent that have a custom reply function registered at a specific position?

For example, the teachable agent registers its custom reply at position 1,
self.register_reply(Agent, TeachableAgent._generate_teachable_assistant_reply, 1)
https://github.com/microsoft/autogen/blob/7a4ba1a732ae29cb3d5c9a1b30724a4ba6891ca6/autogen/agentchat/contrib/teachable_agent.py#L66C89-L66C89
Before this commit, the TeachableAgent's custom reply would have come after check_termination_and_human_reply. But now, it looks like it will come after a_check_termination_and_human_reply but before check_termination_and_human_reply.

I'm concerned about how changes to this default register_reply order in ConversableAgent will affect other agents that have taken a dependency on this order. Is it assumed that anything in contrib/ may experience breaking changes? Thanks!

@sonichi
Copy link
Contributor

@sonichi sonichi commented on 5c92fb3 Dec 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unexpected breaking change. I overlooked the register_reply methods without specifying the keyword position=.

@momuno
Copy link
Member

@momuno momuno commented on 5c92fb3 Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unexpected breaking change. I overlooked the register_reply methods without specifying the keyword position=.

ah ok. Thanks for your response!

Please sign in to comment.