-
Notifications
You must be signed in to change notification settings - Fork 826
Created a new agent to showcase the list of components in the std catalog. Also fixed a few component bugs #596
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8f347c6
fix contact sample
dmandar c6e03b3
Fix dropdown and make it multi-choice
dmandar ee36b32
Add a new component_gallery sample agent and client that allows debug…
dmandar 276582a
Merge branch 'main' into md-componentslistagent
dmandar 667e9ba
Update samples/client/lit/component_gallery/README.md
dmandar 828d6d9
fix modal
dmandar eae7f16
Merge branch 'md-componentslistagent' of https://github.com/google/A2…
dmandar af7e4d1
Address review comments
dmandar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)) { | ||
|
Comment on lines
+195
to
+197
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the |
||
| return this.selections; | ||
| } | ||
|
|
||
| const selectionValue = this.processor.getData( | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this file needa copyright header, like the a2ui schema? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
|
|
||
| """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_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() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why the extra whitespace?
(PS: We probably need autoformatting rules in the repo)