Commit Graph

864 Commits

Author SHA1 Message Date
Lize Raes a4e82afb2b
Removing incorrect end comma in jsonStructure for POJO extracting AI Services (#894)
## Context
I noted that for more complex POJO object, the JSON returned by the LLM
often contained a last comma before closing bracket, making the JSON
invalid and resulting in an error while parsing it. I traced it back to
the proposed jsonStructure that is part of the SystemMessage, sending a
wrong format to the LLM.

## Change
Removed the last comma that shouldn't be there in the jsonStructure +
updated the unit tests

---------

Co-authored-by: Lize
2024-04-07 18:54:10 +02:00
Ikko Eltociear Ashimine b6f3df8071
refactor: Update AstraDbEmbeddingStoreIT.java (#863)
<!-- Thank you so much for your contribution! -->

## Context
<!-- Please provide some context so that it is clear why this change is
required. -->

## Change
refereceEmbedding -> referenceEmbedding

## 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)
2024-04-03 10:55:10 +02:00
af su 0577991c0e
refactor: redefine HuggingFaceModelName constant class (#870)
## Context
As a constant class, the class is typically immutable and has a private
constructor.
2024-04-03 10:52:23 +02:00
Glarme 6aacd0b731
fix(langchain4j-zhipu-ai): Fix baseUrl misconfiguration in ZhipuAiClient builder (#872)
Fix baseUrl misconfiguration in ZhipuAiClient builder

<!-- Thank you so much for your contribution! -->

## Context
<!-- Please provide some context so that it is clear why this change is
required. -->
This commit addresses an issue where the baseUrl in the builder of
ZhipuAiClient was not properly configured in Module
langchain4j-zhipu-ai. This misconfiguration could potentially lead to
confusion or errors when using the client directly. By correcting the
baseUrl configuration, this commit ensures consistent and accurate
behavior of the client.

## Change
<!-- Please describe the changed you made. -->
Change the baseUrl value in
`dev.langchain4j.model.zhipu.ZhipuAiClient.Builder` from
`https://aip.baidubce.com/` to `https://open.bigmodel.cn/`

## 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)
2024-04-03 10:51:27 +02:00
Eric Deandrea 8ffd4e56bc
Add getters to AnthropicCreateMessageRequest and change scope of attributes (#873)
This should have been done in #834
2024-04-03 10:50:04 +02:00
LangChain4j 32db17b60c PR template: added tests requirement 2024-04-03 10:42:38 +02:00
LangChain4j 45b58ac993
released 0.29.1 (#857) 2024-03-28 16:42:45 +01:00
LangChain4j a7e26d2435 released core and parent together 2024-03-28 14:23:24 +01:00
LangChain4j a2572c862c
Fix 804 (#856)
<!-- Thank you so much for your contribution! -->

## Context
See https://github.com/langchain4j/langchain4j/issues/804

## Change
- `OpenAiStreamingChatModel`: in case `modelName` is not one of the
known OpenAI models, do not return `TokenUsage` in the `Response`. This
is done for cases when `OpenAiStreamingChatModel` is used to connect to
other OpenAI-API-compatible LLM providers like Ollama and Groq. In such
cases it is better to not return `TokenUsage` then returning a wrong
one.
- For all OpenAI models, default `Tokenizer` will now use
"gpt-3.5-turbo" model name instead of the one provided by the user in
the `modelName` parameter. This is done to avoid crashing with "Model
'ft:gpt-3.5-turbo:my-org:custom_suffix:id' is unknown to jtokkit" for
fine-tuned OpenAI models. It should be safe to use "gpt-3.5-turbo" by
default with all current OpenAI models, as they all use the same
cl100k_base encoding.


## Checklist
Before submitting this PR, please check the following points:
- [X] I have added unit and integration tests for my change
- [X] All unit and integration tests in the module I have added/changed
are green
- [X] 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)
2024-03-28 14:06:28 +01:00
LangChain4j 6b410e6425 Fix #799 2024-03-28 10:48:14 +01:00
LangChain4j 1dc55a9066 Fix #833: DocumentByParagraphSplitter regex JDK version adaptation (#843) 2024-03-28 09:55:26 +01:00
Kugaaa b07964e21e
Fix #833: DocumentByParagraphSplitter regex JDK version adaptation (#843)
## Context
See [#833](https://github.com/langchain4j/langchain4j/issues/833)

## Change
`DocumentByParagraphSplitter` split regular expression

## Checklist
Before submitting this PR, please check the following points:
- [x] I have added unit and integration tests for my change
- [x] All unit and integration tests in the module I have added/changed
are green
- [x] 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)
2024-03-28 09:50:57 +01:00
LangChain4j 57cd62cf0e Docu: RAG 2024-03-28 09:15:14 +01:00
tenpigs267 2f417ceb84
removing classname before the json structure (#844)
## Context
This PR remove the classname that had been added in front of json
structure in ServiceOutputParser as discusser here :
https://github.com/langchain4j/langchain4j/pull/625#discussion_r1540700157

## Change
just removing the unwanted classname
2024-03-28 07:28:16 +01:00
LangChain4j 0bdade2865
Docu: RAG (#846) 2024-03-27 17:44:48 +01:00
LangChain4j 7aa75324ed Docu: Mistral AI json mode 2024-03-27 12:49:22 +01:00
Eric Deandrea 6fd8fbcade
Introduce SPI for creating Anthropic client (#834)
<!-- Thank you so much for your contribution! -->

## Context
This is very similar to what is done for Mistral (#744) and OpenAI. It
will directly enable quarkiverse/quarkus-langchain4j#413.
2024-03-27 09:19:54 +01:00
Quentin 2185c0fb93
Fix some typos (#835)
<!-- Thank you so much for your contribution! -->

## 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
- [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 my new module in the
[BOM](https://github.com/langchain4j/langchain4j/blob/main/langchain4j-bom/pom.xml)
(only when a new module is added)

---------

Co-authored-by: LangChain4j <langchain4j@gmail.com>
2024-03-27 09:15:44 +01:00
Quentin 40a88c8bde
Improvements: Common part can be extracted removing branch (#836)
<!-- Thank you so much for your contribution! -->

## 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)
2024-03-27 09:13:19 +01:00
Georgios Andrianakis 5ac4e2c69c
Make Mistral tool related enums public (#838)
This allows integrations to customize how they serialized
2024-03-27 08:17:25 +01:00
LangChain4j 8ea1c12f03 Docu: AI Services in Quarkus and Spring Boot 2024-03-26 15:44:54 +01:00
LangChain4j 5e893953fa removed news from README 2024-03-26 14:21:53 +01:00
LangChain4j daaff4d2f6 updated example links in docu 2024-03-26 14:21:36 +01: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 fcd2331335 release parent separately 2024-03-25 17:49:41 +01:00
LangChain4j 64e7f37238 Merge remote-tracking branch 'origin/main' 2024-03-25 17:27:00 +01:00
LangChain4j 0eb9269866 added separate release workflow for core 2024-03-25 17:26:51 +01:00
Julien Dubois e4ac768148
Bump com.azure:azure-storage-blob from 12.25.2 to 12.25.3 (#811)
Minor library update
2024-03-25 17:19:50 +01:00
LangChain4j ce04012723 extracted AiServicesWithChatMemoryIT 2024-03-25 17:19:08 +01:00
LangChain4j 7ac144e7fd ITs fixes 2024-03-25 17:18:52 +01:00
Julien Dubois 7534884854
Add a variable to optionally update the index in AzureAISearchContentRetriver (#822)
See #795
2024-03-25 15:54:16 +01:00
LangChain4j 9b62e85194
Allow using AI Service with tools without memory (#819)
<!-- Thank you so much for your contribution! -->

## Context
Currenty AI Service can use tools only if there is a `ChatMemory` or
`ChatMemoryProvider` configured.
This is probably an unnecessary and overly strict requirement. In
practice, tools can be used without the memory that spans between calls
to AI service, using only a "temporary memory" that spans single call to
the AI service (that can include multiple interactions with LLM due to
tool executions).

## Change
Allow using AI Services with tools without memory. If there is no memory
configured, a "temporary memory" is used for each AI Service invocation
to store all messages created/produced in scope of this AI Service
invocation.

## Checklist
Before submitting this PR, please check the following points:
- [X] I have added unit and integration tests for my change
- [X] All unit and integration tests in the module I have added/changed
are green
- [X] 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)
2024-03-25 15:49:41 +01:00
LangChain4j ffb0352321 [FEATURE] #734 Add missing foundational Bedrock models (#773) 2024-03-25 13:31:58 +01:00
LangChain4j 4db0f9ceac Revert "Add streaming API for Bedrock Anthropics (#679)"
This reverts commit 6684ea0b33.
2024-03-25 12:07:02 +01:00
LangChain4j 6224530ac7 [FEATURE] #734 Add missing foundational Bedrock models (#773) 2024-03-25 11:54:59 +01:00
Ruslan 82c60b98e8
Support relative paths without parent directory (#817)
## Context
Closes #816.

## Change
I've just reordered methods: `getParent` and `getAbsolutePath`. Quite a
simple change.

Still, it may not work if the file is in the root (or may be work,
haven't tested).

I had some problems with opening the project in InteliJ IDEA and I need
some help, do I need to add some tests? I would like, but how to mock
the filesystem?

## Checklist
Before submitting this PR, please check the following points:
- [ ] I have added unit and integration tests for my change
- [x] All unit and integration tests in the module I have added/changed
are green
- [x] 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)
2024-03-25 09:30:39 +01:00
Michał Koźmiński 6684ea0b33
Add streaming API for Bedrock Anthropics (#679)
Currently, langchain4j doesn't have support for streaming of Bedrock
Anthropics model, this PR tries to address it.

Adding support for Anthropics v2 and v2:1 streaming. 
New tests disabled due to need for AWS credentials but pass when
enabled.
2024-03-25 09:17:48 +01:00
Jonny Coddington ded9ecce38
[FEATURE] #734 Add missing foundational Bedrock models (#773)
This PR addresses issue
https://github.com/langchain4j/langchain4j/issues/734:

- Added functionality to pass in strings & enums as model ID. 
- Added Llama and Mistral AI models. 
- Added Anthropic Message API model
2024-03-25 09:15:45 +01:00
LangChain4j 016f0b60ea
Fix #757: Gemini: allow SystemMessage(s), merge them into the first UserMessage, warn in logs (#812)
## Context
See https://github.com/langchain4j/langchain4j/issues/757

## Change
All `SystemMessage`s from the input are now merged together into the
first `UserMessage`.
Warning abut this is given (once) in the log.

## Checklist
Before submitting this PR, please check the following points:
- [X] I have added unit and integration tests for my change
- [X] All unit and integration tests in the module I have added/changed
are green
- [X] 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
- [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 my new module in the
[BOM](https://github.com/langchain4j/langchain4j/blob/main/langchain4j-bom/pom.xml)
(only when a new module is added)
2024-03-25 09:13:06 +01:00
dependabot[bot] b3c0dad47d
Bump webpack-dev-middleware from 5.3.3 to 5.3.4 in /docs (#807)
Bumps
[webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware)
from 5.3.3 to 5.3.4.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/webpack/webpack-dev-middleware/releases">webpack-dev-middleware's
releases</a>.</em></p>
<blockquote>
<h2>v5.3.4</h2>
<h3><a
href="https://github.com/webpack/webpack-dev-middleware/compare/v5.3.3...v5.3.4">5.3.4</a>
(2024-03-20)</h3>
<h3>Bug Fixes</h3>
<ul>
<li><strong>security:</strong> do not allow to read files above (<a
href="https://redirect.github.com/webpack/webpack-dev-middleware/issues/1779">#1779</a>)
(<a
href="189c4ac7d2">189c4ac</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/webpack/webpack-dev-middleware/blob/v5.3.4/CHANGELOG.md">webpack-dev-middleware's
changelog</a>.</em></p>
<blockquote>
<h3><a
href="https://github.com/webpack/webpack-dev-middleware/compare/v5.3.3...v5.3.4">5.3.4</a>
(2024-03-20)</h3>
<h3>Bug Fixes</h3>
<ul>
<li><strong>security:</strong> do not allow to read files above (<a
href="https://redirect.github.com/webpack/webpack-dev-middleware/issues/1779">#1779</a>)
(<a
href="189c4ac7d2">189c4ac</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="86071ead69"><code>86071ea</code></a>
chore(release): 5.3.4</li>
<li><a
href="189c4ac7d2"><code>189c4ac</code></a>
fix(security): do not allow to read files above (<a
href="https://redirect.github.com/webpack/webpack-dev-middleware/issues/1779">#1779</a>)</li>
<li>See full diff in <a
href="https://github.com/webpack/webpack-dev-middleware/compare/v5.3.3...v5.3.4">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=webpack-dev-middleware&package-manager=npm_and_yarn&previous-version=5.3.3&new-version=5.3.4)](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-03-25 09:02:59 +01:00
Julien Dubois 60673ab97d
Bump com.azure:azure-search-documents from 11.6.2 to 11.6.3. (#810)
Minor library update
2024-03-25 09:01:22 +01:00
Julien Dubois 681a0a2bb6
Bump com.azure:azure-storage-common from 12.24.2 to 12.24.3 (#809)
Minor library update.
2024-03-25 09:01:07 +01:00
Siben Nayak 86a5908f8a
Add support for Neo4J Graph and ContentRetriever (#741)
For Issue #685 

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


- **New Features**
- Introduced a `Neo4jGraph` class for enhanced interaction with Neo4j
databases, including read/write operations and schema management.
- Added a `Neo4jContentRetriever` for generating and executing Cypher
queries from user questions, improving content retrieval from Neo4j
databases.
- **Tests**
- Implemented tests for Neo4j database interactions and content
retrieval functionalities, ensuring reliability and performance.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-03-25 08:43:35 +01:00
Carlos Zela Bueno 50af4b39d5
[DOCS] MistralAI function calling docs (#765) 2024-03-25 08:39:56 +01:00
Carlos Zela Bueno ae68bf9ab3
[FEATURE] Mistral AI supports function calling (#767)
This PR adds `function calling` support for MistralAI `chat` and
`streaming` completions models.

Also, add and deprecate the Mistral AI models like:
- open-mistral-7b, 
- open-mixtral-8x7b, 
- mistral-small-latest, 
- mistral-medium-latest, 
- mistral-large-latest,
- mistral-tiny (deprecated)
- mistral-medium (deprecated)

Others PR related:
1. MistralAI Examples with function calling
[PR#68](https://github.com/langchain4j/langchain4j-examples/pull/68)
2. MistralAI Function Calling documentation
[PR#765](https://github.com/langchain4j/langchain4j/pull/765)
3. Updating the integration table by adding the function calling as new
column for other integrations [
PR#766](https://github.com/langchain4j/langchain4j/pull/766)
2024-03-25 08:34:29 +01:00
Aayush Kataria 7e5025c5de
Adding Azure cosmos mongo vCore as a new Embedding Store (#691)
I have added Azure Cosmos DB Mongo vCore as an Embedding Store to be
used by customers using LangChain4J and Cosmos DB for their LLM
applications.
2024-03-22 14:51:11 +01:00
LangChain4j 69511a5c18 Merge remote-tracking branch 'origin/main' 2024-03-22 11:46:34 +01:00
LangChain4j fbced4e70e Ollama: test that OpenAI API (OpenAiChatModel) works 2024-03-22 11:46:28 +01:00
Raja Kolli fa110d33fd
adds PGVector Store example (#792)
Updated documentation with PGVector link
2024-03-22 10:41:05 +01:00