Commit Graph

48 Commits

Author SHA1 Message Date
renovate[bot] d2e7af569b
chore(deps): update actions/checkout digest to v7 (#5586)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [actions/checkout](https://redirect.github.com/actions/checkout)
([changelog](de0fac2e45..df4cb1c069))
| action | digest | `de0fac2` → `df4cb1c` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the [Dependency
Dashboard](../issues/2069) for more information.

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/langchain4j/langchain4j).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNDIuMiIsInVwZGF0ZWRJblZlciI6IjQzLjI0Mi4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Dmytro Liubarskyi <ljubarskij@gmail.com>
2026-06-26 10:25:19 +02:00
Dmytro Liubarskyi 0c605c53cc make release resumable from specific phase 2026-04-30 16:59:30 +02:00
Dmytro Liubarskyi 77001bc8ba improving release automation 2026-04-09 14:04:04 +02:00
Dmytro Liubarskyi 0413a0f603 harden GitHub workflows 2026-04-07 16:36:42 +02:00
Dmytro Liubarskyi c37fb2e0df replaced peter-evans/repository-dispatch action with manual repo dispatch 2026-04-07 15:26:43 +02:00
Dmytro Liubarskyi d971fe0df3 improving release automation 2026-03-31 20:33:01 +02:00
Dmytro Liubarskyi 918d27b691 improving release automation 2026-03-31 17:46:27 +02:00
Dmytro Liubarskyi 38a94992e2 improving release automation 2026-03-31 17:16:02 +02:00
Dmytro Liubarskyi 20d655c69a improving release automation 2026-03-31 16:54:40 +02:00
Dmytro Liubarskyi 08046014b1 improving release automation 2026-03-31 16:33:36 +02:00
Dmytro Liubarskyi edf5951122 improving release automation 2026-03-31 15:58:20 +02:00
Dmytro Liubarskyi aab8f90a85 improving release automation 2026-03-31 15:28:57 +02:00
Dmytro Liubarskyi 6e79351408
update github actions (#4719) 2026-03-16 09:57:40 +01:00
Dmytro Liubarskyi 9c56be0b45 Refactor test retries (#4690) 2026-03-13 11:15:51 +01:00
Dmytro Liubarskyi 569740e025 Refactor test retries (#4690) 2026-03-13 11:02:27 +01:00
Dmytro Liubarskyi 75275e05bf cleanup 2025-12-04 17:25:22 +01:00
Dmytro Liubarskyi c3a491e0b4
Migrate in-process embedding modules into main repo (#4179)
## Change
Migrated all modules form the
https://github.com/langchain4j/langchain4j-embeddings repository into
main (this) repository.

## General checklist
- [X] There are no breaking changes (API, behaviour)
- [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)
2025-12-04 16:03:11 +01:00
Dmytro Liubarskyi 840140150f automate updating documentation chatbot 2025-10-09 18:26:43 +02:00
Dmytro Liubarskyi 8a64a2fadc
Release automation (#3838) 2025-10-08 18:40:45 +02:00
Dmytro Liubarskyi fccc2e794c
Test against Java 25 (#3751)
## Issue
Closes https://github.com/langchain4j/langchain4j/issues/3662

## Change

## General checklist
- [X] There are no breaking changes (API, behaviour)
- [ ] 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
- [ ] 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)
2025-09-24 22:44:07 +02:00
Dmytro Liubarskyi 2fe244e40a Add azure openai audio (#2110) 2025-08-28 11:02:09 +02:00
Dmytro Liubarskyi 03930ba850
Support thinking/reasoning (#3380)
## Issue
Closes https://github.com/langchain4j/langchain4j/issues/3013
Closes https://github.com/langchain4j/langchain4j/issues/2605
Closes https://github.com/langchain4j/langchain4j/issues/2472
Closes https://github.com/langchain4j/langchain4j/issues/3361
Closes https://github.com/langchain4j/langchain4j/issues/1224

## Change
Support thinking/reasoning feature in `ChatModel`/`StreamingChatModel`
API for:
- [X] [Amazon
Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-reasoning.html)
- [X]
[Anthropic](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
- [X] [DeepSeek](https://api-docs.deepseek.com/guides/reasoning_model)
(via OpenAI module)
- [X] [Gemini](https://ai.google.dev/gemini-api/docs/thinking)
- [X] [Ollama](https://ollama.com/blog/thinking)

### API changes:
- `AiMessage`: added `thinking()` field to keep thinking/reasoning text
- `AiMessage`: added generic `attributes()` field to keep
thinking/reasoning signatures (for Bedrock, Anthropic, Gemini)
- `StreamingChatResponseHandler`: added
`onPartialThinking(PartialThinking)` callback
- `TokenStream`: added `onPartialThinking(Consumer<PartialThinking>)`
callback
- `BedrockChatModel` and `BedrockStreamingChatModel`: added
`returnThinking` and `sendThinking` parameters to the builder
- `AnthropicChatModel` and `AnthropicStreamingChatModel`: added
`returnThinking` and `sendThinking` parameters to the builder
- `GoogleAiGeminiChatModel` and `GoogleAiGeminiStreamingChatModel`:
added `returnThinking` and `sendThinking` parameters to the builder
- `OllamaChatModel` and `OllamaStreamingChatModel`: added `think` and
`returnThinking` parameters to the builder
- `OpenAiChatModel` and `OpenAiStreamingChatModel`: added
`returnThinking` parameter to the builder

## General checklist
- [X] There are no breaking changes
- [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
- [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):
https://github.com/langchain4j/langchain4j-spring/pull/133
2025-07-24 16:19:46 +02:00
renovate[bot] fa236e5dc0
Update mikepenz/action-junit-report action to v5 (#3318)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[mikepenz/action-junit-report](https://redirect.github.com/mikepenz/action-junit-report)
| action | major | `v4` -> `v5` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>mikepenz/action-junit-report
(mikepenz/action-junit-report)</summary>

###
[`v5`](https://redirect.github.com/mikepenz/action-junit-report/releases/tag/v5)

[Compare
Source](https://redirect.github.com/mikepenz/action-junit-report/compare/v4...v5)

- no changes

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/langchain4j/langchain4j).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNy4yIiwidXBkYXRlZEluVmVyIjoiNDEuMTcuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-07 00:30:08 +03:00
Dmytro Liubarskyi 35d8bee5db move spotless into a separate maven profile and workflow job 2025-05-22 14:50:01 +02:00
Dmytro Liubarskyi 3fb258b009 - Updated to the next dev version
- Release to Maven central portal instead of s01
2025-05-20 15:55:12 +02:00
Dmytro Liubarskyi 10b4a1cb5a fixing failing ITs 2025-03-17 11:56:23 +01:00
LangChain4j 88adf9f1cb
Release 1.0.0-alpha1 (#2326) 2024-12-22 17:51:40 +01:00
Maxim Katcharov 6802b50f01
Add MongoDB filtering and deletion, and various upgrades (#1869)
## Issue
Closes #1868
Closes #1532

## Change
* Implement mongodb filtering and deletion (#1868)
* Move test boilerplate into a TestHelper
* Throw an exception if no index exists once the store is created
(addresses #1532)
* Upgrade mongodb-driver-sync to 5.2.0
* Upgrade from legacy knnVector to vectorSearch
* Minor refactoring and fixes

## 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
- [ ] **No changes to core.** 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)
2024-11-27 09:52:10 +01:00
LangChain4j df12173da0 GitHub Models: fixing ITs 2024-11-18 09:36:15 +01:00
LangChain4j 13d024e968 added missing RAPID_API_KEY 2024-11-08 08:51:56 +01:00
Konstantin Pavlov 9de7a22289
Add JUnit Report action to workflows (#1977)
Add [JUnit Report](https://github.com/mikepenz/action-junit-report)

## Issue
Improve reporting in CI workflows
<img width="561" alt="image"
src="https://github.com/user-attachments/assets/190023e3-2715-4199-b86b-c94aaeab62e3">

## Change

This pull request introduces changes to multiple GitHub Actions
workflows to consistently publish test reports using the
`mikepenz/action-junit-report@v4` action. The updates ensure that test
reports are published regardless of the success or failure of the
previous steps.

Changes to GitHub Actions workflows:

*
[`.github/workflows/main.yaml`](diffhunk://#diff-71cabc4177e41ea8f15a89eb65398fa8187739f68a2762706d84885cd8b2ddc3R109-R115):
Added a step to publish test reports using
`mikepenz/action-junit-report@v4`, ensuring the step runs even if the
previous step fails.
*
[`.github/workflows/nightly.yaml`](diffhunk://#diff-e79198339eb3fcc6974b6912e52526068eab3b7952ed67d03276479a235eb58eL94-R105):
Updated the condition for uploading test reports and added a step to
publish test reports using `mikepenz/action-junit-report@v4`.
*
[`.github/workflows/release.yaml`](diffhunk://#diff-e426ed45842837026e10e66af23d9c7077e89eacbe6958ce7cb991130ad05adaR83-R89):
Added a step to publish test reports using
`mikepenz/action-junit-report@v4`, ensuring the step runs even if the
previous step fails.
*
[`.github/workflows/release_core_and_parent.yaml`](diffhunk://#diff-29983aaefd1016684ce940117feefedb37edefca433dde927389805f65cdfee6R36-R42):
Added a step to publish test reports using
`mikepenz/action-junit-report@v4`, ensuring the step runs even if the
previous step fails.
*
[`.github/workflows/snapshot_release.yaml`](diffhunk://#diff-cf84df4f6da634dce2ec7dc5dfc37ddc1f47181a6dd4f2e1d81df7537356dcd8R39-R45):
Added a step to publish test reports using
`mikepenz/action-junit-report@v4`, ensuring the step runs even if the
previous step fails.
*
[`.github/workflows/snapshot_release_core_and_parent.yaml`](diffhunk://#diff-178e48d6db6047dafaad65fe4eb44b9bdbe8a90f03397c2c653de9fa07e830dfR41-R47):
Added a step to publish test reports using
`mikepenz/action-junit-report@v4`, ensuring the step runs even if the
previous step fails.

## 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)
2024-10-24 10:10:25 +02:00
Konstantin Pavlov aa7866fc6e
Upgrade to JDK 17, always run unit tests on CI (#1913)
## Issue
Fixes #1909, Fixes #1899, Closes #1652

This pull request includes several updates to the GitHub Actions
workflows and Maven configuration files to modernize the Java version
and improve the build process. The most important changes include
upgrading the Java version, modifying the Maven build commands, and
updating dependencies.

## Change

- ⬆️ Min JDK version has been upgraded to 17
- 🗿 Hardening: run `mvn process-test-classes javadocs:aggregate` on
**ALL** modules to verify that code compiles before running integraiton
tests
- 💄 Reformat maven commands to multiline to fit on a screen
- Rename GoogleAiGeminiTokenizerTest to GoogleAiGeminiTokenizerIT
- Upgrade graalvm and Oracle image
- Run tests on every build, run integraiton tests only on
langchain4j/langchain4j repo

----

This pull request includes several updates to the GitHub workflows and
various project files to modernize the build environment and improve
testing processes. The most important changes include updating the Java
Development Kit (JDK) versions, modifying Maven commands for better
readability and functionality, and renaming test classes for
consistency.

### Updates to GitHub Workflows:

* **JDK Version Updates:**
*
[`.github/workflows/javadoc.yaml`](diffhunk://#diff-40d3687e6b489280a4b84d8a8ee6ceaee3d7ca3a8e161df603d1046daded3db3L30-R39):
Updated from JDK 8 to JDK 17 and changed the distribution to 'temurin'.
*
[`.github/workflows/main.yaml`](diffhunk://#diff-71cabc4177e41ea8f15a89eb65398fa8187739f68a2762706d84885cd8b2ddc3L31-R36):
Removed JDK 8 and 11, now only using JDK 17 and 21.
[[1]](diffhunk://#diff-71cabc4177e41ea8f15a89eb65398fa8187739f68a2762706d84885cd8b2ddc3L31-R36)
[[2]](diffhunk://#diff-71cabc4177e41ea8f15a89eb65398fa8187739f68a2762706d84885cd8b2ddc3L59-R68)
*
[`.github/workflows/nightly.yaml`](diffhunk://#diff-e79198339eb3fcc6974b6912e52526068eab3b7952ed67d03276479a235eb58eL13-L18):
Removed JDK 8 and 11, now only using JDK 17 and 21.
[[1]](diffhunk://#diff-e79198339eb3fcc6974b6912e52526068eab3b7952ed67d03276479a235eb58eL13-L18)
[[2]](diffhunk://#diff-e79198339eb3fcc6974b6912e52526068eab3b7952ed67d03276479a235eb58eL43-R46)

* **Maven Command Enhancements:**
*
[`.github/workflows/receive-pr.yml`](diffhunk://#diff-3f8fc2f08505435fdc4f66740e23234e3fee099725c4d72b02a67a0fc5db4c41L45-R47):
Reformatted Maven command for better readability.
*
[`.github/workflows/release.yaml`](diffhunk://#diff-e426ed45842837026e10e66af23d9c7077e89eacbe6958ce7cb991130ad05adaL38-R44):
Reformatted Maven command for better readability and maintainability.
*
[`.github/workflows/release_core_and_parent.yaml`](diffhunk://#diff-29983aaefd1016684ce940117feefedb37edefca433dde927389805f65cdfee6L27-R31):
Reformatted Maven command for better readability.
*
[`.github/workflows/snapshot_release.yaml`](diffhunk://#diff-cf84df4f6da634dce2ec7dc5dfc37ddc1f47181a6dd4f2e1d81df7537356dcd8L34-R38):
Reformatted Maven command for better readability.
*
[`.github/workflows/snapshot_release_core_and_parent.yaml`](diffhunk://#diff-178e48d6db6047dafaad65fe4eb44b9bdbe8a90f03397c2c653de9fa07e830dfL34-R40):
Reformatted Maven command for better readability.

### Project File Updates:

* **Dependency and Property Updates:**
*
[`code-execution-engines/langchain4j-code-execution-engine-graalvm-polyglot/pom.xml`](diffhunk://#diff-336b440bd3a43cdb2df4f9c6ee2a0cb257703526e8700f607cc67ec7ec73f0eaL19-R20):
Updated GraalVM version from 23.1.1 to 24.1.0.
*
[`langchain4j-parent/pom.xml`](diffhunk://#diff-db1dfc1ccffac6c8f8ae2414e6aad535940aaf08a488d30941157dc53ec573b0L17-R18):
Updated Maven compiler plugin version to 3.13.0 and removed Java 11+
profile.
[[1]](diffhunk://#diff-db1dfc1ccffac6c8f8ae2414e6aad535940aaf08a488d30941157dc53ec573b0L17-R18)
[[2]](diffhunk://#diff-db1dfc1ccffac6c8f8ae2414e6aad535940aaf08a488d30941157dc53ec573b0L458-R458)
[[3]](diffhunk://#diff-db1dfc1ccffac6c8f8ae2414e6aad535940aaf08a488d30941157dc53ec573b0L616-L624)

* **Test Class Renaming:**
*
[`langchain4j-google-ai-gemini/src/test/java/dev/langchain4j/model/googleai/GoogleAiGeminiTokenizerIT.java`](diffhunk://#diff-76accbd5060e23e5e16220546f59fa5074b91b36c2d42ece8109fa800c9a2f3dL14-R14):
Renamed from `GoogleAiGeminiTokenizerTest.java` to follow integration
test naming conventions.

* **Miscellaneous Fixes:**
*
[`langchain4j-oracle/src/test/java/dev/langchain4j/store/embedding/oracle/CommonTestOperations.java`](diffhunk://#diff-4a9654970655bfc6505ad1b1d334df5751c823922bdca974630c3641e29cf951L24):
Added a constant for the Oracle image name and updated container startup
and connect timeouts.
[[1]](diffhunk://#diff-4a9654970655bfc6505ad1b1d334df5751c823922bdca974630c3641e29cf951L24)
[[2]](diffhunk://#diff-4a9654970655bfc6505ad1b1d334df5751c823922bdca974630c3641e29cf951R63-R64)
[[3]](diffhunk://#diff-4a9654970655bfc6505ad1b1d334df5751c823922bdca974630c3641e29cf951L72-R75)
*
[`langchain4j-qdrant/src/test/java/dev/langchain4j/store/embedding/qdrant/QdrantFilterConverterTest.java`](diffhunk://#diff-2006ea9aece1dcbcf4d519a514526e8314ecebf5575d9197fc5385c99e2c3119L68-R68):
Corrected assertions for better readability.
[[1]](diffhunk://#diff-2006ea9aece1dcbcf4d519a514526e8314ecebf5575d9197fc5385c99e2c3119L68-R68)
[[2]](diffhunk://#diff-2006ea9aece1dcbcf4d519a514526e8314ecebf5575d9197fc5385c99e2c3119L78-R78)
[[3]](diffhunk://#diff-2006ea9aece1dcbcf4d519a514526e8314ecebf5575d9197fc5385c99e2c3119L88-R88)
[[4]](diffhunk://#diff-2006ea9aece1dcbcf4d519a514526e8314ecebf5575d9197fc5385c99e2c3119L98-R98)

----

## 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
- [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)
2024-10-15 10:30:50 +02:00
LangChain4j 0bc88cc65b Added GCP_PROJECT_NUM env variable 2024-10-08 09:54:42 +02:00
LangChain4j 3579664e08 Support for GitHub Models using the Azure AI Inference API (#1807) 2024-09-24 19:31:53 +02:00
LangChain4j 2929912448 Integration with Voyage (#1816) 2024-09-24 09:07:34 +02:00
LangChain4j afd2a5414a #1363 — Add support for the Gemini AI model (#1695) 2024-09-04 16:07:13 +02:00
Stéphane Philippart 03cd29a933
feat: Enable batch embedding server side (#1643)
## Change
As agreed I update the code to use the server side batch processing for
OVHcloud AI embedding models.


## 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. -->
- [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) (only for
"big" features)
- [X] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)
2024-08-27 10:06:53 +02:00
LangChain4j 2d8cfe5032
Nightly build (#1162) 2024-06-03 17:08:19 +02:00
LangChain4j d9cb1e9b81
Release 0.31.0 (#1151) 2024-05-23 17:40:52 +02:00
LangChain4j d1e3cc1693
Release 0.29.0 (#830) 2024-03-26 11:54:43 +01:00
LangChain4j d6b5a79656 release parent separately 2024-03-25 17:53:22 +01:00
LangChain4j 0eb9269866 added separate release workflow for core 2024-03-25 17:26:51 +01:00
LangChain4j e0b7a2816b added Milvus env var 2024-03-22 09:55:28 +01:00
LangChain4j a172a6134d Azure AI Search: added env vars 2024-03-19 16:23:33 +01:00
LangChain4j 90fe3040b9
released 0.28.0 (#735) 2024-03-11 20:08:55 +01:00
LangChain4j 1acb7a607f
EmbeddingStore (Metadata) Filter API (#610)
## New EmbeddingStore (metadata) `Filter` API
Many embedding stores, such as
[Pinecone](https://docs.pinecone.io/docs/metadata-filtering) and
[Milvus](https://milvus.io/docs/boolean.md) support strict filtering
(think of an SQL "WHERE" clause) during similarity search.
So, if one has an embedding store with movies, for example, one could
search not only for the most semantically similar movies to the given
user query but also apply strict filtering by metadata fields like year,
genre, rating, etc. In this case, the similarity search will be
performed only on those movies that match the filter expression.

Since LangChain4j supports (and abstracts away) many embedding stores,
there needs to be an embedding-store-agnostic way for users to define
the filter expression.

This PR introduces a `Filter` interface, which can represent both simple
(e.g., `type = "documentation"`) and composite (e.g., `type in
("documentation", "tutorial") AND year > 2020`) filter expressions in an
embedding-store-agnostic manner.

`Filter` currently supports the following operations:

- Comparison:
  - `IsEqualTo`
  - `IsNotEqualTo`
  - `IsGreaterThan`
  - `IsGreaterThanOrEqualTo`
  - `IsLessThan`
  - `IsLessThanOrEqualTo`
  - `IsIn`
  - `IsNotIn`

- Logical:
  - `And`
  - `Not`
  - `Or`

These operations are supported by most embedding stores and serve as a
good starting point. However, the list of operations will expand over
time to include other operations (e.g., `Contains`) supported by
embedding stores.

Currently, the DSL looks like this:
```java
Filter onlyDocs = metadataKey("type").isEqualTo("documentation");

Filter docsAndTutorialsAfter2020 = metadataKey("type").isIn("documentation", "tutorial").and(metadataKey("year").isGreaterThan(2020));
// or
Filter docsAndTutorialsAfter2020 = and(
    metadataKey("type").isIn("documentation", "tutorial"),
    metadataKey("year").isGreaterThan(2020)
);
```

## Filter expression as a `String`
Filter expression can also be specified as a `String`. This might be
necessary, for example, if the filter expression is generated
dynamically by the application or by the LLM (as in [self
querying](https://python.langchain.com/docs/modules/data_connection/retrievers/self_query/)).

This PR introduces a `FilterParser` interface with a simple `Filter
parse(String)` API, allowing for future support of multiple syntaxes (if
this will be required).

For the out-of-the-box filter syntax, ANSI SQL's `WHERE` clause is
proposed as a suitable candidate for several reasons:
- SQL is well-known among Java developers
- There is extensive tooling available for SQL (e.g., parsers)
- LLMs are pretty good at generating valid SQL, as there are tons of SQL
queries on the internet, which are included in the LLM training
datasets. There are also specialized LLMs that are trained for
text-to-SQL task, such as [SQLCoder](https://huggingface.co/defog).

The downside is that SQL's `WHERE` clause might not support all
operations and data types that could be supported in the future by
various embedding stores. In such case, we could extend it to a superset
of ANSI SQL `WHERE` syntax and/or provide an option to express filters
in the native syntax of the store.

An out-of-the-box implementation of the SQL `FilterParser` is provided
as a `SqlFilterParser` in a separate module
`langchain4j-embedding-store-filter-parser-sql`, using
[JSqlParser](https://github.com/JSQLParser/JSqlParser) under the hood.

`SqlFilterParser` can parse SQL "SELECT" (or just "WHERE" clause)
statement into a `Filter` object:
- `SELECT * FROM fake_table WHERE userId = '123-456'` ->
`metadataKey("userId").isEqualTo("123-456")`
- `userId = '123-456'`  ->  `metadataKey("userId").isEqualTo("123-456")`

It can also resolve `CURDATE()` and
`CURRENT_DATE`/`CURRENT_TIME`/`CURRENT_TIMESTAMP`:
`SELECT * FROM fake_table WHERE year = EXTRACT(YEAR FROM CURRENT_DATE`
-> `metadataKey("year").isEqualTo(LocalDate.now().getYear())`

## Changes in `Metadata` API
Until now, `Metadata` supported only `String` values. This PR expands
the list of supported value types to `Integer`, `Long`, `Float` and
`Double`. In the future, more types may be added (if needed).
The method `String get(String key)` will be deprecated later in favor
of:
- `String getString(String key)`
- `Integer getInteger(String key)`
- `Long getLong(String key)`
- etc

New overloaded `put(key, value)` methods are introduced to support more
value types:
- `put(String key, int value)`
- `put(String key, long value)`
- etc

## Changes in `EmbeddingStore` API
New method `search` is added that will become the main entry point for
search in the future. All `findRelevant` methods will be deprecated
later.
New `search` method accepts `EmbeddingSearchRequest` and returns
`EmbeddingSearchResult`.
`EmbeddingSearchRequest` contains all search criteria (e.g.
`maxResults`, `minScore`), including new `Filter`.
`EmbeddingSearchResult` contains a list of `EmbeddingMatch`.
```java
EmbeddingSearchResult search(EmbeddingSearchRequest request);
```

## Changes in `EmbeddingStoreContentRetriever` API
`EmbeddingStoreContentRetriever` can now be configured with a static
`filter` as well as dynamic `dynamicMaxResults`, `dynamicMinScore` and
`dynamicFilter` in the builder:
```java
ContentRetriever contentRetriever = EmbeddingStoreContentRetriever.builder()
                .embeddingStore(embeddingStore)
                .embeddingModel(embeddingModel)
                ...
                .maxResults(3)
                // or
                .dynamicMaxResults(query -> 3) // You can define maxResults dynamically. The value could, for example, depend on the query or the user associated with the query.
                ...
                .minScore(0.3)
                // or
                .dynamicMinScore(query -> 0.3)
                ...
                .filter(metadataKey("userId").isEqualTo("123-456")) // Assuming your TextSegments contain Metadata with key "userId"
                // or
                .dynamicFilter(query -> metadataKey("userId").isEqualTo(query.metadata().chatMemoryId().toString()))
                ...
                .build();
```
So now you can define `maxResults`, `minScore` and `filter` both
statically and dynamically (they can depend on the query, user, etc.).
These values will be propagated to the underlying `EmbeddingStore`.

##
["Self-querying"](https://python.langchain.com/docs/modules/data_connection/retrievers/self_query/)
This PR also introduces `LanguageModelSqlFilterBuilder` in
`langchain4j-embedding-store-filter-parser-sql` module which can be used
with `EmbeddingStoreContentRetriever`'s `dynamicFilter` to automatically
build a `Filter` object from the `Query` using language model and
`SqlFilterParser`.

For example:
```java
TextSegment groundhogDay = TextSegment.from("Groundhog Day", new Metadata().put("genre", "comedy").put("year", 1993));
TextSegment forrestGump = TextSegment.from("Forrest Gump", new Metadata().put("genre", "drama").put("year", 1994));
TextSegment dieHard = TextSegment.from("Die Hard", new Metadata().put("genre", "action").put("year", 1998));

// describe metadata keys as if they were columns in the SQL table
TableDefinition tableDefinition = TableDefinition.builder()
                .name("movies")
                .addColumn("genre", "VARCHAR", "one of [comedy, drama, action]")
                .addColumn("year", "INT")
                .build();

LanguageModelSqlFilterBuilder sqlFilterBuilder = new LanguageModelSqlFilterBuilder(model, tableDefinition);

ContentRetriever contentRetriever = EmbeddingStoreContentRetriever.builder()
                .embeddingStore(embeddingStore)
                .embeddingModel(embeddingModel)
                .dynamicFilter(sqlFilterBuilder::build)
                .build();

String answer = assistant.answer("Recommend me a good drama from 90s"); // Forrest Gump
```

## Which embedding store integrations will support `Filter`?
In the long run, all (provided the embedding store itself supports it).
In the first iteration, I aim to add support to just a few:
- `InMemoryEmbeddingStore`
- Elasticsearch
- Milvus

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

## Summary by CodeRabbit

- **New Features**
- Introduced filters for checking key's value existence in a collection
for improved data handling.
- **Enhancements**
- Updated `InMemoryEmbeddingStoreTest` to extend a different class for
improved testing coverage and added a new test method.
- **Refactor**
- Made minor formatting adjustments in the assertion block for better
readability.
- **Documentation**
  - Updated class hierarchy information for clarity.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-03-08 17:06:58 +01:00
LangChain4j 9d4234342e
Fixed snapshot release (#650) 2024-02-21 07:56:24 +01:00
LangChain4j a22d297104
Release 0.27.0 (#615) 2024-02-09 08:00:34 +01:00