forked from a2aproject/a2a-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.py
More file actions
27 lines (19 loc) · 742 Bytes
/
common.py
File metadata and controls
27 lines (19 loc) · 742 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
from a2a.types import AgentCard, AgentExtension
HTTP_EXTENSION_HEADER = 'X-A2A-Extensions'
def get_requested_extensions(values: list[str]) -> set[str]:
"""Get the set of requested extensions from an input list.
This handles the list containing potentially comma-separated values, as
occurs when using a list in an HTTP header.
"""
return {
stripped
for v in values
for ext in v.split(',')
if (stripped := ext.strip())
}
def find_extension_by_uri(card: AgentCard, uri: str) -> AgentExtension | None:
"""Find an AgentExtension in an AgentCard given a uri."""
for ext in card.capabilities.extensions or []:
if ext.uri == uri:
return ext
return None