Skip to content

Commit

Permalink
fix groupchat bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-husky committed Nov 1, 2023
1 parent dfed092 commit 189de01
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions autogen/gradio_gui/utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def do_audogen(self, input):
# ⭐⭐ run in subprocess
input = input.content
with ProxyNetworkActivate("AutoGen"):
from autogen import AssistantAgent, UserProxyAgent
code_execution_config={"work_dir": self.autogen_work_dir, "use_docker":self.use_docker}
agents = self.define_agents()
user_proxy = None
Expand Down Expand Up @@ -74,12 +73,12 @@ def do_audogen(self, input):
# ⭐⭐ run in subprocess
import autogen
from void_terminal.toolbox import trimmed_format_exc, ProxyNetworkActivate
from autogen.gradio_gui.utils.pipe import PluginMultiprocessManager, PipeCom
from autogen.gradio_gui.utils.pipe import PipeCom
input = input.content
with ProxyNetworkActivate("AutoGen"):
code_execution_config={"work_dir": self.autogen_work_dir, "use_docker":self.use_docker}
agents = self.define_agents()
agents = []
agents_instances = []
for agent_kwargs in agents:
agent_cls = agent_kwargs.pop('cls')
kwargs = {
Expand All @@ -88,13 +87,15 @@ def do_audogen(self, input):
kwargs.update(agent_kwargs)
agent_handle = agent_cls(**kwargs)
agent_handle._print_received_message = lambda a,b: self.gpt_academic_print_override(agent_kwargs, a, b)
agents.append(agent_handle)
agents_instances.append(agent_handle)
if agent_kwargs['name'] == 'user_proxy':
agent_handle.get_human_input = lambda a: self.gpt_academic_get_human_input(user_proxy, a)
user_proxy = agent_handle
user_proxy.get_human_input = lambda a: self.gpt_academic_get_human_input(user_proxy, a)
try:
groupchat = autogen.GroupChat(agents=agents, messages=[], max_round=50)
groupchat = autogen.GroupChat(agents=agents_instances, messages=[], max_round=50)
manager = autogen.GroupChatManager(groupchat=groupchat, **self.define_group_chat_manager_config())
manager._print_received_message = lambda a,b: self.gpt_academic_print_override(agent_kwargs, a, b)
manager.get_human_input = lambda a: self.gpt_academic_get_human_input(manager, a)
if user_proxy is None: raise Exception("user_proxy is not defined")
user_proxy.initiate_chat(manager, message=input)
except Exception as e:
Expand Down

0 comments on commit 189de01

Please sign in to comment.