## Issue
Fixes#1929
## Change
- Set `tinylog.level=info` in the `surefire` and `failsafe` plugin
system properties. Remove tinilog property from `jvm.config`
- Set explicit `maven-deploy-plugin` version in the aggregator
- Remove redundant explicit dependency versions with
[openrewrite](https://docs.openrewrite.org/recipes/maven/removeredundantdependencyversions)
### Dependency Version Updates:
* Updated the `maven-deploy-plugin` version to `3.1.3` in
`langchain4j-parent/pom.xml` and `pom.xml`.
[[1]](diffhunk://#diff-db1dfc1ccffac6c8f8ae2414e6aad535940aaf08a488d30941157dc53ec573b0L469-R470)
[[2]](diffhunk://#diff-9c5fb3d1b7e3b0f54bc5c4182965c4fe1f9023d449017cece3005d3f90e8e4d8R119-R121)
* Updated the `maven-surefire-plugin` version to `3.3.1` and added a
configuration for `tinylog.level` in `langchain4j-parent/pom.xml`.
* Updated the `maven-failsafe-plugin` version to `3.3.1` and added a
configuration for `tinylog.level` in `langchain4j-parent/pom.xml`.
### Plugin Configuration Changes:
* Removed the `maven-failsafe-plugin` configuration from
`langchain4j-parent/pom.xml`.
* Removed specific version tags for dependencies in multiple `pom.xml`
files, such as `langchain4j-cassandra/pom.xml`,
`langchain4j-easy-rag/pom.xml`, and others.
[[1]](diffhunk://#diff-2a7ac31c7ee7ca4842a1502363449f7e8fdcd1bbe03f904229b80bfe5b693a83L35)
[[2]](diffhunk://#diff-12719e04c48f3263f90134aa98b8f63c2dcac5ffc06b2877baaf36e29f0ab4c1L28)
etc.)
### Other Changes:
* Added `-Djava.awt.headless=true` to `.mvn/jvm.config`.
* Added a comment for dependency versions in
`langchain4j-parent/pom.xml`.
* Removed a TODO comment in `.github/workflows/main.yaml`.
These changes aim to streamline dependency management and plugin
configurations, ensuring consistency and reducing potential conflicts.
## 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 integration tests for my change
- [ ] 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
## Issue
Closes#896Fixes#1480Fixes#1881Fixes#1858Fixes#1865
## Context
Schema for tool parameters in the low-level API (`ChatLanguageModel` +
`ToolSpecification`) is currently specified using `ToolParameters` and
`JsonSchemaProperty` classes. This API works fine for simple cases, but
it does not work well for more complicated cases (e.g., when nested
objects or collections or recursion is required).
Moreover, [Structured
Outputs](https://github.com/langchain4j/langchain4j/pull/1590) feature
is using another API and a lot of logic between tools and structured
outputs is duplicated and out of sync.
## Change
`ToolParameters` and `JsonSchemaProperty` classes are now deprecated in
favour of new `JsonSchemaElement` API (which is used for Structured
Outputs as well). Most of the logic between this 2 features is now
unified.
`JsonSchemaElement` represents a schema for a JSON element. It can be of
such types:
- `JsonArraySchema`
- `JsonBooleanSchema`
- `JsonEnumSchema`
- `JsonIntegerSchema`
- `JsonNumberSchema`
- `JsonObjectSchema`
- `JsonReferenceSchema`
- `JsonStringSchema`
All model providers that support tools (see the list below) were updated
to support the new API. Old API is still supported for backward
compatibility, but will be removed in the future.
`ToolSpecifications` helper class now generates `ToolSpecification`s
using the new API only.
Example of the new API:
```java
ToolSpecification.builder()
.name("weather")
.description("Returns the current weather in the specified city")
.parameters(JsonObjectSchema.builder()
.addStringProperty("city", s -> s.description("The name of the city, e.g., Munich"))
.addEnumProperty("units", TemperatureUnit.class)
.required("city") // the required properties should be specified explicitly
.build())
.build();
```
`JsonObjectSchema` builder has some helper methods to make it easier to
add properties (e.g., `addProperty`, `addStringProperty`,
`addIntegerProperty`, etc.), but properties can also be specified using
a map:
```java
ToolSpecification.builder()
.name("weather")
.description("Returns the current weather in the specified city")
.parameters(JsonObjectSchema.builder()
.properties(Map.of(
"city", JsonStringSchema.builder().description("The name of the city, e.g., Munich").build(),
"units", JsonEnumSchema.builder().enumValues("CELSIUS", "FAHRENHEIT").build()
))
.required("city") // the required properties should be specified explicitly
.build())
.build();
```
### Providers that support new `JsonSchemaElement` for tools
- [x] Amazon Bedrock
- [X] Anthropic
- [X] Azure OpenAI
- [X] DashScope
- [x] GitHub Models
- [X] Google AI Gemini
- [X] Google Vertex AI Gemini
- [x] Jlama
- [x] LocalAI
- [X] Mistral AI
- [X] Ollama
- [X] OpenAI
- [x] Qianfan
- [x] Zhipu AI
### Tested Providers
- [x] Amazon Bedrock
- [x] Anthropic
- [x] Azure OpenAI
- [x] DashScope
- [x] GitHub Models
- [x] Google AI Gemini
- [x] Google Vertex AI Gemini
- [x] Jlama
- [ ] LocalAI
- [x] Mistral AI
- [x] Ollama
- [x] OpenAI
- [x] Qianfan
- [x] Zhipu AI
### Additional Changes
Several bugs have been fixed along the way (see the list of Github
issues on the top).
### Breaking changes
- `ToolSpecification.parameters()` method has been renamed into
`toolParameters()`
### Potentially breaking changes
- `ToolSpecifications` helper class now generates `ToolSpecification`s
with parameters defined using the new API (`JsonObjectSchema`) instead
of the old API (`ToolParameters`).
- If `@Tool` does not have a description (`value` annotation attribute),
`ToolSpecifications` will return `ToolSpecification` with `description()
== null`
## General checklist
- [ ] There are no breaking changes (Most of the use cases should not
break)
- [x] I have added unit and integration tests for my change
- [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. -->
- [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)
- [ ] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)
## Issue
- Follows https://github.com/langchain4j/langchain4j/pull/673
## Change
Apply best practices once more, as time had passed between when #673 was
opened and today. By clearing out any recipe suggestions on the main
branch we ensure any new suggestions on PRs are limited to changed
files.
## General checklist
<!-- Please double-check the following points and mark them like this:
[X] -->
- [x] There are no breaking changes
- [x] I have added unit and integration tests for my change
- [ ] 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)
## Issue
Closes#1756Closes#1750
## Change
1. `OllamaChatModel` and `OllamaStreamingChatModel` support
`ChatListener`
2. Fix `OllamaStreamingLanguageModel` throws `EOFException` when the
response content is too long.
## General checklist
<!-- Please double-check the following points and mark them like this:
[X] -->
- [x] There are no breaking changes
- [x] I have added unit and integration tests for my change
- [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)
## Change
In addition to `application/json`, Gemini also supports `text/x.enum` as
a structured output format, which is great for classification.
This PR covers both Google Vertex AI Gemini and Google AI Gemini models.
A minor internal change to create the `GeminiService` at construction
time rather than on each request.
+ Observability (ChatLanguageModel) for Google AI Gemini
## General checklist
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] There are no breaking changes
- [X] I have added unit and integration tests for my change
- [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)
## Issue
#1506
## Change
Enabled Maven Enforcer Plugin on modules without existing version
conflicts to ensure they remain conflict-free. The Maven Enforcer Plugin
will now cause the build to fail if new conflicts are introduced
guarding against these.
## Tests
`mvn clean test` passed
## Issue
Closes#1066
## Change
These are changes for each split package (each change was done in a
separate commit, so they can be reviewed in isolation):
- `dev.langchain4j.retriever` -> Moved `EmbeddingStoreRetriever` into
`langchain4j-core` module
- `dev.langchain4j.agent.tool` -> Moved `DefaultToolExecutor` and
`ToolExecutor` into `dev.langchain4j.service.tool` package
- `dev.langchain4j.classification` -> Moved `TextClassifier` into
`langchian4j` module
- `dev.langchain4j.chain` -> Moved `Chain` into `langchain4j` module
- `dev.langchain4j.model.embedding` -> [All in-process embedding models
should have unique package
name](https://github.com/langchain4j/langchain4j-embeddings/pull/33)
- `dev.langchain4j.model.output` -> Moved `OutputParser` and all it's
implementations into `dev.langchain4j.service.output` package of the
`langchain4j` module
More details can be found
[here](https://docs.google.com/spreadsheets/d/1U7f2MIfDgWA1tydPpzWpOGTHiBjBVZjsu0uZnXBT9qE/edit?usp=sharing).
## Breaking Changes
- All in-process ONNX model classes moved into their own unique
packages:
- `AllMiniLmL6V2EmbeddingModel` moved into
`dev.langchain4j.model.embedding.onnx.allminilml6v2`
- `AllMiniLmL6V2QuantizedEmbeddingModel` moved into
`dev.langchain4j.model.embedding.onnx.allminilml6v2q`
- `OnnxEmbeddingModel` moved into `dev.langchain4j.model.embedding.onnx`
package
- etc
- `ToolExecutor` and `DefaultToolExecutor` moved into
`dev.langchain4j.service.tool` package
- Moved `OutputParser` and all it's implementations into
`dev.langchain4j.service.output` package of the `langchain4j` module
- Moved `Chain` into `langchain4j` module
- Moved `TextClassifier` into `langchian4j` module
## General checklist
- [ ] There are no breaking changes
- [ ] I have added unit and integration tests for my change
- [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)
- **Fixes #1447 Make vector embedding calculation in batch mode to speed
up the calculation of all embeddings for each label.**
- **Remove unneeded import**
- **[Gemini] Fix enum schema handling**
Gemini updates:
* update to latest Java SDK version
* #1269
* #1270
* #1208
* #1399
* #1397
* #1182
* #828
* fixes parallel function calling which wasn't working properly in the
previous release
* refactored a bit the `generate()` method to have a single entry point
and less duplication
Vertex AI embedding model:
* add new task types (question answering and fact verification)
Imagen image model:
* support more configuration parameters
* #1367
- support system instructions
- support parallel function calling
- should avoid the allocation issue faced sometimes because of the
lifecycle of the underlying VertexAI client object
- Add Gemini function calling support, in both streaming and
non-streaming models
- Upgrade the Gemini Java SDK
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- Introduced functionality for converting tool execution requests into
function calls and vice versa, enhancing interaction capabilities.
- Expanded message handling in chat models to support different message
types and tool execution results.
- Added support for generating chat messages based on tool
specifications, allowing for more dynamic conversations.
- **Enhancements**
- Improved type conversion and message construction processes for better
efficiency and reliability.
- **Tests**
- Added comprehensive test coverage for new functionalities, ensuring
robustness and reliability of conversions and message handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->