-
Notifications
You must be signed in to change notification settings - Fork 240
Refactor spring boot starters #886
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
Conversation
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
- Introduced a `String.masked` extension to obfuscate sensitive string parts. Added test coverage for various input scenarios, including custom mask characters and edge cases.
- Removed `KoogAutoConfiguration` and related legacy configuration files. - Introduced modular `LLM` provider-specific auto-configuration classes (e.g., `OpenAILLMAutoConfiguration`). - Updated test setup to align with the new modular configuration. - Enhanced property validation with `enabled` flag support for finer-grained control.
- Updated `KoogAutoConfigurationTest` to include scenarios where providers are explicitly disabled. - Refactored parameterized tests to use `textBlock = PROVIDERS` with `@CsvSource`. - Adjusted `ApplicationContextRunner` configuration logic for clean test scenarios.
- Introduced `ignoreUnknownFields` to all `ConfigurationProperties` to improve flexibility with unmapped fields. - Expanded property documentation for all LLM clients (e.g., OpenAI, Google, Anthropic) to include detailed descriptions, usage examples, and retry behavior. - Improved autowiring safety with `@ConditionalOnBean` for LLM-specific executors.
- Updated `spring-boot.md` to detail `enabled` flags and their default behavior for LLM providers. - Improved clarity by reformatting the supported provider list. - Added explanations for default base URLs and explicit activation for non-API-key providers (e.g., Ollama).
Qodana for JVM832 new problems were found
@@ Code coverage @@
+ 70% total lines covered
12529 lines analyzed, 8785 lines covered
# Calculated according to the filters of your coverage tool ☁️ View the detailed Qodana report Contact Qodana teamContact us at qodana-support@jetbrains.com
|
devcrocod
approved these changes
Sep 30, 2025
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.
lgtm 👍
there are a few minor things
...ot-starter/src/main/kotlin/ai/koog/spring/prompt/executor/clients/KoogLlmClientProperties.kt
Show resolved
Hide resolved
.../src/main/kotlin/ai/koog/spring/prompt/executor/clients/anthropic/AnthropicKoogProperties.kt
Show resolved
Hide resolved
.../src/main/kotlin/ai/koog/spring/prompt/executor/clients/openai/OpenAILLMAutoConfiguration.kt
Outdated
Show resolved
Hide resolved
.../src/main/kotlin/ai/koog/spring/prompt/executor/clients/openai/OpenAILLMAutoConfiguration.kt
Outdated
Show resolved
Hide resolved
...ot-starter/src/main/kotlin/ai/koog/spring/prompt/executor/clients/KoogLlmClientProperties.kt
Show resolved
Hide resolved
- Replaced `@param` annotations with `@property` for consistency in property definitions across all LLM client classes. - Updated inline documentation in properties and methods for clarity. - Grouped multi-line `withPropertyValues` calls in tests for conciseness and improved readability.
Ololoshechkin
pushed a commit
that referenced
this pull request
Oct 2, 2025
Refactor LLM client auto-configuration structure - Removed `KoogAutoConfiguration` and related legacy configuration files. - Introduced modular `LLM` provider-specific auto-configuration classes (e.g., `OpenAILLMAutoConfiguration`). - Updated test setup to align with the new modular configuration. - Enhanced property validation with `enabled` flag support for finer-grained control. - Introduced a `String.masked` extension to obfuscate sensitive string parts. Added test coverage for various input scenarios, including custom mask characters and edge cases. - Updated `KoogAutoConfigurationTest` to include scenarios where providers are explicitly disabled. - Refactored parameterized tests to use `textBlock = PROVIDERS` with `@CsvSource`. - Adjusted `ApplicationContextRunner` configuration logic for clean test scenarios. - Introduced `ignoreUnknownFields` to all `ConfigurationProperties` to improve flexibility with unmapped fields. - Expanded property documentation for all LLM clients (e.g., OpenAI, Google, Anthropic) to include detailed descriptions, usage examples, and retry behavior. - Improved autowiring safety with `@ConditionalOnBean` for LLM-specific executors. - Updated `spring-boot.md` to detail `enabled` flags and their default behavior for LLM providers. - Improved clarity by reformatting the supported provider list. - Added explanations for default base URLs and explicit activation for non-API-key providers (e.g., Ollama). A blog post about writing Spring Boot starters is [here](https://kpavlov.me/blog/spring-boot-starters) **NB! Tests need a split and some love, but this PR is already big enough. I will refactor them separately.** ## Motivation and Context - The Spring Boot configuration in general is not very Spring Boot idiomatic - The current Spring Boot starter does not expose LLM Clients. In order to get the LLM client in the application, developers have to use reflection to a get a field from the executor 🤯 - All configuration is encapsulated in one file, which makes extensibility difficult (SRP is violated). - Defaults are hardcoded in classes instead of being provided in the resources - Ollama is enabled by the presence of the base URL, which is interesting. - There is no explicit way to disable an LLM provider: no `enabled=true` property ## Breaking Changes - AutoConfiguration classes moved to their respective packages - Ollama provider needs `ai.koog.ollama.enabled=true` to be set explicitly in order to activate. --- #### Type of the changes - [ ] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [x] Documentation update - [x] Tests improvement - [x] Refactoring #### Checklist - [x] The pull request has a description of the proposed change - [ ] I read the [Contributing Guidelines](https://github.com/JetBrains/koog/blob/main/CONTRIBUTING.md) before opening the pull request - [x] The pull request uses **`develop`** as the base branch - [ ] Tests for the changes have been added - [ ] All new and existing tests passed ##### Additional steps for pull requests adding a new feature - [ ] An issue describing the proposed change exists - [ ] The pull request includes a link to the issue - [ ] The change was discussed and approved in the issue - [x] Docs have been added / updated (cherry picked from commit 5a05fed)
karloti
pushed a commit
to karloti/koog
that referenced
this pull request
Oct 21, 2025
Refactor LLM client auto-configuration structure - Removed `KoogAutoConfiguration` and related legacy configuration files. - Introduced modular `LLM` provider-specific auto-configuration classes (e.g., `OpenAILLMAutoConfiguration`). - Updated test setup to align with the new modular configuration. - Enhanced property validation with `enabled` flag support for finer-grained control. - Introduced a `String.masked` extension to obfuscate sensitive string parts. Added test coverage for various input scenarios, including custom mask characters and edge cases. - Updated `KoogAutoConfigurationTest` to include scenarios where providers are explicitly disabled. - Refactored parameterized tests to use `textBlock = PROVIDERS` with `@CsvSource`. - Adjusted `ApplicationContextRunner` configuration logic for clean test scenarios. - Introduced `ignoreUnknownFields` to all `ConfigurationProperties` to improve flexibility with unmapped fields. - Expanded property documentation for all LLM clients (e.g., OpenAI, Google, Anthropic) to include detailed descriptions, usage examples, and retry behavior. - Improved autowiring safety with `@ConditionalOnBean` for LLM-specific executors. - Updated `spring-boot.md` to detail `enabled` flags and their default behavior for LLM providers. - Improved clarity by reformatting the supported provider list. - Added explanations for default base URLs and explicit activation for non-API-key providers (e.g., Ollama). A blog post about writing Spring Boot starters is [here](https://kpavlov.me/blog/spring-boot-starters) **NB! Tests need a split and some love, but this PR is already big enough. I will refactor them separately.** ## Motivation and Context - The Spring Boot configuration in general is not very Spring Boot idiomatic - The current Spring Boot starter does not expose LLM Clients. In order to get the LLM client in the application, developers have to use reflection to a get a field from the executor 🤯 - All configuration is encapsulated in one file, which makes extensibility difficult (SRP is violated). - Defaults are hardcoded in classes instead of being provided in the resources - Ollama is enabled by the presence of the base URL, which is interesting. - There is no explicit way to disable an LLM provider: no `enabled=true` property ## Breaking Changes - AutoConfiguration classes moved to their respective packages - Ollama provider needs `ai.koog.ollama.enabled=true` to be set explicitly in order to activate. --- #### Type of the changes - [ ] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [x] Documentation update - [x] Tests improvement - [x] Refactoring #### Checklist - [x] The pull request has a description of the proposed change - [ ] I read the [Contributing Guidelines](https://github.com/JetBrains/koog/blob/main/CONTRIBUTING.md) before opening the pull request - [x] The pull request uses **`develop`** as the base branch - [ ] Tests for the changes have been added - [ ] All new and existing tests passed ##### Additional steps for pull requests adding a new feature - [ ] An issue describing the proposed change exists - [ ] The pull request includes a link to the issue - [ ] The change was discussed and approved in the issue - [x] Docs have been added / updated (cherry picked from commit 5a05fed)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
documentation
Improvements or additions to documentation
enhancement
New feature or request
refactoring
Code improvements that enhance structure, readability, and quality without changing functionality
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.
Refactor LLM client auto-configuration structure
KoogAutoConfiguration
and related legacy configuration files.LLM
provider-specific auto-configuration classes (e.g.,OpenAILLMAutoConfiguration
).enabled
flag support for finer-grained control.String.masked
extension to obfuscate sensitive string parts. Added test coverage for various input scenarios, including custom mask characters and edge cases.KoogAutoConfigurationTest
to include scenarios where providers are explicitly disabled.textBlock = PROVIDERS
with@CsvSource
.ApplicationContextRunner
configuration logic for clean test scenarios.ignoreUnknownFields
to allConfigurationProperties
to improve flexibility with unmapped fields.@ConditionalOnBean
for LLM-specific executors.spring-boot.md
to detailenabled
flags and their default behavior for LLM providers.A blog post about writing Spring Boot starters is here
NB! Tests need a split and some love, but this PR is already big enough. I will refactor them separately.
Motivation and Context
enabled=true
propertyBreaking Changes
ai.koog.ollama.enabled=true
to be set explicitly in order to activate.Type of the changes
Checklist
develop
as the base branchAdditional steps for pull requests adding a new feature