-
Notifications
You must be signed in to change notification settings - Fork 248
Feat spring boot starter #653
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
Summary of ChangesHello @mekkiamiri, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request delivers a new Spring Boot Starter for the Google Agent Development Kit (ADK), streamlining the process of building agent-powered applications within the Spring ecosystem. It encapsulates the setup of essential ADK components, offering flexible configuration options for various service implementations. The inclusion of a dedicated sample application provides a practical guide for developers to quickly adopt and utilize the starter. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces a new Spring Boot starter for the Google Agent Development Kit (ADK), which is a valuable addition for easier integration. The auto-configuration logic is generally well-structured. My review focuses on several critical dependency versioning issues in the pom.xml files that could lead to build failures. I've also provided suggestions to improve the auto-configuration classes by adhering more closely to Spring best practices, such as proper dependency injection and failing fast on unsupported configurations. The sample application is a helpful example, and I've included some refactoring suggestions to enhance it as a template.
|
|
||
| <properties> | ||
| <java.version>21</java.version> | ||
| <spring-boot.version>4.0.0</spring-boot.version> |
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.
The spring-boot.version is set to 4.0.0, which is not a stable Spring Boot release. Further down, spring-boot-dependencies is imported with version 3.3.0. This inconsistency can cause dependency conflicts and build issues. Please align the versions to a stable release, like 3.3.0.
| <spring-boot.version>4.0.0</spring-boot.version> | |
| <spring-boot.version>3.3.0</spring-boot.version> |
| <dependency> | ||
| <groupId>com.google.adk</groupId> | ||
| <artifactId>adk-spring-boot-starter</artifactId> | ||
| <version>0.3.0</version> |
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.
The version for the adk-spring-boot-starter dependency is hardcoded to 0.3.0. The starter module in this same project has version 0.4.1-SNAPSHOT. This mismatch will likely cause build failures when building from the project root.
To ensure the sample app uses the starter built in the same project, you should align the versions. The correct version should be 0.4.1-SNAPSHOT.
| <version>0.3.0</version> | |
| <version>0.4.1-SNAPSHOT</version> |
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-dependencies</artifactId> | ||
| <version>3.3.0</version> | ||
| <type>pom</type> | ||
| <scope>import</scope> | ||
| </dependency> |
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.
A BOM (Bill of Materials) like spring-boot-dependencies should be imported in a <dependencyManagement> section, not directly in <dependencies>. This allows it to manage dependency versions without adding the BOM as a direct dependency.
Once moved, you can remove the explicit <version> tags from the other Spring Boot dependencies as they will be managed by the BOM.
| public BaseArtifactService artifactService(AdkArtifactProperties properties) { | ||
| if (properties.isGcsEnabled()) { | ||
| Storage storage = StorageOptions.getDefaultInstance().getService(); | ||
| return new GcsArtifactService(properties.getBucketName(), storage); | ||
| } | ||
| return new InMemoryArtifactService(); | ||
| } |
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.
The artifactService bean creates its own Storage instance via StorageOptions.getDefaultInstance().getService(), which ignores the googleCloudStorage bean defined above. This prevents users from customizing or mocking the Storage bean.
The artifactService bean should instead receive the Storage bean via dependency injection. Since the Storage bean is conditional, you can use an ObjectProvider to safely inject it.
public BaseArtifactService artifactService(AdkArtifactProperties properties, org.springframework.beans.factory.ObjectProvider<Storage> storageProvider) {
if (properties.isGcsEnabled()) {
return new GcsArtifactService(properties.getBucketName(), storageProvider.getObject());
}
return new InMemoryArtifactService();
}| public BaseMemoryService memoryService(AdkMemoryProperties properties) { | ||
| // VertexAiMemoryService does not exist yet, defaulting to InMemory | ||
| return new InMemoryMemoryService(); | ||
| } |
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.
If a user configures adk.memory.type=VERTEX_AI, it is silently ignored, and the InMemoryMemoryService is created. This can be misleading.
It's better to fail fast in case of an unsupported configuration. I suggest checking the property and throwing a BeanCreationException if VERTEX_AI is selected, making the failure explicit.
public BaseMemoryService memoryService(AdkMemoryProperties properties) {
if (properties.getType() == com.google.adk.autoconfigure.properties.AdkMemoryProperties.Type.VERTEX_AI) {
throw new org.springframework.beans.factory.BeanCreationException("Vertex AI memory service is not yet supported. Please use IN_MEMORY type.");
}
// Only InMemoryMemoryService is supported for now.
return new InMemoryMemoryService();
}| <parent> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-parent</artifactId> | ||
| <version>4.0.0</version> |
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.
| public Runner runner(BaseArtifactService artifactService, BaseSessionService sessionService, | ||
| BaseMemoryService memoryService) { | ||
| return new Runner( | ||
| llmAgent(), | ||
| "appName", | ||
| artifactService, | ||
| sessionService, | ||
| memoryService); | ||
| } |
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 are a couple of improvements that can be made to this bean definition to follow best practices:
-
Dependency Injection: Instead of calling the
llmAgent()method directly, it's more idiomatic in Spring to declareLlmAgentas a method parameter. This makes the dependency explicit. -
Externalize Configuration: The
appNameis hardcoded to"appName". This should be externalized to a configuration file. You can inject the application name fromapplication.yamlusing@Value("${spring.application.name}").
public Runner runner(LlmAgent llmAgent, BaseArtifactService artifactService, BaseSessionService sessionService,
BaseMemoryService memoryService, org.springframework.beans.factory.annotation.Value("${spring.application.name}") String appName) {
return new Runner(
llmAgent,
appName,
artifactService,
sessionService,
memoryService);
}4984c40 to
4f3123c
Compare
This pull requests, adds support to spring boot starter.
In addition, i added an example to show how to use the starter.
This starter integrates the Google Agent Development Kit (ADK) into Spring Boot applications.
It provides auto-configuration for :