feat: Add a A2uiValidator to validate loaded examples#557
feat: Add a A2uiValidator to validate loaded examples#557nan-yu wants to merge 2 commits intogoogle:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces schema bundling and validation capabilities, which is a significant feature enhancement. The changes include a new build hook for packaging schema files, a robust A2uiSchemaManager for handling schema loading and bundling, and an A2uiValidator class. The addition of comprehensive unit and integration tests is commendable and ensures the reliability of the new functionality. I've identified a critical issue related to a missing import that would lead to a runtime error, a high-severity issue concerning error silencing that could complicate debugging, and a couple of medium-severity suggestions for code cleanup and correctness. Overall, this is a well-structured contribution.
a2a_agents/python/a2ui_agent/src/a2ui/inference/template/manager.py
Outdated
Show resolved
Hide resolved
a2a_agents/python/a2ui_agent/src/a2ui/inference/schema/manager.py
Outdated
Show resolved
Hide resolved
a2a_agents/python/a2ui_agent/src/a2ui/inference/schema/loader.py
Outdated
Show resolved
Hide resolved
a2a_agents/python/a2ui_agent/src/a2ui/inference/schema/manager.py
Outdated
Show resolved
Hide resolved
283be8d to
c42f84f
Compare
7464284 to
8f7adb5
Compare
8f7adb5 to
00db217
Compare
- Add a base InferenceStrategy class - Add PackSpecsBuildHook to copy JSON schemas into the package during build time. - Update pyproject.toml to include assets and configure the build hook. - Implement A2uiSchemaManager for robust schema loading, pruning, and prompt generation.
00db217 to
86ea5d0
Compare
86ea5d0 to
836b285
Compare
Description
This pull request significantly enhances the A2UI agent's capabilities by introducing a robust schema validation and management system. It allows for the programmatic loading and validation of A2UI messages and examples against their respective schemas, ensuring data integrity and consistency. The changes also streamline the packaging of A2UI schemas within the Python distribution, making the agent more self-contained and easier to deploy.
Highlights
A2uiValidatorclass to perform schema validation on A2UI messages, ensuring loaded examples conform to the defined A2UI schema versions (0.8 and 0.9+).A2uiSchemaManagerto centralize the loading, resolution, and management of A2UI schemas, including basic, custom, and inline catalogs, and to generate system prompts for LLMs based on these schemas.pack_specs_hook.py) and updatedpyproject.tomlto automatically package A2UI schema definition files into the Python distribution, making them accessible at runtime.A2uiSchemaLoaderwithFileSystemLoaderandPackageLoaderimplementations to support flexible loading of schema files from various sources.Changelog
InferenceStrategyto define an interface for generating system prompts.A2uiCatalogdataclass to represent and manage A2UI component catalogs and their associated schemas.A2uiSchemaLoaderand concreteFileSystemLoaderandPackageLoaderimplementations for loading JSON schema files.A2uiSchemaManagerclass that implementsInferenceStrategyto manage A2UI schemas, determine effective catalogs, and generate system prompts.A2uiSchemaLoaderimplementations and handle fallback mechanisms.A2uiValidatorclass to validate A2UI messages against their respective JSON schemas, supporting both v0.8 and v0.9+ versions.A2uiTemplateManagerclass that implementsInferenceStrategy, with a placeholder for future implementation.A2uiCatalogclass, covering catalog ID, example loading, component pruning, and LLM instruction rendering.A2uiCatalog.resolve_schemastatic method, verifying correct resolution of schema references.A2uiSchemaManagerclass, covering initialization, schema loading fallbacks, custom catalogs, and system prompt generation.A2uiValidatorclass, covering validation for A2UI schema versions 0.8 and 0.9+, including custom components and various validation scenarios.exceptiongroup,google-adk,google-genai,packaging,pycparser, andsqlalchemyversions.Ignored Files
.github/workflows/**(1)