Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .github/workflows/python_samples_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ jobs:
working-directory: samples/agent/adk
run: uv run pyink --check .

- name: Validate Sample Examples
run: |
PYTHONPATH=agent_sdks/python/src uv run --project agent_sdks/python pytest -vv samples/agent/adk/tests/test_examples_validation.py

- name: Build contact_lookup
working-directory: samples/agent/adk/contact_lookup
run: uv build .
Expand Down
4 changes: 2 additions & 2 deletions samples/agent/adk/component_gallery/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from starlette.middleware.cors import CORSMiddleware
from starlette.staticfiles import StaticFiles
from dotenv import load_dotenv
from a2ui.core.schema.constants import VERSION_0_8
from a2ui.core.schema.constants import VERSION_0_8, VERSION_0_9


from agent_executor import ComponentGalleryExecutor
Expand All @@ -51,7 +51,7 @@
def main(host, port):
try:
extensions = []
for v in [VERSION_0_8]:
for v in [VERSION_0_8, VERSION_0_9]:
extensions.append(get_a2ui_agent_extension(v))
capabilities = AgentCapabilities(
streaming=True,
Expand Down
12 changes: 8 additions & 4 deletions samples/agent/adk/component_gallery/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import logging
from collections.abc import AsyncIterable
from typing import Any
from typing import Any, Optional
import json

from a2a.types import DataPart, Part, TextPart
Expand All @@ -37,14 +37,18 @@ class ComponentGalleryAgent:
def __init__(self, base_url: str):
self.base_url = base_url

async def stream(self, query: str, session_id: str) -> AsyncIterable[dict[str, Any]]:
async def stream(
self, query: str, session_id: str, active_ui_version: Optional[str]
) -> AsyncIterable[dict[str, Any]]:
"""Streams the gallery or responses to actions."""

logger.info(f"Stream called with query: {query}")
logger.info(
f"Stream called with query: {query} and active_ui_version: {active_ui_version}"
)

# Initial Load or Reset
if "WHO_ARE_YOU" in query or "START" in query: # Simple trigger for initial load
gallery_json = get_gallery_json()
gallery_json = get_gallery_json(active_ui_version)
yield {
"is_task_complete": True,
"parts": parse_response_to_parts(
Expand Down
5 changes: 3 additions & 2 deletions samples/agent/adk/component_gallery/agent_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ async def execute(self, context: RequestContext, event_queue: EventQueue) -> Non
query = "START" # Default start
ui_event_part = None

try_activate_a2ui_extension(context, self._agent_card)
active_ui_version = try_activate_a2ui_extension(context, self._agent_card)
logger.info(f"Active UI version: {active_ui_version}")

if context.message and context.message.parts:
for part in context.message.parts:
Expand All @@ -63,7 +64,7 @@ async def execute(self, context: RequestContext, event_queue: EventQueue) -> Non

updater = TaskUpdater(event_queue, task.id, task.context_id)

async for item in self.agent.stream(query, task.context_id):
async for item in self.agent.stream(query, task.context_id, active_ui_version):
final_parts = item["parts"]

await updater.update_status(
Expand Down
Loading
Loading