Skip to content

Commit

Permalink
fix spelling error (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackgerrits authored May 20, 2024
1 parent b4b1fd5 commit f80c42e
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


@dataclass
class BroadcastMessageEnvolope(Generic[T]):
class BroadcastMessageEnvelope(Generic[T]):
"""A message envelope for broadcasting messages to all agents that can handle
the message of the type T."""

Expand Down Expand Up @@ -48,7 +48,7 @@ class BroadcastResponseMessageEnvelope(Generic[T]):
class SingleThreadedAgentRuntime(AgentRuntime[T]):
def __init__(self) -> None:
self._message_queue: List[
BroadcastMessageEnvolope[T]
BroadcastMessageEnvelope[T]
| SendMessageEnvelope[T]
| ResponseMessageEnvelope[T]
| BroadcastResponseMessageEnvelope[T]
Expand All @@ -74,7 +74,7 @@ def send_message(self, message: T, destination: Agent[T]) -> Future[T]:
# Returns the response of all handling agents
def broadcast_message(self, message: T) -> Future[List[T]]:
future: Future[List[T]] = asyncio.get_event_loop().create_future()
self._message_queue.append(BroadcastMessageEnvolope(message, future))
self._message_queue.append(BroadcastMessageEnvelope(message, future))
return future

async def _process_send(self, message_envelope: SendMessageEnvelope[T]) -> None:
Expand All @@ -86,7 +86,7 @@ async def _process_send(self, message_envelope: SendMessageEnvelope[T]) -> None:
response = await recipient.on_message(message_envelope.message)
self._message_queue.append(ResponseMessageEnvelope(response, message_envelope.future))

async def _process_broadcast(self, message_envelope: BroadcastMessageEnvolope[T]) -> None:
async def _process_broadcast(self, message_envelope: BroadcastMessageEnvelope[T]) -> None:
responses: List[Awaitable[T]] = []
for agent in self._per_type_subscribers.get(type(message_envelope.message), []):
future = agent.on_message(message_envelope.message)
Expand All @@ -112,8 +112,8 @@ async def process_next(self) -> None:
match message_envelope:
case SendMessageEnvelope(message, destination, future):
asyncio.create_task(self._process_send(SendMessageEnvelope(message, destination, future)))
case BroadcastMessageEnvolope(message, future):
asyncio.create_task(self._process_broadcast(BroadcastMessageEnvolope(message, future)))
case BroadcastMessageEnvelope(message, future):
asyncio.create_task(self._process_broadcast(BroadcastMessageEnvelope(message, future)))
case ResponseMessageEnvelope(message, future):
asyncio.create_task(self._process_response(ResponseMessageEnvelope(message, future)))
case BroadcastResponseMessageEnvelope(message, future):
Expand Down

0 comments on commit f80c42e

Please sign in to comment.