-
Notifications
You must be signed in to change notification settings - Fork 429
Expand file tree
/
Copy pathagent_card.py
More file actions
76 lines (65 loc) · 2.42 KB
/
agent_card.py
File metadata and controls
76 lines (65 loc) · 2.42 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""Utility functions for inspecting AgentCard instances."""
from a2a.types.a2a_pb2 import AgentCard
def display_agent_card(card: AgentCard) -> None:
"""Print a human-readable summary of an AgentCard to stdout.
Args:
card: The AgentCard proto message to display.
"""
width = 52
sep = '=' * width
thin = '-' * width
lines: list[str] = [sep, 'AgentCard'.center(width), sep]
lines += [
'--- General ---',
f'Name : {card.name}',
f'Description : {card.description}',
f'Version : {card.version}',
]
if card.documentation_url:
lines.append(f'Docs URL : {card.documentation_url}')
if card.icon_url:
lines.append(f'Icon URL : {card.icon_url}')
if card.HasField('provider'):
url_suffix = f' ({card.provider.url})' if card.provider.url else ''
lines.append(f'Provider : {card.provider.organization}{url_suffix}')
lines += ['', '--- Interfaces ---']
for i, iface in enumerate(card.supported_interfaces):
binding = f'{iface.protocol_binding} {iface.protocol_version}'.strip()
parts = [
p
for p in [binding, f'tenant={iface.tenant}' if iface.tenant else '']
if p
]
suffix = f' ({", ".join(parts)})' if parts else ''
line = f' [{i}] {iface.url}{suffix}'
lines.append(line)
lines += [
'',
'--- Capabilities ---',
f'Streaming : {card.capabilities.streaming}',
f'Push notifications : {card.capabilities.push_notifications}',
f'Extended agent card : {card.capabilities.extended_agent_card}',
]
lines += [
'',
'--- I/O Modes ---',
f'Input : {", ".join(card.default_input_modes) or "(none)"}',
f'Output : {", ".join(card.default_output_modes) or "(none)"}',
]
lines += ['', '--- Skills ---']
if card.skills:
for skill in card.skills:
lines += [
thin,
f' ID : {skill.id}',
f' Name : {skill.name}',
f' Description : {skill.description}',
f' Tags : {", ".join(skill.tags) or "(none)"}',
]
if skill.examples:
for ex in skill.examples:
lines.append(f' Example : {ex}')
else:
lines.append(' (none)')
lines.append(sep)
print('\n'.join(lines))