Commit Graph

288 Commits

Author SHA1 Message Date
LangChain4j f5039b6eea
excluded neo4j module from java 8 and 11 builds 2023-12-18 09:31:10 +01:00
Julien Dubois 52fdbaf6df
Update GitHub Actions versions (#357)
In the GitHub Actions workflow:

- Update actions/checkout to the latest version
- Update actions/setup-java to the latest version (Java 21 already works
but is undocumented, the next version it will be thanks to
https://github.com/actions/setup-java/pull/538 😀)
2023-12-15 15:24:22 +01:00
Julien Dubois 55a36c9f00
Migrate to the new Azure OpenAI 1.0.0-beta.6 SDK (#356)
Azure OpenAI 1.0.0-beta.6 is out:

- [x] Update to the new SDK
- [x] Add unit tests
- [x] Do integration tests on my account (as I have access to Azure
OpenAI)
2023-12-15 11:05:09 +01:00
Georgios Andrianakis b7b4c5389b
Remove quarkus module (#345)
This module is confusing people as its intent is not reflected by its
name.
Moreover, this module is simply a copy of the previous version of the
Azure OpenAI stuff that I will just copy in
quarkus-langchain4j-azure-openai
2023-12-14 16:48:02 +01:00
deep-learning-dynamo 3882133f6e moved EmbeddingStoreIngestor from langchain4j to langchain4j-core (#285) 2023-12-14 16:33:02 +01:00
deep-learning-dynamo 5971718145 formatting 2023-12-14 16:06:15 +01:00
deep-learning-dynamo 23cfb07597 improve InMemoryEmbeddingStore: refactor, reduce test duplication, optimized addAll 2023-12-14 16:05:46 +01:00
deep-learning-dynamo 42d5ef9c9e fix the thread safety issue in InMemoryEmbeddingStore. (#351): making sure it deserializes into thread safe list 2023-12-14 15:41:07 +01:00
lexluo09 f1575a9a65
fix the thread safety issue in InMemoryEmbeddingStore. (#351)
fix the thread safety issue in InMemoryEmbeddingStore.

Log and Stack trace:
```
java.util.ConcurrentModificationException: null
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:911)
at java.util.ArrayList$Itr.next(ArrayList.java:861)
at dev.langchain4j.store.embedding.inmemory.InMemoryEmbeddingStore.findRelevant(InMemoryEmbeddingStore.java:122)
at dev.langchain4j.store.embedding.EmbeddingStore.findRelevant(EmbeddingStore.java:67)
```

https://github.com/langchain4j/langchain4j/issues/350
2023-12-14 15:12:29 +01:00
Julien Dubois 38abd88853
Correctly configure Maven wrapper (#348)
Maven wrapper is currently having 2 issues:

- The executable doesn't have the executable bit
- The `.mvn` directory is ignored in Git

Fixing those allow to do `./mvnw package` directly in Codespaces.
2023-12-13 12:48:49 +01:00
Julien Dubois 7ca67e77a3
Add Dev Container support (#337)
Fix #324 

This comes with Java 21, which is not fully supported (see #335 ), but
that should eventually be solved anyway.

This will allow contributors to select "open in CodeSpaces" and work
more easily on the project, like here:

![Screenshot 2023-12-08 at 13 11
43](https://github.com/langchain4j/langchain4j/assets/316835/ecf67ec8-69f3-4b85-8e53-4d71773e6768)
![Screenshot 2023-12-08 at 13 12
35](https://github.com/langchain4j/langchain4j/assets/316835/db0fe7c8-1d1a-4ce9-96e8-7f0a5eeface1)
2023-12-12 19:36:45 +01:00
dependabot[bot] d025238cb0
Bump org.json:json from 20230618 to 20231013 in /langchain4j-cassandra (#341)
Bumps [org.json:json](https://github.com/douglascrockford/JSON-java)
from 20230618 to 20231013.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/douglascrockford/JSON-java/releases">org.json:json's
releases</a>.</em></p>
<blockquote>
<h2>20231013</h2>
<table>
<thead>
<tr>
<th>Pull Request</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/793">#793</a></td>
<td>Reverted <a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/761">#761</a></td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/792">#792</a></td>
<td>update the docs for release 20231013</td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/783">#783</a></td>
<td>optLong vs getLong inconsistencies</td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/782">#782</a></td>
<td>Fix XMLTest.testIndentComplicatedJsonObjectWithArrayAndWithConfig()
for Windows</td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/779">#779</a></td>
<td>add validity check for JSONObject constructors</td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/778">#778</a></td>
<td>Fix XMLTest.testIndentComplicatedJsonObjectWithArrayAndWithConfig()
for Windows</td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/776">#776</a></td>
<td>Update [JUnit to version 4.13.2</td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/774">#774</a></td>
<td>Removing unneeded synchronization</td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/773">#773</a></td>
<td>Add optJSONArray method to JSONObject with a default value</td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/772">#772</a></td>
<td>Disallow nested objects and arrays as keys in objects</td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/779">#779</a></td>
<td>Unit test cleanup</td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/769">#769</a></td>
<td>Addressed Java 17 compile warnings</td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/764">#764</a></td>
<td>Update CodeQL action version</td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/761">#761</a></td>
<td>Add module-info</td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/759">#759</a></td>
<td>JSON parsing should detect embedded </td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/753">#753</a></td>
<td>Updated new object methods</td>
</tr>
<tr>
<td><a
href="https://redirect.github.com/douglascrockford/JSON-java/issues/752">#752</a></td>
<td>Fixes possible unit test bug when compiling/testing on Windows</td>
</tr>
</tbody>
</table>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/stleary/JSON-java/blob/master/docs/RELEASES.md">org.json:json's
changelog</a>.</em></p>
<blockquote>
<p>20231013 First release with minimum Java version 1.8. Recent commits,
including fixes for CVE-2023-5072.</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/douglascrockford/JSON-java/commits">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=org.json:json&package-manager=maven&previous-version=20230618&new-version=20231013)](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>
Co-authored-by: LangChain4j <langchain4j@gmail.com>
2023-12-12 19:22:31 +01:00
Julien Dubois 3c0943d38b
Support Java 21 (#336)
This PR is to fix #335
2023-12-12 19:16:41 +01:00
LangChain4j 8e4254fc20
make OpenAI tokenizer more precise (#346)
This PR is a rework of `OpenAiTokenizer`.
Added `OpenAiTokenizerIT` with lots of tests to ensure that
`OpenAiTokenizer` calculates token usage very close to OpenAI.
In most cases calculation is 1:1, in some corner cases the difference is
within 5%.
2023-12-12 16:45:16 +01:00
deep-learning-dynamo 054a36f59f minor fixes 2023-12-11 11:16:46 +01:00
Scott d08d58c35a
spring-boot-starter add azure openai support (#339)
Add azure support for spring-boot-starter
2023-12-11 11:13:27 +01:00
LangChain4j 303b2ab7b5
OpenAI: Support parallel tool calling (#338)
This PR introduces a support for [parallel tool
calling](https://platform.openai.com/docs/guides/function-calling/parallel-function-calling)
in OpenAI integration.
2023-12-08 17:29:56 +01:00
Julien Dubois 09ab6a1dda
Migration of the AzureOpenAiChatModel to use the Azure OpenAI SDK (#328)
This PR fixes https://github.com/langchain4j/langchain4j/issues/325

- [x] Migrate AzureOpenAiChatModel
- [x] Migrate AzureOpenAiEmbeddingModel
- [x] Migrate AzureOpenAiLanguageModel
- [x] Migrate AzureOpenAiStreamingChatModel
- [x] Migrate AzureOpenAiStreamingLanguageModel
- [x] Add a full suite of tests
2023-12-08 10:51:26 +01:00
deep-learning-dynamo 0d2f743ebc Weaviate: reformat 2023-12-08 10:44:50 +01:00
deep-learning-dynamo b587845b59 Weaviate: added back IT using cloud instance 2023-12-08 10:44:34 +01:00
deep-learning-dynamo c8b3e9b48a LocalAI: added doc links 2023-12-08 10:34:33 +01:00
Eddú Meléndez Gonzales a886eee15a
Use Testcontainers for Weaviate IT (#332)
Run `semitechnologies/weaviate` image using `GenericContainer` and
allow rapid feeback when using Weaviate. Relax `apiKey` constraint
to allow empty value for testing purposes.
2023-12-08 10:33:56 +01:00
shalk(xiao kun) b2f358c926
enable langchain4j-graal build in workflow (#333) 2023-12-08 10:30:36 +01:00
Eddú Meléndez Gonzales b92c4cf138
Use Testcontainers to run LocalAI (#331)
Currently, IT in LocalAI module depends on a instance running.
This commit introduces the use of Testcontainers using
`GenericContainer`.

Also, due to the size of the image and the models. The image is
cached after the first run, improving next executions.
2023-12-08 09:22:18 +01:00
jiangsier-xyz c89da68d4c
Enhanced QWen Model Features and Tokenizer Implementation (#317)
1. Added support for new QWen model features: repetitionPenalty,
temperature, stops, and incrementalOutput.
2. Implemented a new QwenTokenizer class.
3. Refactored code to utilize Lombok builder instead of manual builder
implementation.
2023-12-05 10:52:05 +01:00
Eddú Meléndez Gonzales 00db7557ce
Use Testcontainers in Ollama IT (#315)
Currently, integration tests in Ollama module are disabled because
it needs a Ollama instance running in order to execute them.
Testcontainers provides this infrastructure not only by running
the ollama container but also by automating the pull model step.

This commit, use the Singleton Container approach to reuse the single
instance across multiple IT. Also, pull step is only executed when the
image is `ollama/ollama`.

The behavior on this is:
1st execution:
1. Pull `ollama/ollama` image
2. Start the container based on `ollama/ollama` image
3. Download the `orca-mini` model
4. Create an image based on the current state (with the model in it)
5. Declare the container ready to use
6. Run test

Next executions:
1. Look for the local image created in the 1st execution
2. Start the container based on the local image
3. Declare the container ready to use
4. Run test

1st execution is expected to take longer because of the model (3GB).
Next execution are way more faster.
2023-12-05 10:31:02 +01:00
Eddú Meléndez Gonzales 3168433cb1
Enable Milvus IT by using Testcontainers (#314)
Currently, Milvus IT is disables because it requires a manual step
to run the compose file. Adding Testcontainers, the infrastructure
is in place to run the tests.
2023-12-04 17:54:54 +01:00
Eddú Meléndez Gonzales 2c835a5d2e
Use Testcontainers in Chroma IT (#313)
Use `GenericContainer` to run `ghcr.io/chroma-core/chroma` along with
tests. No manual steps are required to execute them.
2023-12-04 17:50:34 +01:00
Eddú Meléndez Gonzales ea857e6043
Use ElasticsearchContainer in Elasticsearch IT (#312)
Current test execution depends on a running elasticserach instance,
which depends on a manual execution of docker command. This commit
introduces testcontainers as in other modules to run such instance
along with tests, improving DevEx.
2023-12-04 17:46:59 +01:00
deep-learning-dynamo c694d2836c Use Testcontainers annotation (#310) 2023-12-04 17:40:35 +01:00
Eddú Meléndez Gonzales 3676b6d752
Use Testcontainers annotation (#310)
`@Container` is used along with `@Testcontainers` for initialization.
The current test has `PostgreSQLContainer` annotated with `@Container`
and it is manually initialized.
2023-12-04 17:39:17 +01:00
deep-learning-dynamo c3893897cf Fix PG Vector Index creation statement incorrect (#302) 2023-12-04 16:16:18 +01:00
Pascal Vantrepote 1a9f45ddb1
Fix PG Vector Index creation statement incorrect (#302)
Statement has been corrected:

```
                final String indexName = table + "_ivfflat_index";
                connection.createStatement().executeUpdate(String.format(
                        "CREATE INDEX IF NOT EXISTS %s ON %s " +
                                "USING ivfflat (embedding vector_cosine_ops) " +
                                "WITH (lists = %s)",
                        indexName, table, ensureGreaterThanZero(indexListSize, "indexListSize")));
```
2023-12-04 16:13:49 +01:00
Georgios Andrianakis e7bb4bcc15
Add note about Quarkus specific examples (#329) 2023-12-04 15:13:18 +01:00
Svante Kumlien d9fdf179f1
#299 Add null check for ToolsParameters in tokenCountEstimation (#303)
Add null check when estimating the number of tokens in the
ToolParameters.
The parameters are always null for a Tool with no parameters.
2023-11-25 11:09:48 +01:00
sboeckelmann 11e7364686
pass OpenSearchClient directly to OpenSearchEmbeddingStore (#309)
see https://github.com/langchain4j/langchain4j/issues/308
2023-11-25 11:04:29 +01:00
deep-learning-dynamo f98c04028a cleanup 2023-11-24 13:09:51 +01:00
deep-learning-dynamo c671ebebdb Token usage calculation bug (#280): slight refactoring + added a test 2023-11-24 13:01:07 +01:00
jiangsier-xyz 7cfa1a5dfc
Fix a token usage statistical issue in DefaultAiServices (#280)
The statistical logic on token usage is consistent with AiServiceStreamingResponseHandler.

And more:
When it comes to rolling messages in
MessageWindowChatMemory/TokenWindowChatMemory, LinkedList offers
superior performance. ArrayList moves all the elements when the first
element is deleted.
2023-11-24 12:48:45 +01:00
deep-learning-dynamo 06ada5310d disabled jdk17 build temporarily 2023-11-24 12:25:05 +01:00
LangChain4j ba7fabaa50
graal: cleanup (#297) 2023-11-19 12:59:24 +01:00
janglada 949bc25f63
Graal Integration for Local JS and Python Execution (#263)
This PR introduces GraalVM integration to enable local execution of
JavaScript and Python scripts by Langchain4j agents.
Major updates include:

-  New langchain4j-graal module for encapsulating integration logic.
-  Necessary infrastructure for invoking GraalVM and executing scripts.
-  Unit tests to validate the integration.
2023-11-19 09:19:48 +01:00
deep-learning-dynamo 903b3fb1ac reducing duplication of *EmbeddingStoreIT 2023-11-18 21:28:32 +01:00
deep-learning-dynamo bd802c352d reducing duplication of *EmbeddingStoreIT 2023-11-18 21:12:34 +01:00
deep-learning-dynamo 6aed16ab81 reducing duplication of *EmbeddingStoreIT 2023-11-18 20:17:59 +01:00
deep-learning-dynamo 09022d4a32 reducing duplication of *EmbeddingStoreIT 2023-11-18 20:15:46 +01:00
deep-learning-dynamo e0dc387cef reducing duplication of *EmbeddingStoreIT 2023-11-18 20:09:45 +01:00
deep-learning-dynamo 7c5cade3c0 reducing duplication of *EmbeddingStoreIT 2023-11-18 20:02:21 +01:00
deep-learning-dynamo e467beb64a reducing duplication of *EmbeddingStoreIT 2023-11-18 19:20:26 +01:00
deep-learning-dynamo 00c6068de3 reducing duplication of *EmbeddingStoreIT 2023-11-18 18:29:44 +01:00