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: 12 additions & 1 deletion renderers/lit/src/0.8/ui/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { A2uiMessageProcessor } from "@a2ui/web_core/data/model-processor";
import { classMap } from "lit/directives/class-map.js";
import { styleMap } from "lit/directives/style-map.js";
import { structuralStyles } from "./styles.js";
import { extractStringValue } from "./utils/utils.js";

@customElement("a2ui-checkbox")
export class Checkbox extends Root {
Expand Down Expand Up @@ -70,6 +71,8 @@ export class Checkbox extends Root {
return;
}



this.processor.setData(
this.component,
this.value.path,
Expand Down Expand Up @@ -100,7 +103,12 @@ export class Checkbox extends Root {
.checked=${value}
/>
<label class=${classMap(this.theme.components.CheckBox.label)} for="data"
>${this.label?.literalString}</label
>${extractStringValue(
this.label,
this.component,
this.processor,
this.surfaceId
)}</label
>
</section>`;
}
Expand All @@ -113,6 +121,7 @@ export class Checkbox extends Root {
return this.#renderField(this.value.literal);
} else if (this.value && "path" in this.value && this.value.path) {
if (!this.processor || !this.component) {

return html`(no model)`;
}

Expand All @@ -122,6 +131,8 @@ export class Checkbox extends Root {
this.surfaceId ?? A2uiMessageProcessor.DEFAULT_SURFACE_ID
);



if (textValue === null) {
return html`Invalid label`;
}
Expand Down
18 changes: 18 additions & 0 deletions renderers/lit/src/0.8/ui/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ export class Icon extends Root {
min-height: 0;
overflow: auto;
}

.g-icon {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px;
display: inline-block;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
font-feature-settings: 'liga';
}
`,
];

Expand Down
7 changes: 5 additions & 2 deletions renderers/lit/src/0.8/ui/multiple-choice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,11 @@ export class MultipleChoice extends Root {
}

getCurrentSelections(): string[] {
if (!this.processor || !this.component || Array.isArray(this.selections)) {
return [];
if (!this.processor || !this.component) {
return Array.isArray(this.selections) ? this.selections : [];
}
if (Array.isArray(this.selections)) {
return this.selections;
}

const selectionValue = this.processor.getData(
Expand Down
94 changes: 94 additions & 0 deletions samples/agent/adk/component_gallery/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@

"""Main entry point for the Component Gallery agent."""
import logging
import os
import sys

import click
import uvicorn
from a2a.server.apps import A2AStarletteApplication
from a2a.server.request_handlers import DefaultRequestHandler
from a2a.server.tasks import InMemoryTaskStore
from a2a.types import AgentCapabilities, AgentCard, AgentSkill
from a2ui.extension.a2ui_extension import get_a2ui_agent_extension
from starlette.middleware.cors import CORSMiddleware
from dotenv import load_dotenv

from agent import ComponentGalleryAgent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The import ComponentGalleryAgent is not directly used in this file and can be removed to keep the imports clean.

from agent_executor import ComponentGalleryExecutor

load_dotenv()

logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[logging.StreamHandler(sys.stdout)],
force=True,
)

logger = logging.getLogger(__name__)

@click.command()
@click.option("--host", default="localhost")
@click.option("--port", default=10005)
def main(host, port):
try:
capabilities = AgentCapabilities(
streaming=True,
extensions=[get_a2ui_agent_extension()],
)

# Skill definition
skill = AgentSkill(
id="component_gallery",
name="Component Gallery",
description="Demonstrates A2UI components.",
tags=["gallery", "demo"],
examples=["Show me the gallery"],
)

base_url = f"http://{host}:{port}"

agent_card = AgentCard(
name="Component Gallery Agent",
description="A2UI Component Gallery",
url=base_url,
version="0.0.1",
default_input_modes=["text"],
default_output_modes=["text"],
capabilities=capabilities,
skills=[skill],
)

agent_executor = ComponentGalleryExecutor(base_url=base_url)

request_handler = DefaultRequestHandler(
agent_executor=agent_executor,
task_store=InMemoryTaskStore(),
)

server = A2AStarletteApplication(
agent_card=agent_card, http_handler=request_handler
)

app = server.build()

app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:5173"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

# Check if images dir exists before mounting? Skipping for now.

print(f"Starting Component Gallery Agent on port {port}...")
uvicorn.run(app, host=host, port=port)

except Exception as e:
logger.error(f"An error occurred during server startup: {e}")
exit(1)

if __name__ == "__main__":
main()
Loading
Loading