Skip to content

Commit

Permalink
fix agentstudio when using non gpt
Browse files Browse the repository at this point in the history
  • Loading branch information
Devashish Tyagi authored and Devashish Tyagi committed Jan 18, 2024
1 parent 46e76d2 commit 93173c0
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions samples/apps/autogen-studio/autogenstudio/workflowmanager.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from typing import List, Optional
from dataclasses import asdict
from datetime import datetime
from typing import List, Optional

import autogen

from .datamodel import AgentFlowSpec, AgentWorkFlowConfig, Message
from .utils import get_skills_from_prompt, clear_folder
from datetime import datetime
from .utils import clear_folder, get_skills_from_prompt


class AutoGenWorkFlowManager:
Expand Down Expand Up @@ -102,7 +104,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:
Expand Down Expand Up @@ -139,10 +142,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
Expand Down

0 comments on commit 93173c0

Please sign in to comment.