build most modules with jdk 8 (#295)
Since we target java 8, CI build was updated to run most modules using java 8, then modules requiring java 11 separately with java 11
This commit is contained in:
parent
61e6a4bef0
commit
ff998ac82d
|
@ -7,14 +7,24 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK
|
||||
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'temurin'
|
||||
cache: 'maven'
|
||||
- name: Build with JDK 8 (excluding modules requiring JDK 11)
|
||||
run: mvn --batch-mode install -DskipITs -pl !langchain4j-opensearch
|
||||
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'adopt'
|
||||
- name: Test
|
||||
run: mvn --batch-mode test
|
||||
|
||||
distribution: 'temurin'
|
||||
cache: 'maven'
|
||||
- name: Build modules requiring JDK 11
|
||||
run: mvn --batch-mode install -DskipITs -pl langchain4j-opensearch
|
||||
|
||||
# For checking some compliance things (require a recent JDK due to plugins so in a separate step)
|
||||
compliance:
|
||||
|
@ -26,6 +36,7 @@ jobs:
|
|||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
cache: 'maven'
|
||||
# Check we only rely on permissive licenses in the main parts of the library:
|
||||
- name: License Compliance
|
||||
run: mvn -P compliance org.honton.chas:license-maven-plugin:compliance
|
||||
|
|
|
@ -1,34 +1,5 @@
|
|||
package dev.langchain4j.store.embedding.elasticsearch;
|
||||
|
||||
import static dev.langchain4j.internal.Utils.isCollectionEmpty;
|
||||
import static dev.langchain4j.internal.Utils.isNullOrBlank;
|
||||
import static dev.langchain4j.internal.Utils.randomUUID;
|
||||
import static dev.langchain4j.internal.ValidationUtils.ensureNotNull;
|
||||
import static dev.langchain4j.internal.ValidationUtils.ensureTrue;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.auth.AuthScope;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.http.client.CredentialsProvider;
|
||||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.elasticsearch.client.RestClient;
|
||||
import org.elasticsearch.client.RestClientBuilder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||
import co.elastic.clients.elasticsearch._types.InlineScript;
|
||||
import co.elastic.clients.elasticsearch._types.mapping.DenseVectorProperty;
|
||||
|
@ -48,11 +19,36 @@ import co.elastic.clients.json.jackson.JacksonJsonpMapper;
|
|||
import co.elastic.clients.transport.ElasticsearchTransport;
|
||||
import co.elastic.clients.transport.endpoints.BooleanResponse;
|
||||
import co.elastic.clients.transport.rest_client.RestClientTransport;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import dev.langchain4j.data.document.Metadata;
|
||||
import dev.langchain4j.data.embedding.Embedding;
|
||||
import dev.langchain4j.data.segment.TextSegment;
|
||||
import dev.langchain4j.store.embedding.EmbeddingMatch;
|
||||
import dev.langchain4j.store.embedding.EmbeddingStore;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.auth.AuthScope;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.http.client.CredentialsProvider;
|
||||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.elasticsearch.client.RestClient;
|
||||
import org.elasticsearch.client.RestClientBuilder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static dev.langchain4j.internal.Utils.*;
|
||||
import static dev.langchain4j.internal.ValidationUtils.ensureNotNull;
|
||||
import static dev.langchain4j.internal.ValidationUtils.ensureTrue;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
/**
|
||||
* Represents an <a href="https://www.elastic.co/">Elasticsearch</a> index as an embedding store.
|
||||
|
@ -103,9 +99,9 @@ public class ElasticsearchEmbeddingStore implements EmbeddingStore<TextSegment>
|
|||
this.objectMapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
public ElasticsearchEmbeddingStore(RestClient client, String indexName) {
|
||||
public ElasticsearchEmbeddingStore(RestClient restClient, String indexName) {
|
||||
JsonpMapper mapper = new JacksonJsonpMapper();
|
||||
ElasticsearchTransport transport = new RestClientTransport(client, mapper);
|
||||
ElasticsearchTransport transport = new RestClientTransport(restClient, mapper);
|
||||
|
||||
this.client = new ElasticsearchClient(transport);
|
||||
this.indexName = ensureNotNull(indexName, "indexName");
|
||||
|
@ -122,11 +118,12 @@ public class ElasticsearchEmbeddingStore implements EmbeddingStore<TextSegment>
|
|||
private String apiKey;
|
||||
private String userName;
|
||||
private String password;
|
||||
private RestClient client;
|
||||
private RestClient restClient;
|
||||
private String indexName = "default";
|
||||
|
||||
/**
|
||||
* @param serverUrl Elasticsearch Server URL
|
||||
* @return builder
|
||||
*/
|
||||
public Builder serverUrl(String serverUrl) {
|
||||
this.serverUrl = serverUrl;
|
||||
|
@ -162,16 +159,18 @@ public class ElasticsearchEmbeddingStore implements EmbeddingStore<TextSegment>
|
|||
|
||||
/**
|
||||
* @param restClient Elasticsearch RestClient (optional).
|
||||
* Effectively overrides all other connection parameters serverUrl, etc.
|
||||
* Effectively overrides all other connection parameters like serverUrl, etc.
|
||||
* @return builder
|
||||
*/
|
||||
public Builder restClient(RestClient client) {
|
||||
this.client = client;
|
||||
public Builder restClient(RestClient restClient) {
|
||||
this.restClient = restClient;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param indexName Elasticsearch index name (optional).
|
||||
* Default value: "default".
|
||||
* @return builder
|
||||
*/
|
||||
public Builder indexName(String indexName) {
|
||||
this.indexName = indexName;
|
||||
|
@ -179,8 +178,8 @@ public class ElasticsearchEmbeddingStore implements EmbeddingStore<TextSegment>
|
|||
}
|
||||
|
||||
public ElasticsearchEmbeddingStore build() {
|
||||
if (client != null) {
|
||||
return new ElasticsearchEmbeddingStore(client, indexName);
|
||||
if (restClient != null) {
|
||||
return new ElasticsearchEmbeddingStore(restClient, indexName);
|
||||
} else {
|
||||
return new ElasticsearchEmbeddingStore(serverUrl, apiKey, userName, password, indexName);
|
||||
}
|
||||
|
|
|
@ -200,12 +200,6 @@
|
|||
<version>${spring-boot.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5</artifactId>
|
||||
|
|
Loading…
Reference in New Issue