Skip to content

Commit

Permalink
Merge branch 'langchain4j:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Suhas-Koheda authored Nov 29, 2024
2 parents c155d3a + d9c2f72 commit 548d979
Show file tree
Hide file tree
Showing 134 changed files with 2,030 additions and 4,512 deletions.
28 changes: 14 additions & 14 deletions .editorconfig

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Closes #
## 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 added unit and/or integration tests for my change
- [ ] The tests cover both positive and negative cases
- [ ] I have manually run all the unit and integration tests in the module I have added/changed, and they are all green
- [ ] I have manually run all the unit and integration tests in the [core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core) and [main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j) modules, and they are all green
<!-- Before adding documentation and example(s) (below), please wait until the PR is reviewed and approved. -->
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ jobs:
MILVUS_API_KEY: ${{ secrets.MILVUS_API_KEY }}
MILVUS_URI: ${{ secrets.MILVUS_URI }}
MISTRAL_AI_API_KEY: ${{ secrets.MISTRAL_AI_API_KEY }}
MONGODB_ATLAS_USERNAME: ${{ secrets.MONGODB_ATLAS_USERNAME }}
MONGODB_ATLAS_PASSWORD: ${{ secrets.MONGODB_ATLAS_PASSWORD }}
MONGODB_ATLAS_HOST: ${{ secrets.MONGODB_ATLAS_HOST }}
NOMIC_API_KEY: ${{ secrets.NOMIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }}
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/nightly_jdk17.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ jobs:
MILVUS_API_KEY: ${{ secrets.MILVUS_API_KEY }}
MILVUS_URI: ${{ secrets.MILVUS_URI }}
MISTRAL_AI_API_KEY: ${{ secrets.MISTRAL_AI_API_KEY }}
MONGODB_ATLAS_USERNAME: ${{ secrets.MONGODB_ATLAS_USERNAME }}
MONGODB_ATLAS_PASSWORD: ${{ secrets.MONGODB_ATLAS_PASSWORD }}
MONGODB_ATLAS_HOST: ${{ secrets.MONGODB_ATLAS_HOST }}
NOMIC_API_KEY: ${{ secrets.NOMIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }}
Expand All @@ -83,11 +80,12 @@ jobs:
VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }}
WEAVIATE_API_KEY: ${{ secrets.WEAVIATE_API_KEY }}
WEAVIATE_HOST: ${{ secrets.WEAVIATE_HOST }}
CI_DELAY_SECONDS_AZURE_AI_SEARCH: 3
CI_DELAY_SECONDS_AZURE_OPENAI: 1
CI_DELAY_SECONDS_BEDROCK: 3
CI_DELAY_SECONDS_GITHUB_MODELS: 3
CI_DELAY_SECONDS_BEDROCK: 5
CI_DELAY_SECONDS_GITHUB_MODELS: 5
CI_DELAY_SECONDS_GOOGLE_AI_GEMINI: 5
CI_DELAY_SECONDS_VERTEX_AI_GEMINI: 7
CI_DELAY_SECONDS_VERTEX_AI_GEMINI: 10
CI_DELAY_SECONDS_VOYAGE_AI: 22

- name: Upload Test Reports
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/nightly_jdk21.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ jobs:
MILVUS_API_KEY: ${{ secrets.MILVUS_API_KEY }}
MILVUS_URI: ${{ secrets.MILVUS_URI }}
MISTRAL_AI_API_KEY: ${{ secrets.MISTRAL_AI_API_KEY }}
MONGODB_ATLAS_USERNAME: ${{ secrets.MONGODB_ATLAS_USERNAME }}
MONGODB_ATLAS_PASSWORD: ${{ secrets.MONGODB_ATLAS_PASSWORD }}
MONGODB_ATLAS_HOST: ${{ secrets.MONGODB_ATLAS_HOST }}
NOMIC_API_KEY: ${{ secrets.NOMIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }}
Expand All @@ -83,11 +80,12 @@ jobs:
VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }}
WEAVIATE_API_KEY: ${{ secrets.WEAVIATE_API_KEY }}
WEAVIATE_HOST: ${{ secrets.WEAVIATE_HOST }}
CI_DELAY_SECONDS_AZURE_AI_SEARCH: 3
CI_DELAY_SECONDS_AZURE_OPENAI: 1
CI_DELAY_SECONDS_BEDROCK: 3
CI_DELAY_SECONDS_GITHUB_MODELS: 3
CI_DELAY_SECONDS_BEDROCK: 5
CI_DELAY_SECONDS_GITHUB_MODELS: 5
CI_DELAY_SECONDS_GOOGLE_AI_GEMINI: 5
CI_DELAY_SECONDS_VERTEX_AI_GEMINI: 7
CI_DELAY_SECONDS_VERTEX_AI_GEMINI: 10
CI_DELAY_SECONDS_VOYAGE_AI: 22

- name: Upload Test Reports
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ jobs:
MILVUS_API_KEY: ${{ secrets.MILVUS_API_KEY }}
MILVUS_URI: ${{ secrets.MILVUS_URI }}
MISTRAL_AI_API_KEY: ${{ secrets.MISTRAL_AI_API_KEY }}
MONGODB_ATLAS_USERNAME: ${{ secrets.MONGODB_ATLAS_USERNAME }}
MONGODB_ATLAS_PASSWORD: ${{ secrets.MONGODB_ATLAS_PASSWORD }}
MONGODB_ATLAS_HOST: ${{ secrets.MONGODB_ATLAS_HOST }}
NOMIC_API_KEY: ${{ secrets.NOMIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }}
Expand Down
2 changes: 2 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
-Djava.awt.headless=true
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Thank you for investing your time and effort in contributing to our project, we
- Keep the code compatible with Java 17.
- Avoid adding new dependencies as much as possible (new dependencies with test scope are OK). If absolutely necessary, try to use the same libraries which are already used in the project. Make sure you run `mvn dependency:analyze` to identify unnecessary dependencies.
- Write unit and/or integration tests for your code. This is critical: no tests, no review!
- The tests should cover both positive and negative cases.
- Make sure you run all unit tests on all modules with `mvn clean test`
- Avoid making breaking changes. Always keep backward compatibility in mind. For example, instead of removing fields/methods/etc, mark them `@Deprecated` and make sure they still work as before.
- Follow existing naming conventions.
Expand Down Expand Up @@ -44,6 +45,7 @@ Please note that we do not have the capacity to review PRs immediately. We ask f

# Guidelines on adding a new model integration

- Please open PRs with new model integrations in the [langchain4j-community](https://github.com/langchain4j/langchain4j-community) repository
- [Integration with Anthropic](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-anthropic) is a good example.
- Use the official SDK if available.
- If the official SDK is not available, use Java 11 HTTP Client and Jackson to implement the client.
Expand All @@ -54,6 +56,7 @@ Please note that we do not have the capacity to review PRs immediately. We ask f

# Guidelines on adding a new embedding store integration

- Please open PRs with new embedding store integrations in the [langchain4j-community](https://github.com/langchain4j/langchain4j-community) repository
- [Integration with Chroma](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-chroma) is a good example.
- Use the official SDK if available.
- If the official SDK is not available, use Java 11 HTTP Client and Jackson to implement the client.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![CODACY](https://img.shields.io/badge/Codacy-Dashboard-blue?style=for-the-badge&logo=codacy)](https://app.codacy.com/gh/langchain4j/langchain4j/dashboard)

[![Discord](https://dcbadge.vercel.app/api/server/JzTFvyjG6R?style=for-the-badge)](https://discord.gg/JzTFvyjG6R)
[![BlueSky](https://img.shields.io/badge/@langchain4j-follow-blue?logo=bluesky&style=for-the-badge)](https://bsky.app/profile/langchain4j.dev)
[![X](https://img.shields.io/badge/@langchain4j-follow-blue?logo=x&style=for-the-badge)](https://x.com/langchain4j)
[![Maven Version](https://img.shields.io/maven-central/v/dev.langchain4j/langchain4j?logo=apachemaven&style=for-the-badge)](https://search.maven.org/#search|gav|1|g:"dev.langchain4j"%20AND%20a:"langchain4j")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>

<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<!-- DEPENDENCY CONFLICT RESOLUTION FOR OKHTTP (END) -->

<dependency>
Expand Down
8 changes: 8 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
style:
active: true
MethodName:
active: true
ignoreOverriddenFunctions: true
excludeAnnotatedMethodsOrClasses:
- "org.junit.jupiter.api.Test"
ignoreTestFiles: true
30 changes: 30 additions & 0 deletions docs/docs/integrations/embedding-models/dashscope.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ https://dashscope.aliyun.com/

## Maven Dependency

:::note
Since `0.37.0`, `langchain4j-dashscope` has migrated to `langchain4j-community` and is renamed to `langchain4j-community-dashscope`.
:::

`0.36.2` and previous:

```xml
<dependency>
<groupId>dev.langchain4j</groupId>
Expand All @@ -17,6 +23,30 @@ https://dashscope.aliyun.com/
</dependency>
```

`0.37.0` and later:

```xml
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-community-dashscope</artifactId>
<version>0.37.0</version>
</dependency>
```

Or, you can use BOM to manage dependencies consistently:

```xml
<dependencyManagement>
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-community-bom</artifactId>
<version>0.37.0</version>
<typ>pom</typ>
<scope>import</scope>
</dependency>
</dependencyManagement>
```

## APIs

- `QwenEmbeddingModel`
Expand Down
54 changes: 54 additions & 0 deletions docs/docs/integrations/embedding-stores/duckdb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
sidebar_position: 11
---

# DuckDB

https://duckdb.org/

## Maven Dependency

```xml
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-community-duckdb</artifactId>
<version>0.37.0</version>
</dependency>
```

## APIs

- `DuckDBEmbeddingStore`

## Examples

```java
// Init Model and Store
var embeddingStore = DuckDBEmbeddingStore.inMemory();
var embeddingModel = new AllMiniLmL6V2QuantizedEmbeddingModel();

//Create embeddings
Stream.of(
"DuckDB is an amazing database engine!",
"Python really lack of typing :D")
.forEach(text -> {
var segment = TextSegment.from(text);
var embedding = embeddingModel.embed(segment).content();
embeddingStore.add(embedding, segment);
});


// Search request
var queryEmbedding = embeddingModel.embed("What is the best database engine").content();
var request = EmbeddingSearchRequest.builder()
.queryEmbedding(queryEmbedding)
.maxResults(1)
.build();

var relevant = embeddingStore.search(request);
EmbeddingMatch<TextSegment> embeddingMatch = relevant.matches().get(0);

// Show results
System.out.println(embeddingMatch.score()); // 0.8416415629618381
System.out.println(embeddingMatch.embedded().text()); //DuckDB is an amazing database engine!
```
2 changes: 1 addition & 1 deletion docs/docs/integrations/embedding-stores/elasticsearch.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 11
sidebar_position: 12
---

# Elasticsearch
Expand Down
5 changes: 3 additions & 2 deletions docs/docs/integrations/embedding-stores/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ sidebar_position: 0
| [ClickHouse](/integrations/embedding-stores/clickhouse) ||||
| [Coherence](/integrations/embedding-stores/coherence) ||||
| [Couchbase](/integrations/embedding-stores/couchbase) || ||
| [DuckDB](/integrations/embedding-stores/duckdb) ||||
| [Elasticsearch](/integrations/embedding-stores/elasticsearch) ||||
| [Infinispan](/integrations/embedding-stores/infinispan) || | |
| [Milvus](/integrations/embedding-stores/milvus) ||||
| [MongoDB Atlas](/integrations/embedding-stores/mongodb-atlas) || Only native filter support | |
| [MongoDB Atlas](/integrations/embedding-stores/mongodb-atlas) || | |
| [Neo4j](/integrations/embedding-stores/neo4j) || | |
| [OpenSearch](/integrations/embedding-stores/opensearch) || | |
| [Oracle](/integrations/embedding-stores/oracle) ||||
| [PGVector](/integrations/embedding-stores/pgvector) ||||
| [Pinecone](/integrations/embedding-stores/pinecone) ||||
| [Qdrant](/integrations/embedding-stores/qdrant) ||| |
| [Qdrant](/integrations/embedding-stores/qdrant) ||| |
| [Redis](/integrations/embedding-stores/redis) || | |
| [Tablestore](/integrations/embedding-stores/tablestore) ||||
| [Vearch](/integrations/embedding-stores/vearch) || | |
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/embedding-stores/infinispan.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 12
sidebar_position: 13
---

# Infinispan
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/embedding-stores/milvus.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 13
sidebar_position: 14
---

# Milvus
Expand Down
14 changes: 8 additions & 6 deletions docs/docs/integrations/embedding-stores/mongodb-atlas.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 14
sidebar_position: 15
---

# MongoDB Atlas and Vector Search
Expand All @@ -10,13 +10,16 @@ sidebar_position: 14

## Prerequisites

You must have an Atlas cluster that runs one of the following MongoDB versions:
Vector Search requires the following or later MongoDB versions:

- 6.0.11
- 7.0.2
- Later versions (including Release Candidates).

To use Atlas Vector search, you need to have an Atlas deployment. MongoDB offers a free forever cluster that you can use for testing. See the [Get Started with Atlas](https://www.mongodb.com/docs/atlas/getting-started/) tutorial to learn more. Once you deploy a cluster, you can create a vector search index by using the index JSON editor.
Vector Search is available on Atlas, and as of 2024 is available in early access for Community Edition.

MongoDB offers a free forever cluster. See the [Get Started with Atlas](https://www.mongodb.com/docs/atlas/getting-started/) tutorial to learn more. Once you deploy a cluster, you can create a vector search index by using the index JSON editor. Alternatively, the LangChain4j `MongoDbEmbeddingStore` builder offers a `createIndex` option to automate index creation.

MongoDB also offers [Atlas CLI](https://www.mongodb.com/docs/atlas/cli/current/) for local development.

## Maven Dependency

Expand All @@ -34,6 +37,5 @@ To use Atlas Vector search, you need to have an Atlas deployment. MongoDB offers

## Examples

- [MongoDbEmbeddingStoreCloudIT](https://github.com/langchain4j/langchain4j/blob/main/langchain4j-mongodb-atlas/src/test/java/dev/langchain4j/store/embedding/mongodb/MongoDbEmbeddingStoreCloudIT.java)
- [MongoDbEmbeddingStoreLocalIT](https://github.com/langchain4j/langchain4j/blob/main/langchain4j-mongodb-atlas/src/test/java/dev/langchain4j/store/embedding/mongodb/MongoDbEmbeddingStoreLocalIT.java)
- [MongoDbEmbeddingStoreIT](https://github.com/langchain4j/langchain4j/blob/main/langchain4j-mongodb-atlas/src/test/java/dev/langchain4j/store/embedding/mongodb/MongoDbEmbeddingStoreIT.java)

2 changes: 1 addition & 1 deletion docs/docs/integrations/embedding-stores/neo4j.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 15
sidebar_position: 16
---

# Neo4j
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/embedding-stores/opensearch.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 16
sidebar_position: 17
---

# OpenSearch
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/embedding-stores/oracle.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 17
sidebar_position: 18
---

# Oracle
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/embedding-stores/pgvector.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 18
sidebar_position: 19
---

# PGVector
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/embedding-stores/pinecone.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 19
sidebar_position: 20
---

# Pinecone
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/embedding-stores/qdrant.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 20
sidebar_position: 21
---

# Qdrant
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/embedding-stores/redis.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 21
sidebar_position: 22
---

# Redis
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/embedding-stores/tablestore.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 22
sidebar_position: 23
---

# Tablestore
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/integrations/embedding-stores/vearch.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 23
sidebar_position: 24
---

# Vearch
Expand All @@ -10,7 +10,7 @@ https://github.com/vearch/vearch
## Maven Dependency

:::note
Since `0.37.0`, `langchain4j-vearch` has migrated to `langchain4j-community` and is renamed to `langchain4j-community-vearch
Since `0.37.0`, `langchain4j-vearch` has migrated to `langchain4j-community` and is renamed to `langchain4j-community-vearch`.
:::

`0.36.2` and previous:
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/embedding-stores/vespa.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 24
sidebar_position: 25
---

# Vespa
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/embedding-stores/weaviate.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 25
sidebar_position: 26
---

# Weaviate
Expand Down
Loading

0 comments on commit 548d979

Please sign in to comment.