Skip to content

add support for OpenSearch vector store #508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
e655a36
add support for OpenSearch vector store
JM-Lab Mar 25, 2024
b15b308
moving versions for OpenSearch as a property in the parent POM
JM-Lab Apr 4, 2024
1701ca1
Merge branch 'spring-projects:main' into opensearch-vector-store
JM-Lab Apr 4, 2024
f08c8a7
Merge branch 'spring-projects:main' into opensearch-vector-store
JM-Lab Apr 14, 2024
7b77b19
Add mappingJson parameter to OpenSearchVectorStore
JM-Lab Apr 14, 2024
9c252bc
Add opensearch auto-configuration and boot starter
JM-Lab Apr 14, 2024
4230038
Remove unused ChatMessage class
markpollack Apr 17, 2024
f698902
doc: Add top page about API multimodality suppot
tzolov Apr 19, 2024
0eaf7d0
Cassandra Vector Store initial impl follow up
michaelsembwever Apr 10, 2024
df92dff
Fix OpenAI audio options merging order
tzolov Apr 19, 2024
2cdd9b5
Add (Streaming)ChatClient convinience defaults
tzolov Apr 20, 2024
be6081f
fix: rename call to stream
tzolov Apr 20, 2024
6178b3d
Fix CassandraVectorStoreConfig logger name
omarmahamid Apr 11, 2024
8c04b05
Add support for AWS bedrock claude3 opus model support
Apr 16, 2024
d3f2a8f
Fix bean name conflicts when using BedrockAnthropic and BedrockAnthro…
Apr 19, 2024
8fa688f
Update qdrant.adoc
hygl Apr 12, 2024
3b79a1a
Add documentation for Elasticsearch VectorStore.
Vrryou Mar 27, 2024
9fbc09a
Replace manual bean configuration with application.yml configuration.
Vrryou Mar 30, 2024
e9d7398
Rewrite Elasticsearch documentation to follow Neo4J's format.
Vrryou Apr 16, 2024
65e6880
doc: add elasticsearch to nav catalog
tzolov Apr 20, 2024
563f9b4
Bedrock client autoconfiguration support external AwsCredentialsProvi…
Apr 16, 2024
b21427c
Fix erroneous references to OpenAI
thesurlydev Apr 22, 2024
9aa97b5
fix wrong document code examples
jiacheo Apr 22, 2024
b0add71
Fix CassandraVectorStoreAutoConfiguration's @ConditionalOnClass to no…
michaelsembwever Apr 22, 2024
9e865f0
Add Bedrock Meta LLama3 AI model support.
Apr 23, 2024
6b9f8d3
Implement a function, not functions
danvega Apr 25, 2024
a5923f5
Fix sample in "Manual Configuration" section of OpenAI Embeddings API
izeye Apr 25, 2024
db6f7cd
Update AzureVectorStore.java
eltociear Apr 15, 2024
773b7bd
PgVectorStore: creating an index only if missing
iAMSagar44 Apr 22, 2024
7e03a15
Mistral AI streaming function API change fix
tzolov Apr 26, 2024
5f9ecdd
Fixing Log probability information
ricken07 Apr 9, 2024
a50969e
Bedrock Titan embedding client adds BedrockTitanEmbeddingOptions to s…
Apr 22, 2024
daf131b
Fix column creation, when adding additional normal and embedding colu…
michaelsembwever Apr 24, 2024
6fd3df0
add support for OpenSearch vector store
JM-Lab Mar 25, 2024
d30e989
moving versions for OpenSearch as a property in the parent POM
JM-Lab Apr 4, 2024
6f24154
Add mappingJson parameter to OpenSearchVectorStore
JM-Lab Apr 14, 2024
f5d9d70
Add opensearch auto-configuration and boot starter
JM-Lab Apr 14, 2024
7e1c1cc
Merge branch 'opensearch-vector-store' of https://github.com/JM-Lab/s…
JM-Lab Apr 28, 2024
3d07101
Add additional properties for OpenSearch auto-configuration
JM-Lab Apr 28, 2024
639073e
Update Docker version for OpenSearchVectorStoreIT and opensearch-clie…
JM-Lab Apr 28, 2024
4c6876b
add support for OpenSearch vector store
JM-Lab Mar 25, 2024
dce8b80
moving versions for OpenSearch as a property in the parent POM
JM-Lab Apr 4, 2024
bd1ac01
Add mappingJson parameter to OpenSearchVectorStore
JM-Lab Apr 14, 2024
b05d9b7
Add opensearch auto-configuration and boot starter
JM-Lab Apr 14, 2024
7bb833e
add support for OpenSearch vector store
JM-Lab Mar 25, 2024
13c504e
moving versions for OpenSearch as a property in the parent POM
JM-Lab Apr 4, 2024
f6e5537
Add mappingJson parameter to OpenSearchVectorStore
JM-Lab Apr 14, 2024
ac61b82
Add additional properties for OpenSearch auto-configuration
JM-Lab Apr 28, 2024
a8cad11
Update Docker version for OpenSearchVectorStoreIT and opensearch-clie…
JM-Lab Apr 28, 2024
1a9d6de
Merge branch 'opensearch-vector-store' of https://github.com/JM-Lab/s…
JM-Lab Apr 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ You can find more details in the [Reference Documentation](https://docs.spring.i
Spring AI supports many AI models. For an overview see here. Specific models currently supported are
* OpenAI
* Azure OpenAI
* Amazon Bedrock (Anthropic, Llama2, Cohere, Titan, Jurassic2)
* Amazon Bedrock (Anthropic, Llama, Cohere, Titan, Jurassic2)
* HuggingFace
* Google VertexAI (PaLM2, Gemini)
* Mistral AI
Expand Down
2 changes: 1 addition & 1 deletion models/spring-ai-bedrock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- [Anthropic2 Chat Documentation](https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/api/chat/bedrock/bedrock-anthropic.html)
- [Cohere Chat Documentation](https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/api/chat/bedrock/bedrock-cohere.html)
- [Cohere Embedding Documentation](https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/api/embeddings/bedrock-cohere-embedding.html)
- [Llama2 Chat Documentation](https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/api/chat/bedrock/bedrock-llama2.html)
- [Llama Chat Documentation](https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/api/chat/bedrock/bedrock-llama.html)
- [Titan Chat Documentation](https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/api/chat/bedrock/bedrock-titan.html)
- [Titan Embedding Documentation](https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/api/embeddings/bedrock-titan-embedding.html)
- [Jurassic2 Chat Documentation](https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/api/chat/bedrock/bedrock-jurassic2.html)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import reactor.core.publisher.Flux;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.regions.Region;

import org.springframework.ai.bedrock.anthropic.api.AnthropicChatBedrockApi.AnthropicChatRequest;
import org.springframework.ai.bedrock.anthropic.api.AnthropicChatBedrockApi.AnthropicChatResponse;
Expand All @@ -32,6 +33,7 @@

/**
* @author Christian Tzolov
* @author Wei Jiang
* @since 0.8.0
*/
// @formatter:off
Expand Down Expand Up @@ -92,6 +94,20 @@ public AnthropicChatBedrockApi(String modelId, AwsCredentialsProvider credential
super(modelId, credentialsProvider, region, objectMapper, timeout);
}

/**
* Create a new AnthropicChatBedrockApi instance using the provided credentials provider, region and object mapper.
*
* @param modelId The model id to use. See the {@link AnthropicChatModel} for the supported models.
* @param credentialsProvider The credentials provider to connect to AWS.
* @param region The AWS region to use.
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
* @param timeout The timeout to use.
*/
public AnthropicChatBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, Region region,
ObjectMapper objectMapper, Duration timeout) {
super(modelId, credentialsProvider, region, objectMapper, timeout);
}

// https://github.com/build-on-aws/amazon-bedrock-java-examples/blob/main/example_code/bedrock-runtime/src/main/java/aws/community/examples/InvokeBedrockStreamingAsync.java

// https://docs.anthropic.com/claude/reference/complete_post
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.springframework.util.Assert;
import reactor.core.publisher.Flux;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.regions.Region;

import java.time.Duration;
import java.util.List;
Expand All @@ -39,6 +40,7 @@
*
* @author Ben Middleton
* @author Christian Tzolov
* @author Wei Jiang
* @since 1.0.0
*/
// @formatter:off
Expand Down Expand Up @@ -96,6 +98,20 @@ public Anthropic3ChatBedrockApi(String modelId, AwsCredentialsProvider credentia
super(modelId, credentialsProvider, region, objectMapper, timeout);
}

/**
* Create a new AnthropicChatBedrockApi instance using the provided credentials provider, region and object mapper.
*
* @param modelId The model id to use. See the {@link AnthropicChatModel} for the supported models.
* @param credentialsProvider The credentials provider to connect to AWS.
* @param region The AWS region to use.
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
* @param timeout The timeout to use.
*/
public Anthropic3ChatBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, Region region,
ObjectMapper objectMapper, Duration timeout) {
super(modelId, credentialsProvider, region, objectMapper, timeout);
}

// https://github.com/build-on-aws/amazon-bedrock-java-examples/blob/main/example_code/bedrock-runtime/src/main/java/aws/community/examples/InvokeBedrockStreamingAsync.java

// https://docs.anthropic.com/claude/reference/complete_post
Expand Down Expand Up @@ -441,7 +457,11 @@ public enum AnthropicChatModel {
/**
* anthropic.claude-3-haiku-20240307-v1:0
*/
CLAUDE_V3_HAIKU("anthropic.claude-3-haiku-20240307-v1:0");
CLAUDE_V3_HAIKU("anthropic.claude-3-haiku-20240307-v1:0"),
/**
* anthropic.claude-3-opus-20240229-v1:0
*/
CLAUDE_V3_OPUS("anthropic.claude-3-opus-20240229-v1:0");

private final String id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
import org.springframework.ai.bedrock.cohere.api.CohereChatBedrockApi;
import org.springframework.ai.bedrock.cohere.api.CohereEmbeddingBedrockApi;
import org.springframework.ai.bedrock.jurassic2.api.Ai21Jurassic2ChatBedrockApi;
import org.springframework.ai.bedrock.llama2.BedrockLlama2ChatOptions;
import org.springframework.ai.bedrock.llama2.api.Llama2ChatBedrockApi;
import org.springframework.ai.bedrock.llama.BedrockLlamaChatOptions;
import org.springframework.ai.bedrock.llama.api.LlamaChatBedrockApi;
import org.springframework.ai.bedrock.titan.BedrockTitanChatOptions;
import org.springframework.ai.bedrock.titan.BedrockTitanEmbeddingOptions;
import org.springframework.ai.bedrock.titan.api.TitanChatBedrockApi;
import org.springframework.ai.bedrock.titan.api.TitanEmbeddingBedrockApi;
import org.springframework.aot.hint.MemberCategory;
Expand All @@ -43,6 +44,7 @@
* @author Josh Long
* @author Christian Tzolov
* @author Mark Pollack
* @author Wei Jiang
*/
public class BedrockRuntimeHints implements RuntimeHintsRegistrar {

Expand All @@ -63,15 +65,17 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
for (var tr : findJsonAnnotatedClassesInPackage(BedrockCohereEmbeddingOptions.class))
hints.reflection().registerType(tr, mcs);

for (var tr : findJsonAnnotatedClassesInPackage(Llama2ChatBedrockApi.class))
for (var tr : findJsonAnnotatedClassesInPackage(LlamaChatBedrockApi.class))
hints.reflection().registerType(tr, mcs);
for (var tr : findJsonAnnotatedClassesInPackage(BedrockLlama2ChatOptions.class))
for (var tr : findJsonAnnotatedClassesInPackage(BedrockLlamaChatOptions.class))
hints.reflection().registerType(tr, mcs);

for (var tr : findJsonAnnotatedClassesInPackage(TitanChatBedrockApi.class))
hints.reflection().registerType(tr, mcs);
for (var tr : findJsonAnnotatedClassesInPackage(BedrockTitanChatOptions.class))
hints.reflection().registerType(tr, mcs);
for (var tr : findJsonAnnotatedClassesInPackage(BedrockTitanEmbeddingOptions.class))
hints.reflection().registerType(tr, mcs);
for (var tr : findJsonAnnotatedClassesInPackage(TitanEmbeddingBedrockApi.class))
hints.reflection().registerType(tr, mcs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
* @see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html">Model Parameters</a>

* @author Christian Tzolov
* @author Wei Jiang
* @since 0.8.0
*/
public abstract class AbstractBedrockApi<I, O, SO> {
Expand All @@ -69,7 +70,7 @@ public abstract class AbstractBedrockApi<I, O, SO> {

private final String modelId;
private final ObjectMapper objectMapper;
private final String region;
private final Region region;
private final BedrockRuntimeClient client;
private final BedrockRuntimeAsyncClient clientStreaming;

Expand All @@ -93,7 +94,7 @@ public AbstractBedrockApi(String modelId, String region, Duration timeout) {
this(modelId, ProfileCredentialsProvider.builder().build(), region, ModelOptionsUtils.OBJECT_MAPPER, timeout);
}

/**
/**
* Create a new AbstractBedrockApi instance using the provided credentials provider, region and object mapper.
*
* @param modelId The model id to use.
Expand All @@ -105,6 +106,7 @@ public AbstractBedrockApi(String modelId, AwsCredentialsProvider credentialsProv
ObjectMapper objectMapper) {
this(modelId, credentialsProvider, region, objectMapper, Duration.ofMinutes(5));
}

/**
* Create a new AbstractBedrockApi instance using the provided credentials provider, region and object mapper.
*
Expand All @@ -118,10 +120,26 @@ public AbstractBedrockApi(String modelId, AwsCredentialsProvider credentialsProv
*/
public AbstractBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, String region,
ObjectMapper objectMapper, Duration timeout) {
this(modelId, credentialsProvider, Region.of(region), objectMapper, timeout);
}

/**
* Create a new AbstractBedrockApi instance using the provided credentials provider, region and object mapper.
*
* @param modelId The model id to use.
* @param credentialsProvider The credentials provider to connect to AWS.
* @param region The AWS region to use.
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
* @param timeout Configure the amount of time to allow the client to complete the execution of an API call.
* This timeout covers the entire client execution except for marshalling. This includes request handler execution,
* all HTTP requests including retries, unmarshalling, etc. This value should always be positive, if present.
*/
public AbstractBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, Region region,
ObjectMapper objectMapper, Duration timeout) {

Assert.hasText(modelId, "Model id must not be empty");
Assert.notNull(credentialsProvider, "Credentials provider must not be null");
Assert.hasText(region, "Region must not be empty");
Assert.notNull(region, "Region must not be empty");
Assert.notNull(objectMapper, "Object mapper must not be null");
Assert.notNull(timeout, "Timeout must not be null");

Expand All @@ -131,13 +149,13 @@ public AbstractBedrockApi(String modelId, AwsCredentialsProvider credentialsProv


this.client = BedrockRuntimeClient.builder()
.region(Region.of(this.region))
.region(this.region)
.credentialsProvider(credentialsProvider)
.overrideConfiguration(c -> c.apiCallTimeout(timeout))
.build();

this.clientStreaming = BedrockRuntimeAsyncClient.builder()
.region(Region.of(this.region))
.region(this.region)
.credentialsProvider(credentialsProvider)
.overrideConfiguration(c -> c.apiCallTimeout(timeout))
.build();
Expand All @@ -153,7 +171,7 @@ public String getModelId() {
/**
* @return The AWS region.
*/
public String getRegion() {
public Region getRegion() {
return this.region;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import reactor.core.publisher.Flux;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.regions.Region;

import org.springframework.ai.bedrock.api.AbstractBedrockApi;
import org.springframework.ai.bedrock.cohere.api.CohereChatBedrockApi.CohereChatRequest;
Expand All @@ -36,6 +37,7 @@
* https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-cohere.html
*
* @author Christian Tzolov
* @author Wei Jiang
* @since 0.8.0
*/
public class CohereChatBedrockApi extends
Expand Down Expand Up @@ -91,6 +93,20 @@ public CohereChatBedrockApi(String modelId, AwsCredentialsProvider credentialsPr
super(modelId, credentialsProvider, region, objectMapper, timeout);
}

/**
* Create a new CohereChatBedrockApi instance using the provided credentials provider, region and object mapper.
*
* @param modelId The model id to use. See the {@link CohereChatModel} for the supported models.
* @param credentialsProvider The credentials provider to connect to AWS.
* @param region The AWS region to use.
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
* @param timeout The timeout to use.
*/
public CohereChatBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, Region region,
ObjectMapper objectMapper, Duration timeout) {
super(modelId, credentialsProvider, region, objectMapper, timeout);
}

/**
* CohereChatRequest encapsulates the request parameters for the Cohere command model.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.regions.Region;

import org.springframework.ai.bedrock.api.AbstractBedrockApi;
import org.springframework.ai.bedrock.cohere.api.CohereEmbeddingBedrockApi.CohereEmbeddingRequest;
Expand All @@ -34,6 +35,7 @@
* https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-cohere.html#model-parameters-embed
*
* @author Christian Tzolov
* @author Wei Jiang
* @since 0.8.0
*/
public class CohereEmbeddingBedrockApi extends
Expand Down Expand Up @@ -91,6 +93,21 @@ public CohereEmbeddingBedrockApi(String modelId, AwsCredentialsProvider credenti
super(modelId, credentialsProvider, region, objectMapper, timeout);
}

/**
* Create a new CohereEmbeddingBedrockApi instance using the provided credentials provider, region and object
* mapper.
*
* @param modelId The model id to use. See the {@link CohereEmbeddingModel} for the supported models.
* @param credentialsProvider The credentials provider to connect to AWS.
* @param region The AWS region to use.
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
* @param timeout The timeout to use.
*/
public CohereEmbeddingBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, Region region,
ObjectMapper objectMapper, Duration timeout) {
super(modelId, credentialsProvider, region, objectMapper, timeout);
}

/**
* The Cohere Embed model request.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
import org.springframework.ai.bedrock.jurassic2.api.Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatResponse;

import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.regions.Region;

/**
* Java client for the Bedrock Jurassic2 chat model.
* https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-jurassic2.html
*
* @author Christian Tzolov
* @author Wei Jiang
* @since 0.8.0
*/
public class Ai21Jurassic2ChatBedrockApi extends
Expand Down Expand Up @@ -92,6 +94,20 @@ public Ai21Jurassic2ChatBedrockApi(String modelId, AwsCredentialsProvider creden
super(modelId, credentialsProvider, region, objectMapper, timeout);
}

/**
* Create a new Ai21Jurassic2ChatBedrockApi instance.
*
* @param modelId The model id to use. See the {@link Ai21Jurassic2ChatBedrockApi.Ai21Jurassic2ChatModel} for the supported models.
* @param credentialsProvider The credentials provider to connect to AWS.
* @param region The AWS region to use.
* @param objectMapper The object mapper to use for JSON serialization and deserialization.
* @param timeout The timeout to use.
*/
public Ai21Jurassic2ChatBedrockApi(String modelId, AwsCredentialsProvider credentialsProvider, Region region,
ObjectMapper objectMapper, Duration timeout) {
super(modelId, credentialsProvider, region, objectMapper, timeout);
}

/**
* AI21 Jurassic2 chat request parameters.
*
Expand Down
Loading