Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: [conversable_agent] remove list of func pointers #2005

Merged
merged 6 commits into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions autogen/agentchat/conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ def __init__(
)
self._default_auto_reply = default_auto_reply
self._reply_func_list = []
self._ignore_async_func_in_sync_chat_list = []
self._human_input = []
self.reply_at_receive = defaultdict(bool)
self.register_reply([Agent, None], ConversableAgent.generate_oai_reply)
Expand Down Expand Up @@ -342,10 +341,9 @@ def reply_func(
"config": copy.copy(config),
"init_config": config,
"reset_config": reset_config,
"ignore_async_in_sync_chat": ignore_async_in_sync_chat and inspect.iscoroutinefunction(reply_func),
},
)
if ignore_async_in_sync_chat and inspect.iscoroutinefunction(reply_func):
self._ignore_async_func_in_sync_chat_list.append(reply_func)

@staticmethod
def _summary_from_nested_chats(
Expand Down Expand Up @@ -843,9 +841,9 @@ def _raise_exception_on_async_reply_functions(self) -> None:
Raises:
RuntimeError: if any async reply functions are registered.
"""
reply_functions = {f["reply_func"] for f in self._reply_func_list}.difference(
self._ignore_async_func_in_sync_chat_list
)
reply_functions = {
f["reply_func"] for f in self._reply_func_list if not f.get("ignore_async_in_sync_chat", False)
}

async_reply_functions = [f for f in reply_functions if inspect.iscoroutinefunction(f)]
if async_reply_functions != []:
Expand Down
Loading