From 70704d885d0b992dd7230b4876d4af12d675481c Mon Sep 17 00:00:00 2001 From: Devashish Tyagi Date: Thu, 18 Jan 2024 16:32:30 -0500 Subject: [PATCH] fix agentstudio when using non gpt --- .../autogenstudio/workflowmanager.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/samples/apps/autogen-studio/autogenstudio/workflowmanager.py b/samples/apps/autogen-studio/autogenstudio/workflowmanager.py index a28bc9a7dd34..1d5939f18543 100644 --- a/samples/apps/autogen-studio/autogenstudio/workflowmanager.py +++ b/samples/apps/autogen-studio/autogenstudio/workflowmanager.py @@ -102,7 +102,8 @@ def sanitize_agent_spec(self, agent_spec: AgentFlowSpec) -> AgentFlowSpec: """ agent_spec.config.is_termination_msg = agent_spec.config.is_termination_msg or ( - lambda x: "TERMINATE" in x.get("content", "").rstrip() + lambda x: x.get("content", "") + and "TERMINATE" in x.get("content", "").rstrip() ) skills_prompt = "" if agent_spec.skills: @@ -139,10 +140,18 @@ def load(self, agent_spec: AgentFlowSpec) -> autogen.Agent: agent_spec = self.sanitize_agent_spec(agent_spec) if agent_spec.type == "assistant": agent = autogen.AssistantAgent(**asdict(agent_spec.config)) - agent.register_reply([autogen.Agent, None], reply_func=self.process_reply, config={"callback": None}) + agent.register_reply( + [autogen.Agent, None], + reply_func=self.process_reply, + config={"callback": None}, + ) elif agent_spec.type == "userproxy": agent = autogen.UserProxyAgent(**asdict(agent_spec.config)) - agent.register_reply([autogen.Agent, None], reply_func=self.process_reply, config={"callback": None}) + agent.register_reply( + [autogen.Agent, None], + reply_func=self.process_reply, + config={"callback": None}, + ) else: raise ValueError(f"Unknown agent type: {agent_spec.type}") return agent