-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathagent_1.py
More file actions
32 lines (20 loc) · 762 Bytes
/
agent_1.py
File metadata and controls
32 lines (20 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from uagents import Agent, Context, Model
class Message(Model):
message: str
# First generate a secure seed phrase (e.g. https://pypi.org/project/mnemonic/)
SEED_PHRASE = "put_your_seed_phrase_here"
# Now your agent is ready to join the agentverse!
agent = Agent(
name="alice",
seed=SEED_PHRASE,
mailbox=True
)
# Copy the address shown below
print(f"Your agent's address is: {agent.address}")
@agent.on_message(model=Message, replies={Message})
async def handle_message(ctx: Context, sender: str, msg: Message):
ctx.logger.info(f"Received message from {sender}: {msg.message}")
ctx.logger.info("Sending message to bob")
await ctx.send(sender, Message(message="hello there bob"))
if __name__ == "__main__":
agent.run()