Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions demo/ui/utils/agent_card.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import requests
import httpx

from a2a.types import AgentCard
from a2a.utils.constants import AGENT_CARD_WELL_KNOWN_PATH


def get_agent_card(remote_agent_address: str) -> AgentCard:
async def get_agent_card(remote_agent_address: str) -> AgentCard:
"""Get the agent card."""
if not remote_agent_address.startswith(('http://', 'https://')):
remote_agent_address = 'http://' + remote_agent_address
agent_card = requests.get(
f'{remote_agent_address}{AGENT_CARD_WELL_KNOWN_PATH}'
)
return AgentCard(**agent_card.json())
async with httpx.AsyncClient() as client:
agent_card = await client.get(
f'{remote_agent_address}{AGENT_CARD_WELL_KNOWN_PATH}'
)
return AgentCard(**agent_card.json())
9 changes: 9 additions & 0 deletions samples/python/hosts/multiagent/remote_agent_connection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import traceback
from collections.abc import Callable

from a2a.client import (
Client,
Expand All @@ -8,10 +9,18 @@
AgentCard,
Message,
Task,
TaskArtifactUpdateEvent,
TaskState,
TaskStatusUpdateEvent,
)


TaskCallbackArg = Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent
# A callable that processes a task update and returns an updated task.
# It's important that implementations of this callback return a `Task` object.
TaskUpdateCallback = Callable[[TaskCallbackArg, AgentCard], Task]


class RemoteAgentConnections:
"""A class to hold the connections to the remote agents."""

Expand Down