Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
85 changes: 85 additions & 0 deletions vector-stores/spring-ai-opensearch-store/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>spring-ai-opensearch-store</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the spring-ai-opensearch-store dependency to the spring-bom

<packaging>jar</packaging>
<name>Spring AI Vector Store - OpenSearch</name>
<description>Spring AI OpenSearch Vector Store</description>
<url>https://github.com/spring-projects/spring-ai</url>

<scm>
<url>https://github.com/spring-projects/spring-ai</url>
<connection>git://github.com/spring-projects/spring-ai.git</connection>
<developerConnection>[email protected]:spring-projects/spring-ai.git</developerConnection>
</scm>

<properties>
<!-- testing -->
<hikari-cp.version>4.0.3</hikari-cp.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-core</artifactId>
<version>${parent.version}</version>
</dependency>

<dependency>
<groupId>org.opensearch.client</groupId>
<artifactId>opensearch-java</artifactId>
<version>2.9.1</version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving the version as a property in the parent POM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a commit to move the version to a property in the parent POM.

</dependency>

<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a test dependency only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<artifactId>httpclient5</artifactId>
<version>5.3.1</version>
</dependency>

<!-- TESTING -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-openai</artifactId>
<version>${parent.version}</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-test</artifactId>
<version>${parent.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.opensearch</groupId>
<artifactId>opensearch-testcontainers</artifactId>
<version>2.0.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/*
* Copyright 2023 - 2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ai.vectorstore;

import org.springframework.ai.vectorstore.filter.Filter;
import org.springframework.ai.vectorstore.filter.Filter.Expression;
import org.springframework.ai.vectorstore.filter.Filter.Key;
import org.springframework.ai.vectorstore.filter.converter.AbstractFilterExpressionConverter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import java.util.regex.Pattern;

/**
* @author Jemin Huh
* @since 1.0.0
*/
public class OpenSearchAiSearchFilterExpressionConverter extends AbstractFilterExpressionConverter {

private static final Pattern DATE_FORMAT_PATTERN = Pattern.compile("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z");

private final SimpleDateFormat dateFormat;

public OpenSearchAiSearchFilterExpressionConverter() {
this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
}

@Override
protected void doExpression(Expression expression, StringBuilder context) {
if (expression.type() == Filter.ExpressionType.IN || expression.type() == Filter.ExpressionType.NIN) {
context.append(getOperationSymbol(expression));
context.append("(");
this.convertOperand(expression.left(), context);
this.convertOperand(expression.right(), context);
context.append(")");
}
else {
this.convertOperand(expression.left(), context);
context.append(getOperationSymbol(expression));
this.convertOperand(expression.right(), context);
}
}

@Override
protected void doStartValueRange(Filter.Value listValue, StringBuilder context) {
}

@Override
protected void doEndValueRange(Filter.Value listValue, StringBuilder context) {
}

@Override
protected void doAddValueRangeSpitter(Filter.Value listValue, StringBuilder context) {
context.append(" OR ");
}

private String getOperationSymbol(Expression exp) {
return switch (exp.type()) {
case AND -> " AND ";
case OR -> " OR ";
case EQ, IN -> "";
case NE -> " NOT ";
case LT -> "<";
case LTE -> "<=";
case GT -> ">";
case GTE -> ">=";
case NIN -> "NOT ";
default -> throw new RuntimeException("Not supported expression type: " + exp.type());
};
}

@Override
public void doKey(Key key, StringBuilder context) {
var identifier = hasOuterQuotes(key.key()) ? removeOuterQuotes(key.key()) : key.key();
var prefixedIdentifier = withMetaPrefix(identifier);
context.append(prefixedIdentifier.trim()).append(":");
}

public String withMetaPrefix(String identifier) {
return "metadata." + identifier;
}

@Override
protected void doValue(Filter.Value filterValue, StringBuilder context) {
if (filterValue.value() instanceof List list) {
int c = 0;
for (Object v : list) {
context.append(v);
if (c++ < list.size() - 1) {
this.doAddValueRangeSpitter(filterValue, context);
}
}
}
else {
this.doSingleValue(filterValue.value(), context);
}
}

@Override
protected void doSingleValue(Object value, StringBuilder context) {
if (value instanceof Date date) {
context.append(this.dateFormat.format(date));
}
else if (value instanceof String text) {
if (DATE_FORMAT_PATTERN.matcher(text).matches()) {
try {
Date date = this.dateFormat.parse(text);
context.append(this.dateFormat.format(date));
}
catch (ParseException e) {
throw new IllegalArgumentException("Invalid date type:" + text, e);
}
}
else {
context.append(text);
}
}
else {
context.append(value);
}
}

@Override
public void doStartGroup(Filter.Group group, StringBuilder context) {
context.append("(");
}

@Override
public void doEndGroup(Filter.Group group, StringBuilder context) {
context.append(")");
}

}
Loading