-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathagent.py
More file actions
32 lines (24 loc) · 1005 Bytes
/
agent.py
File metadata and controls
32 lines (24 loc) · 1005 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 a2a.server.tasks import TaskUpdater
from a2a.types import Message, TaskState, Part, TextPart
from a2a.utils import get_message_text, new_agent_text_message
from messenger import Messenger
class Agent:
def __init__(self):
self.messenger = Messenger()
# Initialize other state here
async def run(self, message: Message, updater: TaskUpdater) -> None:
"""Implement your agent logic here.
Args:
message: The incoming message
updater: Report progress (update_status) and results (add_artifact)
Use self.messenger.talk_to_agent(message, url) to call other agents.
"""
input_text = get_message_text(message)
# Replace this example code with your agent logic
await updater.update_status(
TaskState.working, new_agent_text_message("Thinking...")
)
await updater.add_artifact(
parts=[Part(root=TextPart(text=input_text))],
name="Echo",
)