Commit Graph

1286 Commits

Author SHA1 Message Date
LangChain4j 62794e13e9 Deprecated withApiKey() static factories 2024-09-24 15:53:39 +02:00
LangChain4j 8c625c3caf capitalize maven module names 2024-09-24 15:33:17 +02:00
LangChain4j 42c958a458
Extract HtmlTextExtractor into its own module (#1811)
## Issue
Closes #1049

## Change
Extracted `HtmlTextExtractor` into
`langchain4j-document-transformer-jsoup` module.
Renamed `HtmlToTextDocumentTransformer` into `HtmlTextExtractor`.

Please import:
```xml
<dependency>
    <groupId>dev.langchain4j</groupId>
    <artifactId>langchain4j-document-transformer-jsoup</artifactId>
    <version>0.35.0</version>
</dependency>
```

## 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
- [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 15:08:23 +02:00
LangChain4j f6211ec8fd fix(Google AI Gemini) — Fixed wrong mapping between function execution requests and function execution responses. (#1802) 2024-09-24 14:50:05 +02:00
LangChain4j 2929912448 Integration with Voyage (#1816) 2024-09-24 09:07:34 +02:00
Martin7-1 9e63004370
Integration with Voyage (#1816)
## Issue
Closes #1814 and #1813 

## Change
1. Integration `EmbeddingModel` and `ScoringModel` with `Voyage`.
2. Add document about `VoyageEmbeddingModel` and `VoyageScoringModel`

Related PR:

1. [Voyage
Example](https://github.com/langchain4j/langchain4j-examples/pull/109)
2. [Voyage Spring
Boot](https://github.com/langchain4j/langchain4j-spring/pull/42)

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

## 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)
2024-09-24 08:59:01 +02:00
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
LangChain4j ef2f1ec470 Deprecated withApiKey() static factories 2024-09-23 15:19:51 +02:00
Guillaume Laforge 6bd851fefc
fix(Google AI Gemini) — Fixed wrong mapping between function execution requests and function execution responses. (#1802)
Added a test using `AiServices`.
Function execution requests were mapped to function execution responses.
2024-09-23 12:29:57 +02:00
LangChain4j a91ea8ae4f FEATURE: Anthropic streaming with tools (#1795) 2024-09-23 11:59:07 +02:00
Milan Le d1f5775f8b
FEATURE: Anthropic streaming with tools (#1795)
## Issue
Closes #1738

## Change
- Added AnthropicContentBlockType an enum that specifies content to
follow (text, or tool_use).
- Added AnthropicToolChoice, an enum
- Introduced AnthropicToolExecutionRequestBuilder to build tool
execution requests.
- Updated
`langchain4j-anthropic/src/main/resources/META-INF/native-image/dev.langchain4j/langchain4j-anthropic/reflect-config.json`
- Update handling of streamed content for tools
- Added integration tests

## 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
- [ ] 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-23 11:57:33 +02:00
bidek bcfaf735da
Fix for issue #1804 - When tool is a method without parameters, the handling of parameters in ToolSpecification will result in an error. (#1812)
## Issue
Fixes #1804

## Change
Ollama: handling case when tool don`t have parameters.

## 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
- [ ] 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-23 10:29:55 +02:00
LangChain4j c872a4d46c fixing failing tests 2024-09-23 10:01:44 +02:00
LangChain4j 10ea33fe26 OpenAI: return token usage returned by OpenAI (#1622) 2024-09-22 10:39:00 +02:00
LangChain4j 33199dc588 Fix #1815 2024-09-22 09:50:30 +02:00
LangChain4j 84915ba03e Deprecated Json from langchain4j-core
langchain4j-core should not depend on Gson
2024-09-20 17:31:32 +02:00
LangChain4j 4af5306d50 docu: AI Services, structured outputs 2024-09-20 17:04:45 +02:00
LangChain4j 3a6cb3dc2d fixed a bug where in Spring Boot setting, AI Service method parameter is ignored without @V annotation 2024-09-20 16:27:11 +02:00
LangChain4j 10176556c6 fixed failing test 2024-09-20 16:21:36 +02:00
LangChain4j 4ae78f8738 docu: Spring Boot component wiring 2024-09-20 15:47:55 +02:00
LangChain4j 8ee79fa5f6 docu: Flux 2024-09-20 15:06:50 +02:00
LangChain4j 0e573e9925 docu: logging 2024-09-20 15:00:22 +02:00
LangChain4j 40b0d01349 add scoring onnx (#1769) 2024-09-20 12:21:44 +02:00
1758225523 1c0671617d
add scoring onnx (#1769)
## Issue
Closes #1549

## Change
OnnxScoringModel similar to OnnxEmbeddingModel


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

## Checklist for adding new model integration
- [X] I have added my new module in the
[BOM](https://github.com/langchain4j/langchain4j/blob/main/langchain4j-bom/pom.xml)
2024-09-20 12:18:45 +02:00
Jack Green d72af43416
`dev.langchain4j.data.document.Metadata.Metadata()` creates redundant `Map` (#1801)
## Change
The [default constructor creates an empty
`HashMap`](abd98a8b0b/langchain4j-core/src/main/java/dev/langchain4j/data/document/Metadata.java (L56)),
just to pass it into another constructor [which wraps it another new
`HashMap`](abd98a8b0b/langchain4j-core/src/main/java/dev/langchain4j/data/document/Metadata.java (L75)).

This overhead can be removed.

## General checklist
- [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-09-20 12:07:32 +02:00
LangChain4j d66fa8554b Added listener on aws bedrock (#1805) 2024-09-20 11:41:58 +02:00
Claudio Silva Junior 8893a39276
Added listener on aws bedrock (#1805)
## Issue
Closes #1759

## Change
Added listener on aws bedrock


## 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)
2024-09-20 11:40:48 +02:00
LangChain4j 71d3c7b2ce fixing failing tests 2024-09-20 11:02:21 +02:00
LangChain4j 5089893dbc fixing failing tests 2024-09-20 10:47:02 +02:00
LangChain4j 40fbcc8890 upload surefire reports 2024-09-20 10:37:43 +02:00
Martin7-1 5de2ee47d0
MongoDB Atlas get rid of lombok (#1806)
## Issue
#1636 

## Change
1. Bump `mongodb-driver-sync` from `4.11.1` to `4.11.4`
2. Get rid of lombok

## General checklist
- [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)
- [ ] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)
2024-09-20 10:32:20 +02:00
Guillaume Laforge abd98a8b0b
Vertex AI Gemini documentation with lots of examples (#1799) 2024-09-19 16:18:05 +02:00
LangChain4j 0b29cb21e6 Added ChatModelListener in anthropic model (#1791) 2024-09-19 11:44:28 +02:00
Claudio Silva Junior 6e191b794c
Added ChatModelListener in anthropic model (#1791)
## Issue
Closes #1757

## Change
Added ChatModelListener in anthropic model

## 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
- [ ] 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 11:39:15 +02:00
LangChain4j 3525027f57 fixing failing tests 2024-09-19 10:56:20 +02:00
Julien Dubois ca0ae8af73
Bumps com.azure:azure-storage-blob from 12.27.1 to 12.28.0. (#1794) 2024-09-19 10:23:58 +02:00
Julien Dubois d9ab42674e
Bumps com.azure:azure-storage-common from 12.26.1 to 12.27.0. (#1793) 2024-09-19 10:23:00 +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
jiangsier-xyz 92e0b97040
Added Qwen2.5 open-source series models (#1798)
## Change
Added Qwen2.5 open-source series models, which show amazing results.
    
See: https://qwenlm.github.io/blog/qwen2.5/

## 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
- [ ] 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
2024-09-19 09:24:33 +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
LangChain4j 1dc3ce6e96 Add langchain4j-tablestore Integration:  TablestoreEmbeddingStore/TablestoreChatMemoryStore (#1650) 2024-09-18 11:45:40 +02:00
ScriptShi be7454a7c6
Add langchain4j-tablestore Integration: TablestoreEmbeddingStore/TablestoreChatMemoryStore (#1650)
## Change
Add langchain4j-tablestore Integration: TablestoreEmbeddingStore /
TablestoreChatMemoryStore

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

## Checklist for adding new embedding store integration
<!-- Please double-check the following points and mark them like this:
[X] -->
- [x] I have added a `{NameOfIntegration}EmbeddingStoreIT` that extends
from either `EmbeddingStoreIT` or `EmbeddingStoreWithFilteringIT`
- [x] I have added my new module in the
[BOM](https://github.com/langchain4j/langchain4j/blob/main/langchain4j-bom/pom.xml)
2024-09-18 11:41:53 +02:00
Herbert Beckman 9ea2e27337
[FEAT] Add Function Calling to Amazon Bedrock integration (#1755)
## Issue
Closes #1074

## Change
Add function calling to Amazon Bedrock integration and his available
models by the
[doc](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html#conversation-inference-supported-models-features).

## 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)
2024-09-18 10:43:14 +02:00
LangChain4j 02352da19b fixing failing tests 2024-09-18 09:54:14 +02:00
Kais Neffati ca8c9b9d78
[BUG] ToolSpecifications misses object properties when object appears more than once #1735 (#1781)
## Issue
Closes #1735 

## Change
Fixed bug when ToolSpecifications misses object properties when object appears more than once

## 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)
2024-09-17 14:47:53 +02:00
LangChain4j 09d356fda4 Ollama chat model listener (#1765) 2024-09-17 11:14:00 +02:00
ZYinNJU 16f410c788
Ollama chat model listener (#1765)
## Issue
Closes #1756
Closes #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)
2024-09-17 11:12:43 +02:00
LangChain4j 07ce173fb3 fixed failing tests 2024-09-17 10:20:59 +02:00
ZYinNJU 558433d203
fix Ollama call tool many times (#1778)
## Issue
Closes #1777 

## Change
`langchain4j-ollama` Add `toolCalls` fields when ChatMessage's type is
AiMessage.

The original message do not contains the `toolCalls`:

```json
{
    "model": "qwen2:7b-instruct-q2_K",
    "messages": [
        {
            "role": "user",
            "content": "What is  3+4?"
        },
        {
            "role": "assistant"
        },
        {
            "role": "tool",
            "content": "7"
        }
    ],
    "options": {},
    "stream": false,
    "tools": [
        {
            "type": "function",
            "function": {
                "name": "add",
                "description": "",
                "parameters": {
                    "properties": {
                        "arg1": {
                            "type": "integer"
                        },
                        "arg0": {
                            "type": "integer"
                        }
                    },
                    "required": [
                        "arg0",
                        "arg1"
                    ]
                }
            }
        }
    ]
}
```

The expect way is that the `AiMessage` should contains the toolCall
information so that the model will not continue to call the tools.

expect request:

```json
{
  "model" : "qwen2:7b-instruct-q2_K",
  "messages" : [ {
    "role" : "user",
    "content" : "What is  3+4?"
  }, {
    "role" : "assistant",
    "tool_calls" : [ {
      "function" : {
        "name" : "add",
        "arguments" : {
          "arg1" : 4,
          "arg0" : 3
        }
      }
    } ]
  }, {
    "role" : "tool",
    "content" : "7"
  } ],
  "options" : { },
  "stream" : false,
  "tools" : [ {
    "type" : "function",
    "function" : {
      "name" : "add",
      "description" : "",
      "parameters" : {
        "type" : "object",
        "properties" : {
          "arg1" : {
            "type" : "integer"
          },
          "arg0" : {
            "type" : "integer"
          }
        },
        "required" : [ "arg0", "arg1" ]
      }
    }
  } ]
}
```

## 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)
- [ ] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)
2024-09-17 09:48:55 +02:00
dependabot[bot] b97492773a
Bump dompurify from 3.0.6 to 3.1.6 in /docs (#1787)
Bumps [dompurify](https://github.com/cure53/DOMPurify) from 3.0.6 to
3.1.6.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/cure53/DOMPurify/releases">dompurify's
releases</a>.</em></p>
<blockquote>
<h2>DOMPurify 3.1.6</h2>
<ul>
<li>Fixed an issue with the execution logic of attribute hooks to
prevent bypasses, thanks <a
href="https://github.com/kevin-mizu"><code>@​kevin-mizu</code></a></li>
<li>Fixed an issue with element removal leading to uncaught errors
through DOM Clobbering, thanks <a
href="https://github.com/realansgar"><code>@​realansgar</code></a></li>
<li>Fixed a minor problem with the bower file pointing to the wrong dist
path</li>
<li>Fixed several minor typos in docs, comments and comment blocks,
thanks <a
href="https://github.com/Rotzbua"><code>@​Rotzbua</code></a></li>
<li>Updated several development dependencies</li>
</ul>
<h2>DOMPurify 3.1.5</h2>
<ul>
<li>Fixed a minor issue with the dist paths in <code>bower.js</code>,
thanks <a
href="https://github.com/HakumenNC"><code>@​HakumenNC</code></a></li>
<li>Fixed a minor issue with sanitizing HTML coming from copy&amp;paste
Word content, thanks <a
href="https://github.com/kakao-bishop-cho"><code>@​kakao-bishop-cho</code></a></li>
</ul>
<h2>DOMPurify 3.1.4</h2>
<ul>
<li>Fixed an issue with the recently implemented <code>isNaN</code>
checks, thanks <a
href="https://github.com/tulach"><code>@​tulach</code></a></li>
<li>Added several new popover attributes to allow-list, thanks <a
href="https://github.com/Gigabyte5671"><code>@​Gigabyte5671</code></a></li>
<li>Fixed the tests and adjusted the test runner to cover all
branches</li>
</ul>
<h2>DOMPurify 3.1.3</h2>
<ul>
<li>Fixed several mXSS variations found by and thanks to <a
href="https://github.com/kevin-mizu"><code>@​kevin-mizu</code></a> &amp;
<a href="https://github.com/Ry0taK"><code>@​Ry0taK</code></a></li>
<li>Added better configurability for comment scrubbing default
behavior</li>
<li>Added better hardening against Prototype Pollution attacks, thanks
<a
href="https://github.com/kevin-mizu"><code>@​kevin-mizu</code></a></li>
<li>Added better handling and readability of the <code>nodeType</code>
property, thanks <a
href="https://github.com/ssi02014"><code>@​ssi02014</code></a></li>
<li>Fixed some smaller issues in README and other documentation</li>
</ul>
<h2>DOMPurify 3.1.2</h2>
<ul>
<li>Addressed and fixed a mXSS variation found by <a
href="https://github.com/kevin-mizu"><code>@​kevin-mizu</code></a></li>
<li>Addressed and fixed a mXSS variation found by <a
href="https://twitter.com/hash_kitten">Adam Kues</a> of Assetnote</li>
<li>Updated tests for older Safari and Chrome versions</li>
</ul>
<h2>DOMPurify 3.1.1</h2>
<ul>
<li>Fixed an mXSS sanitiser bypass reported by <a
href="https://github.com/icesfont"><code>@​icesfont</code></a></li>
<li>Added new code to track element nesting depth</li>
<li>Added new code to enforce a maximum nesting depth of 255</li>
<li>Added coverage tests and necessary clobbering protections</li>
</ul>
<p><strong>Note that this is a security release and should be upgraded
to immediately. Please also note that further releases may follow as the
underlying vulnerability is apparently new and further variations may be
discovered.</strong></p>
<h2>DOMPurify 3.1.0</h2>
<ul>
<li>Added new setting <code>SAFE_FOR_XML</code> to enable better control
over comment scrubbing</li>
<li>Updated README to warn about <em>happy-dom</em> not being safe for
use with DOMPurify yet</li>
<li>Updated the LICENSE file to show the accurate year number</li>
<li>Updated several build and test dependencies</li>
</ul>
<h2>DOMPurify 3.0.11</h2>
<ul>
<li>Fixed another conditional bypass caused by Processing Instructions,
thanks <a
href="https://github.com/Ry0taK"><code>@​Ry0taK</code></a></li>
<li>Fixed the regex for HTML Custom Element detection, thanks <a
href="https://github.com/AlekseySolovey3T"><code>@​AlekseySolovey3T</code></a></li>
</ul>
<h2>DOMPurify 3.0.10</h2>
<ul>
<li>Fixed two possible bypasses when sanitizing an XML document and
later using it in HTML, thanks <a
href="https://github.com/Slonser"><code>@​Slonser</code></a></li>
<li>Bumped up some build and test dependencies</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="4083a9096b"><code>4083a90</code></a>
Merge pull request <a
href="https://redirect.github.com/cure53/DOMPurify/issues/978">#978</a>
from cure53/main</li>
<li><a
href="90a10a14af"><code>90a10a1</code></a>
fix: Fixed a typo on the README</li>
<li><a
href="65df0428f0"><code>65df042</code></a>
chore: Preparing 3.1.6 release</li>
<li><a
href="6e03334bab"><code>6e03334</code></a>
fix: Made sure that remove() is not called directly from node</li>
<li><a
href="00fc06cf57"><code>00fc06c</code></a>
fix: Fixed a DOM clobbering issue leading to an error being thrown</li>
<li><a
href="f8c2ef5911"><code>f8c2ef5</code></a>
Merge pull request <a
href="https://redirect.github.com/cure53/DOMPurify/issues/977">#977</a>
from cure53/dependabot/npm_and_yarn/multi-99ca4f73d8</li>
<li><a
href="e5112ec40a"><code>e5112ec</code></a>
build(deps): bump ws and socket.io-adapter</li>
<li><a
href="9978cecea2"><code>9978cec</code></a>
docs: Added better security warning about SAFE_FOR_XML to README</li>
<li><a
href="fa542df7e8"><code>fa542df</code></a>
fix: Changed the order for attribute checks slightly for safer
hooks</li>
<li><a
href="b8b552cb21"><code>b8b552c</code></a>
Merge pull request <a
href="https://redirect.github.com/cure53/DOMPurify/issues/975">#975</a>
from cure53/dependabot/npm_and_yarn/multi-2d3aef8690</li>
<li>Additional commits viewable in <a
href="https://github.com/cure53/DOMPurify/compare/3.0.6...3.1.6">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dompurify&package-manager=npm_and_yarn&previous-version=3.0.6&new-version=3.1.6)](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>
2024-09-17 09:34:39 +02:00