## Issue
This PR partially fixes#1454
## Context
`DefaultRetrievalAugmentor` currently uses an `Executor` to parallelize
the processing (consider multiple `Query`s and/or multiple
`ContentRetriever`s).
The default `Executor` instance caches (non-daemon) threads for 60
seconds, so when the application is ready to shut down, it can hang for
another 60 seconds before it can actually exit.
For the majority of the use cases (single `Query` and single
`ContentRetriever`) there is no need to use an `Executor`, processing
can be done in the same thread without an `Executor`, thus there will be
no hanging.
For the rest of the use cases we can use the `Executor` to parallelize
the processing as before. But for default `Executor`, reduce the time
from 60 to 1 second, which makes "handing time" acceptable.
In any case, the user can always provide a custom instance of an
`Executor` and manage it externally.
## Change
- Changes in `DefaultRetrievalAugmentor`:
- When there is only a single `Query` and a single `ContentRetriever`
(majority of use cases), processing is done in the same thread
(`Executor` is not used at all)
- Otherwise, the `Executor`is used to parallelize query routing and
content retrieval. The default `Executor` now caches threads for 1
second (instead of 60 seconds)
- Added javadoc and documentation
- Added documentation for
https://github.com/langchain4j/langchain4j/issues/1454
## 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
- [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)
- [ ] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)
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
## Issue
[https://github.com/langchain4j/langchain4j/issues/1219](https://github.com/langchain4j/langchain4j/issues/1219)
## Change
Added the `docusaurus-lunr-search` plugin.
It may seem that for search feature we would need a server. But nothing
stops us from passing that logic to the client)
So, if the index for pages is not too big, we will delegate the search
functionality to client. That's what this plugin does (I think).
It works with `npm run serve`, but I couldn't test it with just opening
the `index.html` file.
Oh, I'm sorry, my editor autoformatted the file)
## 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
[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 manually run all the unit and integration tests in the
module I have added/changed, 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)
## Issue
Implements https://github.com/langchain4j/langchain4j/issues/141
## Change
This PR introduces an option to configure tools programmatically when using AI Services.
Tools can now be provided as a map of `ToolSpecification` to
`ToolExecutor` pairs:
```java
ToolSpecification toolSpecification = ToolSpecification.builder()
.name("get_booking_details")
.description("Returns booking details")
.addParameter("bookingNumber", type("string"))
.build();
ToolExecutor toolExecutor = (toolExecutionRequest, memoryId) -> {
Map<String, Object> arguments = toMap(toolExecutionRequest.arguments());
assertThat(arguments).containsExactly(entry("bookingNumber", "123-456"));
return "Booking period: from 1 July 2027 to 10 July 2027";
};
Assistant assistant = AiServices.builder(Assistant.class)
.chatLanguageModel(chatLanguageModel)
.tools(singletonMap(toolSpecification, toolExecutor))
.build();
String answer = assistant.chat("When does my booking 123-456 starts?");
assertThat(answer).contains("2027");
```
This approach offers a lot of flexibility, as tools can now be loaded
from external sources such as databases and configuration files.
Tool names, descriptions, parameter names, and descriptions can all be
dynamically configured via `ToolSpecification`.
For instance, one of the LC4j users wants to store tools (where each
tool is an API endpoint) in a configuration file like this:
```json
[
{
"name": "get_order_details",
"url": "https://url.com",
"method": "POST",
"description": "Get additional order details by providing an order ID"
"parameters": {
"order": {
"type": "string",
"description": "an order ID, for example: 300"
}
},
"examples": [
"Get additional details for order 300",
"Show more information for order 301",
"Show request delivery date for order 201"
]
}
]
```
With this PR, this can be implemented like so:
```java
List<ApiTool> apiTools = loadFromFile("tools.json");
Map<ToolSpecification, ToolExecutor> tools = new HashMap<>();
for (ApiTool apiTool : apiTools) {
if ("GET".equals(apiTool.getMethod())) {
ToolSpecification toolSpecification = ToolSpecification.builder()
.name(apiTool.getName())
.description(apiTool.getDescription())
.build();
ToolExecutor toolExecutor = (toolExecutionRequest, memoryId) -> httpClient.get(apiTool.getUrl());
tools.put(toolSpecification, toolExecutor);
} else if ("POST".equals(apiTool.getMethod())) {
ToolSpecification.Builder toolSpecificationBuilder = ToolSpecification.builder()
.name(apiTool.getName())
.description(apiTool.getDescription);
apiTool.getParameters().forEach((parameterName, parameterProperties) -> {
toolSpecificationBuilder.addParameter(parameterName, type(parameterProperties.get("type")), description(parameterProperties.get("description")));
});
ToolExecutor toolExecutor = (toolExecutionRequest, memoryId) -> httpClient.post(apiTool.getUrl(), toolExecutionRequest.arguments());
tools.put(toolSpecificationBuilder.build(), toolExecutor);
}
}
```
The drawback of this way of configuring tools is that it requires one to
implement a rather low-level `ToolExecutor` interface and manually parse
tool arguments. In future iterations, we could either automatically
parse arguments into a `Map<String, Object>` tree and/or allow users to
explicitly specify a `Class` to parse into.
## 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)
- [ ] 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)
Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to
3.0.3.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="74b2db2938"><code>74b2db2</code></a>
3.0.3</li>
<li><a
href="88f1429a0f"><code>88f1429</code></a>
update eslint. lint, fix unit tests.</li>
<li><a
href="415d660c30"><code>415d660</code></a>
Snyk js braces 6838727 (<a
href="https://redirect.github.com/micromatch/braces/issues/40">#40</a>)</li>
<li><a
href="190510f79d"><code>190510f</code></a>
fix tests, skip 1 test in test/braces.expand</li>
<li><a
href="716eb9f12d"><code>716eb9f</code></a>
readme bump</li>
<li><a
href="a5851e57f4"><code>a5851e5</code></a>
Merge pull request <a
href="https://redirect.github.com/micromatch/braces/issues/37">#37</a>
from coderaiser/fix/vulnerability</li>
<li><a
href="2092bd1fb1"><code>2092bd1</code></a>
feature: braces: add maxSymbols (<a
href="https://github.com/micromatch/braces/issues/">https://github.com/micromatch/braces/issues/</a>...</li>
<li><a
href="9f5b4cf473"><code>9f5b4cf</code></a>
fix: vulnerability (<a
href="https://security.snyk.io/vuln/SNYK-JS-BRACES-6838727">https://security.snyk.io/vuln/SNYK-JS-BRACES-6838727</a>)</li>
<li><a
href="98414f9f1f"><code>98414f9</code></a>
remove funding file</li>
<li><a
href="665ab5d561"><code>665ab5d</code></a>
update keepEscaping doc (<a
href="https://redirect.github.com/micromatch/braces/issues/27">#27</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/micromatch/braces/compare/3.0.2...3.0.3">compare
view</a></li>
</ul>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/langchain4j/langchain4j/network/alerts).
</details>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Well, well, I'm not a front-end guy and therefore not super confortable
with NPM and Node.
I've updated Docusaurus so it runs the latest version and to see if I
can add search and single-page to the documentation.
Hope this runs on CI/CD
Also see https://github.com/langchain4j/langchain4j/pull/1221
Co-authored-by: Lize Raes <49833622+LizeRaes@users.noreply.github.com>
The current implementation supports the tool calls plan, but does not
include ToolExecutionResultMessage. This makes it impossible to feed
back the tool execution results to the model. This patch includes
support for ToolExecutionResultMessage.
<!-- 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 will be rejected. -->
<!-- Please note that PRs 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 paste the link to the issue this PR is addressing. For
example: https://github.com/langchain4j/langchain4j/issues/1012 -->
## Change
<!-- Please describe the changes you made. -->
## 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
## Change
<!-- Please describe the changes you made. -->
Improve more features and make changes to the previous one.
## General checklist
<!-- Please double-check the following points and mark them like this:
[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. -->
- [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)
## 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
Module added according #973 in order to minimize conflicts.
Implementation in line with cohere reranking
<!-- 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 will be rejected. -->
<!-- Please note that PRs 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
https://github.com/langchain4j/langchain4j/issues/974
## Change
- Adding Jina ai as a scoring model.
- Default model: jina-reranker-v1-base-en
- Default url: https://api.jina.ai/v1/
- Used Jackson object mapper instead of Gson, as I found it it's
langchain4j intent to move away from Gson
- Tried to keep implementation in line with Cohere reranking module
## 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)
- [ ] 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] -->
- [x] I have added my new module in the
[BOM](https://github.com/langchain4j/langchain4j/blob/main/langchain4j-bom/pom.xml)
---------
Co-authored-by: Kevin Smeyers <kevin.smeyers@audlau.be>
Co-authored-by: LangChain4j <langchain4j@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 will be rejected. -->
<!-- Please note that PRs 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 paste the link to the issue this PR is addressing. For
example: https://github.com/langchain4j/langchain4j/issues/1012 -->
None - just a doc issue
## Change
<!-- Please describe the changes you made. -->
The current getting started only shows using an integrations specific
library. At least for the Ollama integration, there are no Services in
the integration jar. A user needs to add the core jar but this is not
mentioned in any docs I could find.
It is demonstrated in the tutorials under the examples repo.
https://github.com/langchain4j/langchain4j-examples/blob/main/tutorials/pom.xml
## General checklist
<!-- Please double-check the following points and mark them like this:
[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. -->
- [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)
## 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
## Web Search Engine v1
As the first web engine is added in the `web/search` folder and open the
possibility of adding other types of web tools such as media, maps, etc
within web folder.
```
web
├─search (included in this PR)
└─media
```
`WebSearchEngine` interface responsible to perform searches on the Web
in response to a user query.
The most popular search engines can be implemented on top of this:
- [Google
Search](https://developers.google.com/custom-search/docs/overview)
(Integration is coming is a [separate
PR](https://github.com/langchain4j/langchain4j/pull/641))
- Bing Search
- SerpApi Search
- Tavily AI Search
- etc
`WebSearchRequest` and `WebSearchResults` (response) follow
[opensearch](https://github.com/dewitt/opensearch) foundation standard
implemented by most web search engine libs like Google, Bing, Yahoo, etc
and powered by W3C.
## Web Search Engine as ContentRetriever - RAG
This PR also introduces out-of-the-box `WebSearchContentRetriever` who
is an implementation of a `ContentRetriever` as part of the advanced RAG
flow. The default behavior is currently supported on this PR (v1):
1. Default: Developer wants snippet web pages back (v1)
2. Optional: Developer wants to retrieve only the relevant segments from
scrapped web pages => developer configures `DocumentSplitter` and
`EmbeddingModel` and `minScore` to return results (can be introduced in v2).
## Web Search Engine as Function calling - Tool
Any implementation of `WebSearchEngine` must be able construct a
`WebSearchTool`, so any LM who support function calling like
OpenAI/LocalAI, Azure OpenAI, Gemini Pro, MistralAI, etc to search
current information using an `WebSearchTool`.
Here is how the web search can be visualized:

#### Others
- In the `langchain4j-examples` project, examples will be added of how
to use it with GoogleSearch as a Tool and as a content retriever in a
RAG flow in the next days.
- Documentation will be updated in the next days as well.
<!-- Thank you so much for your contribution! -->
<!-- Please fill in all the sections below. -->
<!-- Please note that PRs without tests will be rejected. -->
## Context
<!-- Please provide some context so that it is clear why this change is
required. -->
## Change
<!-- Please describe the changed you made. -->
## Checklist
Before submitting this PR, please check the following points:
- [ ] I have added unit and integration tests for my change
- [ ] All unit and integration tests in the module I have added/changed
are green
- [ ] All 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 are 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 my new module in the
[BOM](https://github.com/langchain4j/langchain4j/blob/main/langchain4j-bom/pom.xml)
(only when a new module is added)
## Checklist for adding new embedding store integration
- [ ] I have added a {NameOfIntegration}EmbeddingStoreIT that extends
from either EmbeddingStoreIT or EmbeddingStoreWithFilteringIT
Co-authored-by: Remy Ohajinwa <remyohajinwa@Remys-MacBook-Pro.local>
This PR remove `async` columns of the integration table and add
`Anthropic` and `Zhipu AI` as new integrations.
Also, this PR add a new column named `Function calling` to display the
capabilities already supported.
Co-authored-by: Lize Raes <49833622+LizeRaes@users.noreply.github.com>
Bumps
[follow-redirects](https://github.com/follow-redirects/follow-redirects)
from 1.15.4 to 1.15.6.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="35a517c586"><code>35a517c</code></a>
Release version 1.15.6 of the npm package.</li>
<li><a
href="c4f847f851"><code>c4f847f</code></a>
Drop Proxy-Authorization across hosts.</li>
<li><a
href="8526b4a1b2"><code>8526b4a</code></a>
Use GitHub for disclosure.</li>
<li><a
href="b1677ce001"><code>b1677ce</code></a>
Release version 1.15.5 of the npm package.</li>
<li><a
href="d8914f7982"><code>d8914f7</code></a>
Preserve fragment in responseUrl.</li>
<li>See full diff in <a
href="https://github.com/follow-redirects/follow-redirects/compare/v1.15.4...v1.15.6">compare
view</a></li>
</ul>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/langchain4j/langchain4j/network/alerts).
</details>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- Introduced classes and interfaces to facilitate chat interactions with
the Anthropic API, enabling chat completion functionalities.
- Developed a client class for seamless interaction with the AnthropicAI
API, including authentication and request handling.
- Implemented utility methods for message conversion and managing token
usage in chat interactions.
- Defined an enum to distinguish between user and assistant roles in
chat scenarios.
- Added logging interceptors for HTTP requests and responses to enhance
debugging capabilities.
- Created a model class for generating AI responses from chat messages
using the Anthropic API.
- Added a request model class for creating messages in the Anthropic
system.
- Introduced a class for representing image content with type and source
details.
- Included integration tests for the `AnthropicChatModel` class covering
various functionalities.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **Documentation**
- Updated the AI services tutorial to reflect changes in message
annotation semantics within the chat system.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Provide instructions on creating Google Cloud Platform account and
establishing a new project with use of Vertex AI API. Add basic code
samples for using google's PaLM2, Gemini and Embedding models. List
available model names.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **Documentation**
- Updated the guide on Google Vertex AI Embedding Models with
dependencies, example code, and available models.
- Added a link to an article about image generation with Imagen.
- Expanded the documentation for Google Gemini with setup instructions,
authentication strategies, example uses, and early access information.
- Detailed instructions for getting started with Google Vertex AI PaLM
2, including dependencies, example code, and model information.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: Lize Raes <49833622+LizeRaes@users.noreply.github.com>
The redundant base route `/docs` has been updated to `/`. Also, all the
links used in the docs markdown files have been updated accordingly.
Please verify if everything looks fine.
Thanks!
Hi @LizeRaes
I added documentation for the MistralAI integration, it is updated to
link to the summary table added in this
[PR#609](https://github.com/langchain4j/langchain4j/pull/609)
Also, it takes as base the examples added in the `langchain4j-examples`
project added in this [PR#56
](https://github.com/langchain4j/langchain4j-examples/pull/56) still
pending to merge :)
---------
Co-authored-by: LangChain4j <langchain4j@gmail.com>
Co-authored-by: Lize Raes <49833622+LizeRaes@users.noreply.github.com>
Hi @LizeRaes
- Updated main `README.md` to add summary table
- Updated integration overview table + current capabilities
documentation.
https://langchain4j.github.io/langchain4j/docs/integrations/
This is in reference to
https://github.com/langchain4j/langchain4j/discussions/565
PS: Updated as of February 5, probably requires double checking to make
sure all checks are up to date. Anyway, the main idea is that this table
is updated frequently according to contributions :)
---------
Co-authored-by: LangChain4j <langchain4j@gmail.com>
Co-authored-by: Lize Raes <49833622+LizeRaes@users.noreply.github.com>
So far, LangChain4j had only a simple (a.k.a., naive) RAG
implementation: a single `Retriever` was invoked on each interaction
with the LLM, and all retrieved `TextSegments` were appended to the end
of the `UserMessage`. This approach was very limiting.
This PR introduces support for much more advanced RAG use cases. The
design and mental model are inspired by [this
article](https://blog.langchain.dev/deconstructing-rag/) and [this
paper](https://arxiv.org/abs/2312.10997), making it advisable to read
the article.
This PR introduces a `RetrievalAugmentor` interface responsible for
augmenting a `UserMessage` with relevant content before sending it to
the LLM. The `RetrievalAugmentor` can be used with both `AiServices` and
`ConversationalRetrievalChain`, as well as stand-alone.
A default implementation of `RetrievalAugmentor`
(`DefaultRetrievalAugmentor`) is provided with the library and is
suggested as a good starting point. However, users are not limited to it
and can have more freedom with their own custom implementations.
`DefaultRetrievalAugmentor` decomposes the entire RAG flow into more
granular steps and base components:
- `QueryTransformer`
- `QueryRouter`
- `ContentRetriever` (the old `Retriever` is now deprecated)
- `ContentAggregator`
- `ContentInjector`
This modular design aims to separate concerns and simplify development,
testing, and evaluation. Most (if not all) currently known and proven
RAG techniques can be represented as one or multiple base components
listed above.
Here is how the decomposed RAG flow can be visualized:

This mental and software model aims to simplify the thinking, reasoning,
and implementation of advanced RAG flows.
Each base component listed above has a sensible and simple default
implementation configured in `DefaultRetrievalAugmentor` by default but
can be overridden by more sophisticated implementations (provided by the
library out-of-the-box) as well as custom ones. The list of
implementations is expected to grow over time as we discover new
techniques and implement existing proven ones.
This PR also introduces out-of-the-box support for the following proven
RAG techniques:
- Query expansion
- Query compression
- Query routing using LLM
- [Reciprocal Rank
Fusion](https://learn.microsoft.com/en-us/azure/search/hybrid-search-ranking)
- Re-ranking ([Cohere Rerank](https://docs.cohere.com/docs/reranking)
integration is coming in a [separate
PR](https://github.com/langchain4j/langchain4j/pull/539)).
@LizeRaes Updated the images for the docs home page 🙂
Just had to convert the PNGs into SVGs as the `Svg` tag takes only image
as SVG.
---------
Co-authored-by: LizeRaes <49833622+LizeRaes@users.noreply.github.com>
- Updated subpage 0 to `Overview` and made it the landing page upon
clicking `Tutorials` from the horizontal/navigation/top bar.
- Set up GitHub action to build and publish the docs to the GitHub pages
on release. [Preview](https://amithkoujalgi.github.io/langchain4j/) of
the docs on GitHub pages. This action/workflow can also be triggered
manually.
- Added content to `/integrations/language-models/ollama`
PS:
If GitHub pages has been enabled in the repository, the repo admin
should be able to run the new GitHub workflow/action in the Actions tab
and after the completion of the workflow, the docs should be available
in the link provided by GitHub (or a specified custom domain).
Bumps
[follow-redirects](https://github.com/follow-redirects/follow-redirects)
from 1.15.3 to 1.15.4.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="65858205e5"><code>6585820</code></a>
Release version 1.15.4 of the npm package.</li>
<li><a
href="7a6567e16d"><code>7a6567e</code></a>
Disallow bracketed hostnames.</li>
<li><a
href="05629af696"><code>05629af</code></a>
Prefer native URL instead of deprecated url.parse.</li>
<li><a
href="1cba8e85fa"><code>1cba8e8</code></a>
Prefer native URL instead of legacy url.resolve.</li>
<li><a
href="72bc2a4229"><code>72bc2a4</code></a>
Simplify _processResponse error handling.</li>
<li><a
href="3d42aecdca"><code>3d42aec</code></a>
Add bracket tests.</li>
<li><a
href="bcbb096b32"><code>bcbb096</code></a>
Do not directly set Error properties.</li>
<li>See full diff in <a
href="https://github.com/follow-redirects/follow-redirects/compare/v1.15.3...v1.15.4">compare
view</a></li>
</ul>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/langchain4j/langchain4j/network/alerts).
</details>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>