## Summary
Removed 18 unused import statements from 17 source files across multiple
modules.
### Modules affected
- `langchain4j-core` (6 files)
- `langchain4j` (3 files)
- `langchain4j-azure-ai-search`
- `langchain4j-cassandra`
- `langchain4j-couchbase`
- `langchain4j-agentic`
- `langchain4j-agentic-mcp`
- `langchain4j-local-ai`
- `langchain4j-workers-ai`
- `document-loaders/langchain4j-document-loader-azure-storage-blob`
### Verification
Each import was verified to be unused — the imported symbol does not
appear in any non-import line of its file (including javadoc `@link` and
`@see` tags).
<!--
Thank you so much for your contribution!
Please fill in all the sections below.
Please open the PR as a draft initially. Once it is reviewed and
approved, we will ask you to add documentation and examples.
Please note that PRs with breaking changes or without tests will be
rejected.
Please note that PRs will be reviewed based on the priority of the
issues they address.
We ask for your patience. We are doing our best to review your PR as
quickly as possible.
Please refrain from pinging and asking when it will be reviewed. Thank
you for understanding!
-->
## Issue
<!-- Please specify the ID of the issue this PR is addressing. For
example: "Closes #1234" or "Fixes #1234" -->
Closes#3985
## Change
<!-- Please describe the changes you made. -->
### Summary
This PR adds a default `modelName()` method to `EmbeddingModel`, along
with overrides in most `EmbeddingModel` implementations.
### Details
- Added a default `modelName()` implementation returning `"unknown"` to
avoid breaking existing implementations.
- Added overrides in:
- `OpenAiEmbeddingModel`
- `LocalAiEmbeddingModel`
- `JlamaEmbeddingModel`
- `CohereEmbeddingModel`
- `GitHubModelsEmbeddingModel`
- `GoogleAiEmbeddingModel`
- `JinaEmbeddingModel`
- `MistralAiEmbeddingModel`
- `NomicEmbeddingModel`
- `OllamaEmbeddingModel`
- `OpenAiOfficialEmbeddingModel`
- `VertexAiEmbeddingModel`
- `VoyageAiEmbeddingModel`
- `WatsonxEmbeddingModel`
- `WorkersAiEmbeddingModel`
- Added fallback and override unit tests.
This provides a public accessor for embedding model names, as requested
in Issue #3985,
and keeps API behavior fully backward compatible.
## General checklist
<!-- Please double-check the following points and mark them like this:
[X] -->
- [X] There are no breaking changes (API, behaviour)
- [X] I have added unit and/or integration tests for my change
- [X] The tests cover both positive and negative cases
- [X] I have manually run all the unit and integration tests in the
module I have added/changed, and they are all green
- [X] I have manually run all the unit and integration tests in the
[core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core)
and
[main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j)
modules, and they are all green
<!-- Before adding documentation and example(s) (below), please wait
until the PR is reviewed and approved. -->
- [ ] I have added/updated the
[documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs)
- [ ] I have added an example in the [examples
repo](https://github.com/langchain4j/langchain4j-examples) (only for
"big" features)
- [ ] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)
## Checklist for adding new maven module
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have added my new module in the root `pom.xml` and
`langchain4j-bom/pom.xml`
## Checklist for adding new embedding store integration
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have added a `{NameOfIntegration}EmbeddingStoreIT` that extends
from either `EmbeddingStoreIT` or `EmbeddingStoreWithFilteringIT`
- [ ] I have added a `{NameOfIntegration}EmbeddingStoreRemovalIT` that
extends from `EmbeddingStoreWithRemovalIT`
## Checklist for changing existing embedding store integration
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have manually verified that the
`{NameOfIntegration}EmbeddingStore` works correctly with the data
persisted using the latest released version of LangChain4j
## Change
Part-of https://github.com/langchain4j/langchain4j/issues/3556
Continuation of https://github.com/langchain4j/langchain4j/pull/3561 as
the change is split in multiple PRs.
Support for LocalAI, Nomic, and OVH AI
## General checklist
<!-- Please double-check the following points and mark them like this:
[X] -->
- [x] There are no breaking changes
- [ ] I have added unit and/or integration tests for my change
- [ ] The tests cover both positive and negative cases
- [ ] I have manually run all the unit and integration tests in the
module I have added/changed, and they are all green
- [ ] I have manually run all the unit and integration tests in the
[core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core)
and
[main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j)
modules, and they are all green
<!-- Before adding documentation and example(s) (below), please wait
until the PR is reviewed and approved. -->
- [ ] I have added/updated the
[documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs)
- [ ] I have added an example in the [examples
repo](https://github.com/langchain4j/langchain4j-examples) (only for
"big" features)
- [ ] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)
## Checklist for adding new maven module
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have added my new module in the root `pom.xml` and
`langchain4j-bom/pom.xml`
## Checklist for adding new embedding store integration
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have added a `{NameOfIntegration}EmbeddingStoreIT` that extends
from either `EmbeddingStoreIT` or `EmbeddingStoreWithFilteringIT`
- [ ] I have added a `{NameOfIntegration}EmbeddingStoreRemovalIT` that
extends from `EmbeddingStoreWithRemovalIT`
## Checklist for changing existing embedding store integration
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have manually verified that the
`{NameOfIntegration}EmbeddingStore` works correctly with the data
persisted using the latest released version of LangChain4j
Co-authored-by: Dmytro Liubarskyi <ljubarskij@gmail.com>
<!--
Thank you so much for your contribution!
Please fill in all the sections below.
Please open the PR as a draft initially. Once it is reviewed and
approved, we will ask you to add documentation and examples.
Please note that PRs with breaking changes or without tests will be
rejected.
Please note that PRs will be reviewed based on the priority of the
issues they address.
We ask for your patience. We are doing our best to review your PR as
quickly as possible.
Please refrain from pinging and asking when it will be reviewed. Thank
you for understanding!
-->
## Issue
<!-- Please specify the ID of the issue this PR is addressing. For
example: "Closes #1234" or "Fixes #1234" -->
Closes #
## Change
<!-- Please describe the changes you made. -->
I noticed that in a lot of files there are duplicated checks for `null`
and not empty or `null` and not blank. Since there exist functions in
`Utils` class which do exactly that, I replaced all custom checks with
calls to such functions.
## General checklist
NB: I purposefully didn't commit formatting changes (i.e., `make lint`
and `make format`) because they'd change many lines in many files, much
more than what I changed in this PR, and that'd make PR difficult to
review. If you think I should do it, I'd gladly commit them.
<!-- Please double-check the following points and mark them like this:
[X] -->
- [x] There are no breaking changes
- [ ] I have added unit and/or integration tests for my change
- [ ] The tests cover both positive and negative cases
- [ ] I have manually run all the unit and integration tests in the
module I have added/changed, and they are all green
- [ ] I have manually run all the unit and integration tests in the
[core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core)
and
[main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j)
modules, and they are all green
<!-- Before adding documentation and example(s) (below), please wait
until the PR is reviewed and approved. -->
- [ ] I have added/updated the
[documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs)
- [ ] I have added an example in the [examples
repo](https://github.com/langchain4j/langchain4j-examples) (only for
"big" features)
- [ ] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)
## Checklist for adding new maven module
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have added my new module in the root `pom.xml` and
`langchain4j-bom/pom.xml`
## Checklist for adding new embedding store integration
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have added a `{NameOfIntegration}EmbeddingStoreIT` that extends
from either `EmbeddingStoreIT` or `EmbeddingStoreWithFilteringIT`
- [ ] I have added a `{NameOfIntegration}EmbeddingStoreRemovalIT` that
extends from `EmbeddingStoreWithRemovalIT`
## Checklist for changing existing embedding store integration
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have manually verified that the
`{NameOfIntegration}EmbeddingStore` works correctly with the data
persisted using the latest released version of LangChain4j
---------
Co-authored-by: Dmytro Liubarskyi <ljubarskij@gmail.com>
## Change
- Added `maven-flatten-plugin` to `langchain4j-parent` and
`langchain4j-bom`
- Removed integration-specific dependencies from `langchain4j-parent`'s
`dependencyManagement` section and moved them to the modules where these
dependencies are used
- Explicitly added missing implicit dependencies
- Removed redundant `<maven.compiler.release>` for cassandra, infinispan
and opensearch modules
- Removed redundant license declarations and outdated properties
## General checklist
- [ ] There are no breaking changes
- [ ] I have added unit and/or integration tests for my change
- [ ] The tests cover both positive and negative cases
- [x] I have manually run all the unit and integration tests in the
module I have added/changed, and they are all green
- [x] I have manually run all the unit and integration tests in the
[core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core)
and
[main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j)
modules, and they are all green
- [ ] I have added/updated the
[documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs)
- [ ] I have added an example in the [examples
repo](https://github.com/langchain4j/langchain4j-examples) (only for
"big" features)
- [ ] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)
## Change
Renamed `ChatLanguageModel` into `ChatModel` and
`StreamingChatLanguageModel` into `StreamingChatModel`.
All `chatLanguageModel(...)` methods were renamed into `chatModel(...)`,
all `streamingChatLanguageModel(...)` methods were renamed into
`streamingChatModel(...)`.
`DisabledChatLanguageModel` was renamed into `DisabledChatModel`,
`DisabledStreamingChatLanguageModel` into `DisabledStreamingChatModel`.
### OpenRewrite recipe:
```yml
---
type: specs.openrewrite.org/v1beta/recipe
name: dev.langchain4j.RenameChatModels
recipeList:
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: dev.langchain4j.model.chat.ChatLanguageModel
newFullyQualifiedTypeName: dev.langchain4j.model.chat.ChatModel
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: dev.langchain4j.model.chat.StreamingChatLanguageModel
newFullyQualifiedTypeName: dev.langchain4j.model.chat.StreamingChatModel
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: dev.langchain4j.model.chat.DisabledChatLanguageModel
newFullyQualifiedTypeName: dev.langchain4j.model.chat.DisabledChatModel
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: dev.langchain4j.model.chat.DisabledStreamingChatLanguageModel
newFullyQualifiedTypeName: dev.langchain4j.model.chat.DisabledStreamingChatModel
- org.openrewrite.java.ChangeMethodName:
methodPattern: dev.langchain4j..* chatLanguageModel(..)
newMethodName: chatModel
- org.openrewrite.java.ChangeMethodName:
methodPattern: dev.langchain4j..* streamingChatLanguageModel(..)
newMethodName: streamingChatModel
```
## General checklist
- [ ] There are no breaking changes
- [ ] I have added unit and/or integration tests for my change
- [ ] The tests cover both positive and negative cases
- [x] I have manually run all the unit and integration tests in the
module I have added/changed, and they are all green
- [x] I have manually run all the unit and integration tests in the
[core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core)
and
[main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j)
modules, and they are all green
- [x] I have added/updated the
[documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs)
- [ ] I have added an example in the [examples
repo](https://github.com/langchain4j/langchain4j-examples) (only for
"big" features)
- [x] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)
## Issue
Cleanup repeating dependencies in pom.xml. Better test assertions and
apidocs/javadoc generation.
## Change
Refactor project structure and remove unused test dependencies.
- Repeating test dependencies like `tinylog`, `awaitility` and others
were removed from various modules and consolidated in the parent module.
This reduction in clutter helps to streamline the testing process.
- A separate `kotlin` profile was created to manage Kotlin-related
configurations and dependencies.
- Upgraded versions of dependencies like `ai-mocks` and `wiremock` were
implemented. Moved to wiremock-standalone (shaded jar) to avoid
potential version conflicts with runtime classes.
- The test changes in `ChatRequestExtensionsTest.kt` partially migrated
from AssertJ to Kotest assertions.
- Updated Dokka plugin configuration
## General checklist
<!-- Please double-check the following points and mark them like this:
[X] -->
- [x] There are no breaking changes
- [ ] I have added unit and/or integration tests for my change
- [ ] The tests cover both positive and negative cases
- [x] I have manually run all the unit and integration tests in the
module I have added/changed, and they are all green
- [ ] I have manually run all the unit and integration tests in the
[core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core)
and
[main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j)
modules, and they are all green
<!-- Before adding documentation and example(s) (below), please wait
until the PR is reviewed and approved. -->
- [ ] I have added/updated the
[documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs)
- [ ] I have added an example in the [examples
repo](https://github.com/langchain4j/langchain4j-examples) (only for
"big" features)
- [ ] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)
## Checklist for adding new maven module
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have added my new module in the root `pom.xml` and
`langchain4j-bom/pom.xml`
## Checklist for adding new embedding store integration
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have added a `{NameOfIntegration}EmbeddingStoreIT` that extends
from either `EmbeddingStoreIT` or `EmbeddingStoreWithFilteringIT`
- [ ] I have added a `{NameOfIntegration}EmbeddingStoreRemovalIT` that
extends from `EmbeddingStoreWithRemovalIT`
## Checklist for changing existing embedding store integration
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have manually verified that the
`{NameOfIntegration}EmbeddingStore` works correctly with the data
persisted using the latest released version of LangChain4j
Considering what discussed
[here](https://github.com/langchain4j/langchain4j/pull/2535#issuecomment-2664972164)
I created a second proposal, much simpler and less invasive, for
exception mapping, keeping it completely separated from the retry
policy, even taking count that, differently from the retry policy, it
will be unlikely that we want to make this exception mapping mechanism
configurable and pluggable.
@dliubarskyi @edeandrea Any feedback on this is welcome.
---------
Co-authored-by: Dmytro Liubarskyi <ljubarskij@gmail.com>
## Issue
Streamline maven dependencies
Should fix [this
issue](https://github.com/langchain4j/langchain4j/actions/runs/13666001227/job/38207360909?pr=2640#step:5:16630)
```
2025/03/05 00:52:59,050 3922 [INFO ] [main] netty.implementation.NettyUtility - {"az.sdk.message":"The following Netty versions were found on the classpath and have a mismatch with the versions used by azure-core-http-netty. If your application runs without issue this message can be ignored, otherwise please align the Netty versions used in your application. For more information, see https://aka.ms/azsdk/java/dependency/troubleshoot.","azure-netty-version":"4.1.118.Final","azure-netty-native-version":"2.0.70.Final","classpath-netty-version-io.netty:netty-common":"4.1.115.Final","classpath-netty-version-io.netty:netty-handler":"4.1.110.Final","classpath-netty-version-io.netty:netty-handler-proxy":"4.1.110.Final","classpath-netty-version-io.netty:netty-buffer":"4.1.110.Final","classpath-netty-version-io.netty:netty-codec":"4.1.110.Final","classpath-netty-version-io.netty:netty-codec-http":"4.1.110.Final","classpath-netty-version-io.netty:netty-codec-http2":"4.1.110.Final","classpath-netty-version-io.netty:netty-transport-native-unix-common":"4.1.110.Final","classpath-netty-version-io.netty:netty-transport-native-epoll":"4.1.110.Final","classpath-netty-version-io.netty:netty-transport-native-kqueue":"4.1.118.Final","classpath-native-netty-version-io.netty:netty-tcnative-boringssl-static":"2.0.70.Final"}
```
## Change
This pull request includes the following changes to improve project
dependency management:
- Removed unnecessary and redundant Netty dependencies and exclusions.
- Updated and reorganized dependency versions for consistency, including
new BOM imports for Azure SDK, Netty, and Reactor.
- Eliminated AWS SDK v1 dependencies, transitioning to
`software.amazon.awssdk` BOM for better compatibility and reduced
clutter.
- Removed redundant test dependencies like `assertj-core` and `mockito`
across modules, referring to the parent POM.
- Adjusted `kotlinx-coroutines-test` to use JVM-specific artifact and
standardized dependency version variables.
- Refined POM XML formatting for consistency and clarity (`mvn
spotless:apply`)
## General checklist
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] There are no breaking changes
- [ ] I have added unit and/or integration tests for my change
- [ ] The tests cover both positive and negative cases
- [ ] I have manually run all the unit and integration tests in the
module I have added/changed, and they are all green
- [ ] I have manually run all the unit and integration tests in the
[core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core)
and
[main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j)
modules, and they are all green
<!-- Before adding documentation and example(s) (below), please wait
until the PR is reviewed and approved. -->
- [ ] I have added/updated the
[documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs)
- [ ] I have added an example in the [examples
repo](https://github.com/langchain4j/langchain4j-examples) (only for
"big" features)
- [ ] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)
## Checklist for adding new maven module
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have added my new module in the root `pom.xml` and
`langchain4j-bom/pom.xml`
## Checklist for adding new embedding store integration
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have added a `{NameOfIntegration}EmbeddingStoreIT` that extends
from either `EmbeddingStoreIT` or `EmbeddingStoreWithFilteringIT`
- [ ] I have added a `{NameOfIntegration}EmbeddingStoreRemovalIT` that
extends from `EmbeddingStoreWithRemovalIT`
## Checklist for changing existing embedding store integration
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have manually verified that the
`{NameOfIntegration}EmbeddingStore` works correctly with the data
persisted using the latest released version of LangChain4j
---------
Co-authored-by: kpavlov <{ID}+{username}@users.noreply.github.com>
Co-authored-by: Dmytro Liubarskyi <ljubarskij@gmail.com>
## Issue
Closes#2468
## Changes
1. This PR is a continuation of efforts started in
https://github.com/langchain4j/langchain4j/pull/2413
2. When using `langchain4j-open-ai`, all `OpenAi*Model`s are now using
`java.net.http.HttpClient` instead of OkHttp/Retrofit by default. You
also have an option to [customize it or plug in any other HTTP
client](https://docs.langchain4j.dev/tutorials/customizable-http-client).
3. When using `langchain4j-open-ai-spring-boot-starter`, all
`OpenAi*Model`s are now using Spring's `RestClient` instead of
OkHttp/Retrofit by default. You also have an option to [customize it or
plug in any other HTTP
client](https://docs.langchain4j.dev/tutorials/customizable-http-client).
4. `apiKey` is now optional for all `OpenAi*Model`s
5. `OpenAi*Model`s can now throw
`dev.langchain4j.exception.HttpException` instead of
`dev.ai4j.openai4j.OpenAiHttpException`
6. The default connect timeout is now 15 seconds instead of 60 for all
`OpenAi*Model`s. The default read timeout stays the same (60 seconds).
7. To continue using the "demo" key, you now need to specify the
`baseUrl` explicitly:
```java
OpenAiChatModel model = OpenAiChatModel.builder()
.baseUrl("http://langchain4j.dev/demo/openai/v1")
.apiKey("demo")
.build()
```
8. If you are using `Proxy`, now you need to configure it directly on
the HTTP client of your choice. For example, when using JDK's
`HttpClient`:
```java
HttpClient.Builder httpClientBuilder = HttpClient.newBuilder()
.proxy(ProxySelector.of(new InetSocketAddress("XXX.XXX.XXX.XXX", 1234)));
OpenAiChatModel model = OpenAiChatModel.builder()
.httpClientBuilder(JdkHttpClient.builder().httpClientBuilder(httpClientBuilder))
.apiKey(System.getenv("OPENAI_API_KEY"))
.modelName("gpt-4o-mini")
.build();
```
This also means that all `langchain4j.open-ai.*-model.proxy.*` Spring
Boot properties are not working any more.
9. `OpenAiEmbeddingModel`: removed default `modelName`
(`TEXT_EMBEDDING_ADA_002`), please set it explicitly now
10. `OpenAiImageModel`: removed `withPersisting` and `persistTo`
properties. Persisting images will not be supported any more.
11. `OpenAiLanguageModel` and `OpenAiStreamingLanguageModel`: removed
default `modelName` (`GPT_3_5_TURBO_INSTRUCT`) and `temperature`
(`0.7`), please set it explicitly now
12. `OpenAiModerationModel`: removed default `modelName`
(`TEXT_MODERATION_LATEST`), please set it explicitly now
13. All the `OpenAi*Model` constructors are now accepting a builder
object instead of all the properties
14. The `langchain4j-local-ai` module is now also using
`java.net.http.HttpClient` instead of OkHttp/Retrofit as it depends on
the `langchain4j-open-ai` module
## General checklist
- [ ] There are no breaking changes
- [X] I have added unit and/or integration tests for my change
- [ ] The tests cover both positive and negative cases
- [X] I have manually run all the unit and integration tests in the
module I have added/changed, and they are all green
- [X] I have manually run all the unit and integration tests in the
[core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core)
and
[main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j)
modules, and they are all green
- [X] I have added/updated the
[documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs)
- [x] I have added an example in the examples repo:
https://github.com/langchain4j/langchain4j-examples/pull/143
- [x] I have added/updated Spring Boot starter:
https://github.com/langchain4j/langchain4j-spring/pull/113