Skip to content

Commit

Permalink
Rename agents to sources, avoid ambiguous naming
Browse files Browse the repository at this point in the history
  • Loading branch information
thaind-taureau committed Nov 13, 2024
1 parent f3470bc commit 738d02f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@


class SourceMatchTermination(TerminationCondition):
"""Terminate the conversation after a specific agent responds.
"""Terminate the conversation after a specific source responds.
Args:
agents (List[str]): List of agent names to terminate the conversation.
sources (List[str]): List of source names to terminate the conversation.
Raises:
TerminatedException: If the termination condition has already been reached.
"""

def __init__(self, agents: List[str]) -> None:
self._agents = agents
def __init__(self, sources: List[str]) -> None:
self._sources = sources
self._terminated = False

@property
Expand All @@ -28,9 +28,9 @@ async def __call__(self, messages: Sequence[AgentMessage]) -> StopMessage | None
if not messages:
return None
last_message = messages[-1]
if last_message.source in self._agents:
if last_message.source in self._sources:
self._terminated = True
return StopMessage(content=f"Agent '{last_message.source}' answered", source="SourceMatchTermination")
return StopMessage(content=f"'{last_message.source}' answered", source="SourceMatchTermination")
return None

async def reset(self) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@pytest.mark.asyncio
async def test_agent_name_termination() -> None:
termination = SourceMatchTermination(agents=["Assistant"])
termination = SourceMatchTermination(sources=["Assistant"])
assert await termination([]) is None

continue_messages = [
Expand Down

0 comments on commit 738d02f

Please sign in to comment.