Skip to content

Commit

Permalink
Node at the end of class name. team_manager -> teammate.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpt-sn committed Sep 23, 2024
1 parent 2fe03fd commit c172fd9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def try_chat(llm: LLM, develop: bool):
name="Joe",
llm=llm,
system_prompt="Your name is Joe and you are a part of a duo of comedians.",
team_manager=TeamAgent.create(
teammate=TeamAgent.create(
name="Cathy", llm=llm, system_prompt="Your name is Cathy and you are a part of a duo of comedians."
),
max_turns=3,
Expand Down
2 changes: 1 addition & 1 deletion examples/code_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def try_chat(llm: LLM, develop: bool):
name="UserProxy",
llm=llm,
system_prompt="",
team_manager=TeamAgent.create(
teammate=TeamAgent.create(
name="Assistant",
system_prompt=AUTOGEN_ASSISTANT_SYSTEM_MESSAGE,
llm=llm,
Expand Down
2 changes: 1 addition & 1 deletion examples/data_science.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def make_world(llm: LLM | None = None, env: Environment | None = None) -> tuple[
"Make a plot comparing the stocks of ServiceNow and Salesforce"
" since beginning of 2024. Save it to a PNG file."
),
team_manager=team,
teammate=team,
)
start_tape = TeamTape(context=None, steps=[])
now = f"{datetime.datetime.now():%Y%m%d%H%M%S}"
Expand Down
2 changes: 1 addition & 1 deletion examples/multi_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def try_chat(develop: bool):
org = TeamAgent.create_chat_initiator(
name="UserProxy",
init_message="Find a latest paper about gpt-4 on arxiv and find its potential applications in software.",
team_manager=team,
teammate=team,
)
start_tape = TeamTape(context=None, steps=[])
now = f"{datetime.datetime.now():%Y%m%d%H%M%S}"
Expand Down
30 changes: 15 additions & 15 deletions tapeagents/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, agent: TeamAgent, tape: TeamTape):
self.steps_by_kind = view.top.steps_by_kind
self.exec_result = self.steps[-1] if self.steps and isinstance(self.steps[-1], CodeExecutionResult) else None
self.should_generate_message = (
isinstance(self.node, (NodeCall, NodeRespond))
isinstance(self.node, (CallNode, RespondNode))
and self.messages
and not self.exec_result
and "system" in agent.templates
Expand Down Expand Up @@ -72,7 +72,7 @@ def create(
name=name,
templates={"system": system_prompt} if system_prompt else {},
llms={DEFAULT: llm} if llm else {},
flow=([NodeExecuteCode()] if execute_code else []) + [NodeRespond()],
flow=([ExecuteCodeNode()] if execute_code else []) + [RespondNode()],
)

@classmethod
Expand All @@ -91,9 +91,9 @@ def create_team_manager(
name=name,
subagents=subagents,
flow=[
NodeBroadcastLastMessage(),
NodeSelectAndCall(),
NodeRespondOrRepeat(),
BroadcastLastMessageNode(),
SelectAndCallNode(),
RespondOrRepeatNode(),
],
max_calls=max_calls,
templates={
Expand All @@ -107,7 +107,7 @@ def create_team_manager(
def create_chat_initiator(
cls,
name: str,
team_manager: Agent[TeamTape],
teammate: Agent[TeamTape],
init_message: str,
system_prompt: str = "",
llm: LLM | None = None,
Expand All @@ -123,14 +123,14 @@ def create_chat_initiator(
"system": system_prompt,
},
llms={DEFAULT: llm} if llm else {},
subagents=[team_manager],
flow=([NodeExecuteCode()] if execute_code else []) + [NodeCall(), NodeTerminateOrRepeat()],
subagents=[teammate],
flow=([ExecuteCodeNode()] if execute_code else []) + [CallNode(), TerminateOrRepeatNode()],
max_calls=max_calls,
init_message=init_message,
)


class NodeBroadcastLastMessage(Node):
class BroadcastLastMessageNode(Node):
name: str = "broadcast_last_message"

def generate_steps(
Expand All @@ -157,7 +157,7 @@ def generate_steps(
assert False


class NodeCall(Node):
class CallNode(Node):
name: str = "call"

def make_prompt(self, agent: TeamAgent, tape: TeamTape) -> Prompt:
Expand All @@ -183,7 +183,7 @@ def generate_steps(
yield Call(task=self.name, agent_name=other.name, content=agent.init_message)


class NodeSelectAndCall(Node):
class SelectAndCallNode(Node):
name: str = "select_and_call"

def make_prompt(self, agent: TeamAgent, tape: TeamTape) -> Prompt:
Expand Down Expand Up @@ -211,7 +211,7 @@ def generate_steps(
yield Call(task=self.name, agent_name=callee_name)


class NodeExecuteCode(Node):
class ExecuteCodeNode(Node):
name: str = "execute_code"

def generate_steps(self, agent: logging.Any, tape: Tape, llm_stream: LLMStream) -> Generator[AgentStep, None, None]:
Expand All @@ -225,7 +225,7 @@ def generate_steps(self, agent: logging.Any, tape: Tape, llm_stream: LLMStream)
yield Pass(task=self.name)


class NodeRespond(Node):
class RespondNode(Node):
name: str = "respond"

def make_prompt(self, agent: TeamAgent, tape: TeamTape) -> Prompt:
Expand All @@ -252,7 +252,7 @@ def generate_steps(
yield Respond(task=self.name)


class NodeTerminateOrRepeat(Node):
class TerminateOrRepeatNode(Node):
name: str = "terminate_or_repeat"

def generate_steps(
Expand All @@ -266,7 +266,7 @@ def generate_steps(
yield Jump(task=self.name, next_node=0)


class NodeRespondOrRepeat(Node):
class RespondOrRepeatNode(Node):
name: str = "respond_or_repeat"

def generate_steps(
Expand Down

0 comments on commit c172fd9

Please sign in to comment.