Commit Graph

63 Commits

Author SHA1 Message Date
Guillaume Laforge 9e2ee938d1
New ScoringModel for Google Cloud Vertex AI Ranking API (#1820)
## Issue
Closes #1819

## Change
Add support for the Vertex AI Ranking API, by implement a `ScoringModel`
for it.

## General checklist

- [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. -->
- [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)
2024-09-24 08:05:19 +02:00
Guillaume Laforge 34d4af44a5
Updated documentation for the Google Cloud Vertex AI embedding models and added new parameters (auto truncation and output dimensionality) (#1796)
## Change

Updated documentation for the Vertex AI embedding models, and also added
support for recent new parameters like autoTruncate and
outputDimensionality

## General checklist

- [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)
2024-09-19 09:31:29 +02:00
Guillaume Laforge cb5bdd92e7
Google AI — add support for embedding model and ability to count tokens (#1786)
## Issue
Closes #1785
Closes #1784

## Change
* `GoogleAiChatModel` now implements `TokenCountEstimator`
* new `GoogleAiEmbeddingModel` class
* new `GoogleAiGeminiTokenizer` class

## General checklist

- [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)
2024-09-18 12:41:29 +02:00
Guillaume Laforge 858cc9c19d
Google AI Gemini — support for Enum structured output (#1741)
## 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)
2024-09-13 22:44:43 +02:00
LangChain4j f6148c340e fixing failing tests 2024-09-13 09:50:22 +02:00
LangChain4j 21d35e4434 changed version to 0.35.0-SNAPSHOT 2024-09-09 10:11:09 +02:00
LangChain4j b0a8e6f45b
Release 0.34.0 (#1711) 2024-09-05 16:49:39 +02:00
LangChain4j 6e6a7ed9e7 fixing failing tests 2024-08-29 09:39:36 +02:00
LangChain4j f088f7d822 fixing failing tests 2024-08-27 09:44:04 +02:00
LangChain4j 7ba55fa197 fixing failing tests 2024-08-26 10:18:58 +02:00
LangChain4j cc7121a016 remove System.out.println() from tests 2024-08-26 09:52:40 +02:00
PrimosK e535f0153d
re #1506 Enabling Maven (version) enforcer plugin in modules with no version conflicts (#1507)
## 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
2024-08-06 15:21:25 +02:00
LangChain4j 1cccfdfa65 changed version to 0.34.0-SNAPSHOT 2024-07-26 15:12:26 +02:00
LangChain4j 822f09cb1c
Release 0.33.0 (#1514) 2024-07-25 10:12:20 +02:00
Guillaume Laforge 9d4be1591c
Update the Vertex AI and Gemini SDK libraries (#1443)
Updating the Vertex AI and Gemini SDK library versions.
2024-07-11 12:55:12 +02:00
LangChain4j fe50c88e77 changed version to 0.33.0-SNAPSHOT 2024-07-08 14:47:07 +02:00
LangChain4j c2366a226c
Release 0.32.0 (#1409) 2024-07-04 12:04:29 +02:00
Guillaume Laforge c154203bd5
Gemini updates (#1278)
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
2024-07-03 16:11:03 +02:00
ZYinNJU 982577bd4e
[Feature] Add dimension() in EmbeddingModel (#1250)
## Issue
#1080 

## Change
Adds a `dimension()` method in the `EmbeddingModel` interface that returns the dimension of the `Embedding`s produced by this `EmbeddingModel`.
If dimension is known (e.g., can be derived from the model name), it is returned. If not known, a "test" string is embedded and the embedding dimension is cached and returned.

## 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)


## Checklist for adding new model integration
<!-- Please double-check the following points and mark them like this:
[X] -->
- [ ] I have added my new module in the
[BOM](https://github.com/langchain4j/langchain4j/blob/main/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 my new module in the
[BOM](https://github.com/langchain4j/langchain4j/blob/main/langchain4j-bom/pom.xml)


## 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
2024-06-21 10:11:17 +02:00
Alex K 62fdc16185
Fix deprecated methods (#1213)
This is small refactoring

There are bunch of places where use deprecated methods. 

These changes fix this issue.

## 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
- [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)
2024-06-13 15:03:34 +02:00
LangChain4j a1b733d96d bumped version to 0.32.0-SNAPSHOT 2024-05-24 16:25:13 +02:00
LangChain4j d9cb1e9b81
Release 0.31.0 (#1151) 2024-05-23 17:40:52 +02:00
Guillaume Laforge a49ac33519
Gemini and Vertex AI update (#1141)
- support system instructions
- support parallel function calling
- should avoid the allocation issue faced sometimes because of the
lifecycle of the underlying VertexAI client object
2024-05-22 13:00:52 +02:00
LangChain4j 66c338c135 changed version to 0.31.0-SNAPSHOT 2024-04-29 11:21:00 +02:00
LangChain4j 1a340893ec
Release 0.30.0 (#945) 2024-04-16 18:21:01 +02:00
LangChain4j d1d9b45adc bumped to 0.30.0-SNAPSHOT 2024-04-08 17:36:52 +02:00
LangChain4j 45b58ac993
released 0.29.1 (#857) 2024-03-28 16:42:45 +01:00
LangChain4j d1e3cc1693
Release 0.29.0 (#830) 2024-03-26 11:54:43 +01:00
LangChain4j 91db3d354a bumped to 0.29.0-SNAPSHOT 2024-03-14 13:31:28 +01:00
LangChain4j 90fe3040b9
released 0.28.0 (#735) 2024-03-11 20:08:55 +01:00
Guillaume Laforge f565efcf0a
Ability to specify the task type for calculating embeddings (#722)
It's possible to customize different kinds of tasks for embedding:

- `RETRIEVAL_QUERY`
- `RETRIEVAL_DOCUMENT`
- `SEMANTIC_SIMILARITY`
- `CLASSIFICATION, CLUSTERING`

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **New Features**
- Introduced `TaskType` enum for specifying task types in embedding
instances, enhancing customization for retrieval, similarity,
classification, and clustering tasks.
- Added `taskType` parameter to the constructor for setting task type in
embedding instances.

- **Tests**
- Added tests for semantic similarity, text classification, and document
retrieval embeddings using different task types.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-03-11 14:05:44 +01:00
Tim te Beek 5f522e51d6
refactor: AssertJ best practices (#622)
Hi! Noticed _almost all_ tests used AssertJ, but in some cases JUnit was
still used. In addition to that some tests don't use the most expressive
assertions. Figured clean that up such that you get better assertions if
any tests were to fail. Compare for instance
```diff
-        assertThat(document.metadata().asMap().size()).isEqualTo(4);
+        assertThat(document.metadata().asMap()).hasSize(4);
```
The first one will print expected 5 to be equal to 4, whereas the second
one shows the contents of the map involved.

Being consistent with your test library also stops bad patterns from
repeating accidentally through copy-and-paste. If you want to enforce
these best practices through an automated pull request check that's also
an option. Let me know if you'd want that as well. Hope that helps!
2024-03-05 18:33:22 +01:00
Guillaume Laforge 973c68f2ba
Make the Vertex AI embedding model adapt automatically the number of batch calls to make (#626)
With this change, the batching of embedding calls will be done
automatically, adjusting the number of text segments to calculate
embeddings for, according to the max number of tokens per batch call (up
to 20k) and the max number text segments per batch call (up to 250).
There are 2 new methods in the builder to specify the max number of
tokens and max number of text segments per call, as sometimes, the
calculation of tokens seems to not be correctly returned by the
underlying model (with textembedding-gecko@001 it's fine, but
textembedding-gecko@003 seems to calculate 5-10% less tokens on a per
segment basis, than it returns for the overall call)
2024-02-22 15:15:33 +01:00
LangChain4j 197b4af9d1 bumped version to 0.28.0-SNAPSHOT 2024-02-09 15:11:52 +01:00
LangChain4j c1462c087f
release 0.27.1 (#621) 2024-02-09 15:00:42 +01:00
LangChain4j ad2fd90f32 bumped version to 0.28.0-SNAPSHOT 2024-02-09 08:12:28 +01:00
LangChain4j a22d297104
Release 0.27.0 (#615) 2024-02-09 08:00:34 +01:00
LangChain4j 13c7ee7f1c Revert ServiceHelper refactoring (#485) 2024-02-05 14:39:34 +01:00
Antonio Goncalves baac759766
Beautifying Maven output (#572)
Looking at the Maven output I thought it could benefit from a little
renaming. I just changed the `<name>` in the `pom.xml`, nothing more.
The output is like this at the moment:

![Screenshot 2024-01-30 at 16 26
53](https://github.com/langchain4j/langchain4j/assets/729277/940886d1-565e-416f-a58e-91f609fc0c00)

It could look like this if this PR is merged:

![Screenshot 2024-01-30 at 16 42
38](https://github.com/langchain4j/langchain4j/assets/729277/f8787af2-b869-4e95-90bd-72bce5622737)

Just a personal taste. Let me know if you like it or not (or want to
change it). If not, just discard it, it's fine ;o)
2024-01-30 16:54:54 +01:00
LangChain4j fca8ca48f7 bump version to 0.27.0-SNAPSHOT 2024-01-30 16:18:40 +01:00
LangChain4j 3958e01738
release 0.26.1 (#570) 2024-01-30 16:11:21 +01:00
LangChain4j 469699b944 bump version to 0.27.0-SNAPSHOT 2024-01-30 08:07:45 +01:00
LangChain4j a8ad9e48d9
Automate release (#562) 2024-01-30 07:20:20 +01:00
LangChain4j 96c57051f2 VertexAI: run ITs if environment variable is available 2024-01-26 23:40:23 +01:00
Guillaume Laforge ccee079793
Update Vertex AI embedding to allow a batch size of 250 (#556) 2024-01-26 22:55:42 +01:00
Eric Deandrea c7c4ee8eab
Allowing model builders to be extended and to be provided by `ServiceLoader`s (#531)
This is a small prototype based on discussions originating from
https://github.com/ai-for-java/openai4j/pull/13

The approach I took here is to allow for decorating the models/builders
with additional functionality without having to extend model classes or
builders. I did it for a single model in this prototype - the
`OpenAiChatModel`, but this pattern could be applied to all of the other
models across Langchain4J.

That doesn't mean you couldn't extend the model classes if you wanted to
use inheritance. I just try to avoid it and use composition instead.

I also added a test which shows how it would be used. Downstream
libraries (like Spring Boot or Quarkus) could use this mechanism to
extend/enhance with their own capabilities which aren't necessarily part
of the model.

Let me know what you think @geoand / @langchain4j !

Happy to continue conversation and see where we can bring this!
2024-01-25 09:55:02 +01:00
Guillaume Laforge f2b0c9f310
Support the Imagen image generation model from Google Cloud Vertex AI (#456) 2024-01-10 23:20:22 +01:00
LangChain4j 45a1133f85
Document VertexAI authentication (#463) 2024-01-09 19:50:21 +01:00
LangChain4j 8a7ad8621e
Fix #444: Added missing GraalVM metadata for Gson and excluded commons-logging (#482)
This PR is a fix for #444
- Missing metadata for Gson serialization was added for
`langchain4j-vertex-ai` module
- `commons-logging` was excluded from dependencies as it causes troubles
during native build
2024-01-09 19:49:09 +01:00
LangChain4j 7e5e82b7b2 updated to 0.26.0-SNAPSHOT 2023-12-22 18:08:19 +01:00