Skip to content

Commit

Permalink
update: example
Browse files Browse the repository at this point in the history
  • Loading branch information
Archento committed Oct 29, 2024
1 parent 6d9bc60 commit 856731d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions python/examples/13-agent-name-service/agent1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class Message(Model):
message: str
text: str


DOMAIN = "bob.example.agent"
Expand Down Expand Up @@ -39,7 +39,7 @@ async def register_agent_name(ctx: Context):

@bob.on_message(model=Message)
async def message_handler(ctx: Context, sender: str, msg: Message):
ctx.logger.info(f"Received message from {sender}: {msg.message}")
ctx.logger.info(f"Received message from {sender}: {msg.text}")


if __name__ == "__main__":
Expand Down
10 changes: 5 additions & 5 deletions python/examples/13-agent-name-service/agent2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@


class Message(Model):
message: str
text: str


alice = Agent(
name="alice-0",
name="alice",
seed="agent alice-0 secret phrase",
port=8000,
endpoint=["http://localhost:8000/submit"],
)

DOMAIN = "example.agent"
DOMAIN = "bob.example.agent"


@alice.on_interval(period=5)
async def alice_interval_handler(ctx: Context):
bob_name = "bob-0" + "." + DOMAIN
bob_name = DOMAIN
ctx.logger.info(f"Sending message to {bob_name}...")
await ctx.send(bob_name, Message(message="Hello there bob."))
await ctx.send(bob_name, Message(text="Hello there bob."))


if __name__ == "__main__":
Expand Down

0 comments on commit 856731d

Please sign in to comment.