-
Notifications
You must be signed in to change notification settings - Fork 689
New multi-surface agent example that works with the contact custom component client #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
gspencergoog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't really review the web parts of this very closely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same image as profile2.png. Is that expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me fix
| {{ "key": "contacts", "valueMap": [ | ||
| {{ "key": "contact1", "valueMap": [ | ||
| {{ "key": "name", "valueString": "Alice Wonderland" }}, | ||
| {{ "key": "phone", "valueString": "+1-555-123-4567" }}, | ||
| {{ "key": "email", "valueString": "alice@example.com" }}, | ||
| {{ "key": "imageUrl", "valueString": "https://example.com/alice.jpg" }}, | ||
| {{ "key": "title", "valueString": "Mad Hatter" }}, | ||
| {{ "key": "department", "valueString": "Wonderland" }} | ||
| ] }}, | ||
| {{ "key": "contact2", "valueMap": [ | ||
| {{ "key": "name", "valueString": "Bob The Builder" }}, | ||
| {{ "key": "phone", "valueString": "+1-555-765-4321" }}, | ||
| {{ "key": "email", "valueString": "bob@example.com" }}, | ||
| {{ "key": "imageUrl", "valueString": "https://example.com/bob.jpg" }}, | ||
| {{ "key": "title", "valueString": "Construction" }}, | ||
| {{ "key": "department", "valueString": "Building" }} | ||
| ] }} | ||
| ] }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section uses "{{" and "}}". I'm pretty sure that's invalid in this context. They should probably just be single braces. If they somehow are correct, then the other examples are broken.
| { "surfaceUpdate": { | ||
| "surfaceId": "action-modal", | ||
| "components": [ | ||
| { "id": "modal-wrapper", "component": { "Modal": { "entryPointChild": "hidden-entry-point", "contentChild": "modal-content-column", "open": true } } }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no "open" property on Modal in the specification. Either the spec is out of date, or the properties here are.
| { "id": "description_text_1", "component": { "Text": { "text": { "path": "title"} } } } , | ||
| { "id": "description_text_2", "component": { "Text": { "text": { "path": "team"} } } } , | ||
| { "id": "description_column", "component": { "Column": { "children": { "explicitList": ["user_heading", "description_text_1", "description_text_2"]} , "alignment": "center"} } } , | ||
| { "id": "calendar_icon", "component": { "Icon": { "name": { "literalString": "calendar_today"} } } } , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calendar_today isn't a valid icon name from the enum. It should be calendarToday.
| { "id": "calendar_secondary_text", "component": { "Text": { "text": { "literalString": "Calendar"} } } } , | ||
| { "id": "calendar_text_column", "component": { "Column": { "children": { "explicitList": ["calendar_primary_text", "calendar_secondary_text"]} , "distribution": "start", "alignment": "start"} } } , | ||
| { "id": "info_row_1", "component": { "Row": { "children": { "explicitList": ["calendar_icon", "calendar_text_column"]} , "distribution": "start", "alignment": "start"} } } , | ||
| { "id": "location_icon", "component": { "Icon": { "name": { "literalString": "location_on"} } } } , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
location_on isn't a valid Icon name from the enum. It should be locationOn.
|
|
||
| # a2ui_schema.py | ||
|
|
||
| A2UI_SCHEMA = r''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be referencing the schema available in specification/0.8/json so that it doesn't get out of sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "calendar": "Out of office", | ||
| "imageUrl": "http://localhost:10004/static/profile3.png" | ||
| } | ||
| ] No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add trailing newline.
| {formatted_examples} | ||
| ---BEGIN A2UI JSON SCHEMA--- | ||
| {A2UI_SCHEMA} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could load the file from specification/0.8/json directly instead (but maybe cache it in memory).
| # Check for inline catalog | ||
| if "metadata" in part.root.data and "inlineCatalog" in part.root.data["metadata"]: | ||
| logger.info(f" Part {i}: Found 'inlineCatalog' in DataPart.") | ||
| inline_catalog = part.root.data["metadata"]["inlineCatalog"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think its inlineCatalogs now
I have some keys here fyi
https://github.com/google/A2UI/blob/main/a2a_agents/python/a2ui_extension/src/a2ui/a2ui_extension.py#L30
| agent_card = AgentCard( | ||
| name="Contact Lookup Agent", | ||
| description="This agent helps find contact info for people in your organization.", | ||
| url=base_url, # <-- Use base_url here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need # <-- use base_url here?
|
|
||
| # a2ui_schema.py | ||
|
|
||
| A2UI_SCHEMA = r''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| # a2ui_examples.py | ||
|
|
||
| CONTACT_UI_EXAMPLES = """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try loading examples from json files, here is how i did it in rizzcharts
https://github.com/google/A2UI/blob/main/samples/agent/adk/rizzcharts/agent.py#L50
the nice thing is it validates all your examples so you know you won't confuse the llm with invalid json
| "--- AGENT_EXECUTOR: A2UI extension is active. Using UI agent. ---" | ||
| ) | ||
| else: | ||
| agent = self.text_agent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or just error here
| """ | ||
|
|
||
|
|
||
| def get_ui_prompt(base_url: str, examples: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i found the llmagent instructions lambda handled all this on the fly prompt generation nicely
heres example from rizzcharts
https://github.com/google/A2UI/blob/main/samples/agent/adk/rizzcharts/agent.py#L143
| } | ||
|
|
||
| #onMessage = (event: MessageEvent) => { | ||
| // In production, verify event.origin matches this.src origin (if not opaque). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe implement this for the demo? its kinda a security hole. i imagine people will copy+paste the samples
| // Trusted | ||
| // Always allow same-origin for trusted domains to avoid issues with local assets or CORS checks | ||
| if (this.interactionMode === 'interactive') { | ||
| return "allow-scripts allow-forms allow-popups allow-modals allow-same-origin"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe get rid of allow-popups? these are annoying and u have modals
No description provided.