small code improvements/clean-ups, deleted unused method 'withEmbedding' from SimpleVectorStoreContent class
Signed-off-by: pavel <ppetrashov.dev@gmail.com>
This commit is contained in:
committed by
Ilayaperumal Gopinathan
parent
29fde4f7f1
commit
608b29cf93
@@ -17,7 +17,6 @@
|
||||
package org.springframework.ai.vectorstore;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -100,7 +99,7 @@ public final class SimpleVectorStoreContent implements Content {
|
||||
|
||||
this.id = id;
|
||||
this.text = text;
|
||||
this.metadata = Collections.unmodifiableMap(new HashMap<>(metadata));
|
||||
this.metadata = Map.copyOf(metadata);
|
||||
this.embedding = Arrays.copyOf(embedding, embedding.length);
|
||||
}
|
||||
|
||||
@@ -110,6 +109,7 @@ public final class SimpleVectorStoreContent implements Content {
|
||||
* @return a new instance with the updated embedding
|
||||
* @throws IllegalArgumentException if embedding is null or empty
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.0.0-M7")
|
||||
public SimpleVectorStoreContent withEmbedding(float[] embedding) {
|
||||
Assert.notNull(embedding, "embedding must not be null");
|
||||
Assert.isTrue(embedding.length > 0, "embedding vector must not be empty");
|
||||
|
||||
@@ -49,7 +49,8 @@ import org.springframework.ai.vectorstore.filter.Filter.Value;
|
||||
* }</pre>
|
||||
*
|
||||
*
|
||||
* This builder DSL mimics the common https://www.baeldung.com/hibernate-criteria-queries
|
||||
* This builder DSL mimics the common
|
||||
* <a href="https://www.baeldung.com/hibernate-criteria-queries">Criteria Queries</a>
|
||||
* syntax.
|
||||
*
|
||||
* @author Christian Tzolov
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.antlr.v4.runtime.ANTLRErrorStrategy;
|
||||
import org.antlr.v4.runtime.BailErrorStrategy;
|
||||
@@ -46,7 +45,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* The vector-store agnostic, filter expression language is defined by a formal ANTLR4
|
||||
* grammar (Filters.g4). The language looks and feels like a subset of the well known SQL
|
||||
* WHERE filter expressions. For example you can use the parser like this:
|
||||
* WHERE filter expressions. For example, you can use the parser like this:
|
||||
*
|
||||
* <pre>{@code
|
||||
*
|
||||
@@ -151,7 +150,7 @@ public class FilterExpressionTextParser {
|
||||
return filterExpression;
|
||||
}
|
||||
catch (ParseCancellationException e) {
|
||||
var msg = this.errorListener.errorMessages.stream().collect(Collectors.joining());
|
||||
var msg = String.join("", this.errorListener.errorMessages);
|
||||
var rootCause = NestedExceptionUtils.getRootCause(e);
|
||||
throw new FilterExpressionParseException(msg, rootCause);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.ai.vectorstore.filter.Filter.Key;
|
||||
|
||||
/**
|
||||
* Converts {@link Expression} into Pinecone metadata filter expression format.
|
||||
* (https://docs.pinecone.io/docs/metadata-filtering)
|
||||
* (<a href="https://docs.pinecone.io/docs/metadata-filtering">Metadata filtering</a>)
|
||||
*
|
||||
* @author Christian Tzolov
|
||||
*/
|
||||
@@ -58,7 +58,7 @@ public class PineconeFilterExpressionConverter extends AbstractFilterExpressionC
|
||||
@Override
|
||||
protected void doKey(Key key, StringBuilder context) {
|
||||
var identifier = (hasOuterQuotes(key.key())) ? removeOuterQuotes(key.key()) : key.key();
|
||||
context.append("\"" + identifier + "\": ");
|
||||
context.append("\"").append(identifier).append("\": ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class PrintFilterExpressionConverter extends AbstractFilterExpressionConv
|
||||
|
||||
public void doExpression(Expression expression, StringBuilder context) {
|
||||
this.convertOperand(expression.left(), context);
|
||||
context.append(" " + expression.type() + " ");
|
||||
context.append(" ").append(expression.type()).append(" ");
|
||||
this.convertOperand(expression.right(), context);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user