removed experimental annotations, added deprecations
This commit is contained in:
parent
c27c127912
commit
2a4576f1ed
|
@ -76,8 +76,11 @@ public class Document {
|
|||
*
|
||||
* @param key the key to look up.
|
||||
* @return the metadata value for the given key, or null if the key is not present.
|
||||
* @deprecated as of 0.31.0, use {@link #metadata()} and then {@link Metadata#getString(String)},
|
||||
* {@link Metadata#getInteger(String)}, {@link Metadata#getLong(String)}, {@link Metadata#getFloat(String)},
|
||||
* {@link Metadata#getDouble(String)} instead.
|
||||
*/
|
||||
// TODO deprecate once the new experimental API is settled
|
||||
@Deprecated
|
||||
public String metadata(String key) {
|
||||
return metadata.get(key);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.langchain4j.data.document;
|
||||
|
||||
import dev.langchain4j.Experimental;
|
||||
import dev.langchain4j.data.segment.TextSegment;
|
||||
import dev.langchain4j.store.embedding.EmbeddingStore;
|
||||
|
||||
|
@ -84,8 +83,10 @@ public class Metadata {
|
|||
*
|
||||
* @param key the key
|
||||
* @return the value associated with the given key, or {@code null} if the key is not present.
|
||||
* @deprecated as of 0.31.0, use {@link #getString(String)}, {@link #getInteger(String)}, {@link #getLong(String)},
|
||||
* {@link #getFloat(String)}, {@link #getDouble(String)} instead.
|
||||
*/
|
||||
// TODO deprecate once the new experimental API is settled
|
||||
@Deprecated
|
||||
public String get(String key) {
|
||||
Object value = metadata.get(key);
|
||||
if (value != null) {
|
||||
|
@ -102,7 +103,6 @@ public class Metadata {
|
|||
* @return the {@code String} value associated with the given key, or {@code null} if the key is not present.
|
||||
* @throws RuntimeException if the value is not of type String
|
||||
*/
|
||||
@Experimental
|
||||
public String getString(String key) {
|
||||
if (!containsKey(key)) {
|
||||
return null;
|
||||
|
@ -133,7 +133,6 @@ public class Metadata {
|
|||
* @return the {@link Integer} value associated with the given key, or {@code null} if the key is not present.
|
||||
* @throws RuntimeException if the value is not {@link Number}
|
||||
*/
|
||||
@Experimental
|
||||
public Integer getInteger(String key) {
|
||||
if (!containsKey(key)) {
|
||||
return null;
|
||||
|
@ -166,7 +165,6 @@ public class Metadata {
|
|||
* @return the {@code Long} value associated with the given key, or {@code null} if the key is not present.
|
||||
* @throws RuntimeException if the value is not {@link Number}
|
||||
*/
|
||||
@Experimental
|
||||
public Long getLong(String key) {
|
||||
if (!containsKey(key)) {
|
||||
return null;
|
||||
|
@ -199,7 +197,6 @@ public class Metadata {
|
|||
* @return the {@code Float} value associated with the given key, or {@code null} if the key is not present.
|
||||
* @throws RuntimeException if the value is not {@link Number}
|
||||
*/
|
||||
@Experimental
|
||||
public Float getFloat(String key) {
|
||||
if (!containsKey(key)) {
|
||||
return null;
|
||||
|
@ -232,7 +229,6 @@ public class Metadata {
|
|||
* @return the {@code Double} value associated with the given key, or {@code null} if the key is not present.
|
||||
* @throws RuntimeException if the value is not {@link Number}
|
||||
*/
|
||||
@Experimental
|
||||
public Double getDouble(String key) {
|
||||
if (!containsKey(key)) {
|
||||
return null;
|
||||
|
@ -255,7 +251,6 @@ public class Metadata {
|
|||
* @param key the key
|
||||
* @return {@code true} if this metadata contains a given key; {@code false} otherwise.
|
||||
*/
|
||||
@Experimental
|
||||
public boolean containsKey(String key) {
|
||||
return metadata.containsKey(key);
|
||||
}
|
||||
|
@ -266,8 +261,10 @@ public class Metadata {
|
|||
* @param key the key
|
||||
* @param value the value
|
||||
* @return {@code this}
|
||||
* @deprecated as of 0.31.0, use {@link #put(String, String)}, {@link #put(String, int)}, {@link #put(String, long)},
|
||||
* {@link #put(String, float)}, {@link #put(String, double)} instead.
|
||||
*/
|
||||
// TODO deprecate once the new experimental API is settled
|
||||
@Deprecated
|
||||
public Metadata add(String key, Object value) {
|
||||
return put(key, value.toString());
|
||||
}
|
||||
|
@ -278,8 +275,10 @@ public class Metadata {
|
|||
* @param key the key
|
||||
* @param value the value
|
||||
* @return {@code this}
|
||||
* @deprecated as of 0.31.0, use {@link #put(String, String)}, {@link #put(String, int)}, {@link #put(String, long)},
|
||||
* {@link #put(String, float)}, {@link #put(String, double)} instead.
|
||||
*/
|
||||
// TODO deprecate once the new experimental API is settled
|
||||
@Deprecated
|
||||
public Metadata add(String key, String value) {
|
||||
validate(key, value);
|
||||
this.metadata.put(key, value);
|
||||
|
@ -293,7 +292,6 @@ public class Metadata {
|
|||
* @param value the value
|
||||
* @return {@code this}
|
||||
*/
|
||||
@Experimental
|
||||
public Metadata put(String key, String value) {
|
||||
validate(key, value);
|
||||
this.metadata.put(key, value);
|
||||
|
@ -307,7 +305,6 @@ public class Metadata {
|
|||
* @param value the value
|
||||
* @return {@code this}
|
||||
*/
|
||||
@Experimental
|
||||
public Metadata put(String key, int value) {
|
||||
validate(key, value);
|
||||
this.metadata.put(key, value);
|
||||
|
@ -321,7 +318,6 @@ public class Metadata {
|
|||
* @param value the value
|
||||
* @return {@code this}
|
||||
*/
|
||||
@Experimental
|
||||
public Metadata put(String key, long value) {
|
||||
validate(key, value);
|
||||
this.metadata.put(key, value);
|
||||
|
@ -335,7 +331,6 @@ public class Metadata {
|
|||
* @param value the value
|
||||
* @return {@code this}
|
||||
*/
|
||||
@Experimental
|
||||
public Metadata put(String key, float value) {
|
||||
validate(key, value);
|
||||
this.metadata.put(key, value);
|
||||
|
@ -349,7 +344,6 @@ public class Metadata {
|
|||
* @param value the value
|
||||
* @return {@code this}
|
||||
*/
|
||||
@Experimental
|
||||
public Metadata put(String key, double value) {
|
||||
validate(key, value);
|
||||
this.metadata.put(key, value);
|
||||
|
@ -380,8 +374,9 @@ public class Metadata {
|
|||
* Get a copy of the metadata as a map of key-value pairs.
|
||||
*
|
||||
* @return the metadata as a map of key-value pairs.
|
||||
* @deprecated as of 0.31.0, use {@link #toMap()} instead.
|
||||
*/
|
||||
// TODO deprecate once the new experimental API is settled
|
||||
@Deprecated
|
||||
public Map<String, String> asMap() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (Map.Entry<String, Object> entry : metadata.entrySet()) {
|
||||
|
@ -395,7 +390,6 @@ public class Metadata {
|
|||
*
|
||||
* @return the metadata as a map of key-value pairs.
|
||||
*/
|
||||
@Experimental
|
||||
public Map<String, Object> toMap() {
|
||||
return new HashMap<>(metadata);
|
||||
}
|
||||
|
|
|
@ -53,8 +53,11 @@ public class TextSegment {
|
|||
*
|
||||
* @param key the key.
|
||||
* @return the metadata value, or null if not found.
|
||||
* @deprecated as of 0.31.0, use {@link #metadata()} and then {@link Metadata#getString(String)},
|
||||
* {@link Metadata#getInteger(String)}, {@link Metadata#getLong(String)}, {@link Metadata#getFloat(String)},
|
||||
* {@link Metadata#getDouble(String)} instead.
|
||||
*/
|
||||
// TODO deprecate once the new experimental API is settled
|
||||
@Deprecated
|
||||
public String metadata(String key) {
|
||||
return metadata.get(key);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.langchain4j.store.embedding;
|
||||
|
||||
import dev.langchain4j.Experimental;
|
||||
import dev.langchain4j.data.document.Metadata;
|
||||
import dev.langchain4j.data.embedding.Embedding;
|
||||
import dev.langchain4j.data.segment.TextSegment;
|
||||
|
@ -15,7 +14,6 @@ import static dev.langchain4j.internal.ValidationUtils.*;
|
|||
/**
|
||||
* Represents a request to search in an {@link EmbeddingStore}.
|
||||
*/
|
||||
@Experimental
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public class EmbeddingSearchRequest {
|
||||
|
@ -41,7 +39,6 @@ public class EmbeddingSearchRequest {
|
|||
* This is an optional parameter. Default: no filtering
|
||||
*/
|
||||
@Builder
|
||||
@Experimental
|
||||
public EmbeddingSearchRequest(Embedding queryEmbedding, Integer maxResults, Double minScore, Filter filter) {
|
||||
this.queryEmbedding = ensureNotNull(queryEmbedding, "queryEmbedding");
|
||||
this.maxResults = ensureGreaterThanZero(getOrDefault(maxResults, 3), "maxResults");
|
||||
|
@ -49,22 +46,18 @@ public class EmbeddingSearchRequest {
|
|||
this.filter = filter;
|
||||
}
|
||||
|
||||
@Experimental
|
||||
public Embedding queryEmbedding() {
|
||||
return queryEmbedding;
|
||||
}
|
||||
|
||||
@Experimental
|
||||
public int maxResults() {
|
||||
return maxResults;
|
||||
}
|
||||
|
||||
@Experimental
|
||||
public double minScore() {
|
||||
return minScore;
|
||||
}
|
||||
|
||||
@Experimental
|
||||
public Filter filter() {
|
||||
return filter;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package dev.langchain4j.store.embedding;
|
||||
|
||||
import dev.langchain4j.Experimental;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static dev.langchain4j.internal.ValidationUtils.ensureNotNull;
|
||||
|
@ -9,17 +7,14 @@ import static dev.langchain4j.internal.ValidationUtils.ensureNotNull;
|
|||
/**
|
||||
* Represents a result of a search in an {@link EmbeddingStore}.
|
||||
*/
|
||||
@Experimental
|
||||
public class EmbeddingSearchResult<Embedded> {
|
||||
|
||||
private final List<EmbeddingMatch<Embedded>> matches;
|
||||
|
||||
@Experimental
|
||||
public EmbeddingSearchResult(List<EmbeddingMatch<Embedded>> matches) {
|
||||
this.matches = ensureNotNull(matches, "matches");
|
||||
}
|
||||
|
||||
@Experimental
|
||||
public List<EmbeddingMatch<Embedded>> matches() {
|
||||
return matches;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.langchain4j.store.embedding;
|
||||
|
||||
import dev.langchain4j.Experimental;
|
||||
import dev.langchain4j.data.embedding.Embedding;
|
||||
import dev.langchain4j.store.embedding.filter.Filter;
|
||||
|
||||
|
@ -66,7 +65,6 @@ public interface EmbeddingStore<Embedded> {
|
|||
* @param request A request to search in an {@link EmbeddingStore}. Contains all search criteria.
|
||||
* @return An {@link EmbeddingSearchResult} containing all found {@link Embedding}s.
|
||||
*/
|
||||
@Experimental
|
||||
default EmbeddingSearchResult<Embedded> search(EmbeddingSearchRequest request) {
|
||||
List<EmbeddingMatch<Embedded>> matches =
|
||||
findRelevant(request.queryEmbedding(), request.maxResults(), request.minScore());
|
||||
|
@ -82,8 +80,9 @@ public interface EmbeddingStore<Embedded> {
|
|||
* @return A list of embedding matches.
|
||||
* Each embedding match includes a relevance score (derivative of cosine distance),
|
||||
* ranging from 0 (not relevant) to 1 (highly relevant).
|
||||
* @deprecated as of 0.31.0, use {@link #search(EmbeddingSearchRequest)} instead.
|
||||
*/
|
||||
// TODO deprecate once the new experimental API is settled
|
||||
@Deprecated
|
||||
default List<EmbeddingMatch<Embedded>> findRelevant(Embedding referenceEmbedding, int maxResults) {
|
||||
return findRelevant(referenceEmbedding, maxResults, 0);
|
||||
}
|
||||
|
@ -98,8 +97,9 @@ public interface EmbeddingStore<Embedded> {
|
|||
* @return A list of embedding matches.
|
||||
* Each embedding match includes a relevance score (derivative of cosine distance),
|
||||
* ranging from 0 (not relevant) to 1 (highly relevant).
|
||||
* @deprecated as of 0.31.0, use {@link #search(EmbeddingSearchRequest)} instead.
|
||||
*/
|
||||
// TODO deprecate once the new experimental API is settled
|
||||
@Deprecated
|
||||
default List<EmbeddingMatch<Embedded>> findRelevant(Embedding referenceEmbedding, int maxResults, double minScore) {
|
||||
EmbeddingSearchRequest embeddingSearchRequest = EmbeddingSearchRequest.builder()
|
||||
.queryEmbedding(referenceEmbedding)
|
||||
|
@ -120,8 +120,9 @@ public interface EmbeddingStore<Embedded> {
|
|||
* @return A list of embedding matches.
|
||||
* Each embedding match includes a relevance score (derivative of cosine distance),
|
||||
* ranging from 0 (not relevant) to 1 (highly relevant).
|
||||
* @deprecated as of 0.31.0, use {@link #search(EmbeddingSearchRequest)} instead.
|
||||
*/
|
||||
// TODO deprecate once the new experimental API is settled
|
||||
@Deprecated
|
||||
default List<EmbeddingMatch<Embedded>> findRelevant(
|
||||
Object memoryId, Embedding referenceEmbedding, int maxResults) {
|
||||
return findRelevant(memoryId, referenceEmbedding, maxResults, 0);
|
||||
|
@ -138,8 +139,9 @@ public interface EmbeddingStore<Embedded> {
|
|||
* @return A list of embedding matches.
|
||||
* Each embedding match includes a relevance score (derivative of cosine distance),
|
||||
* ranging from 0 (not relevant) to 1 (highly relevant).
|
||||
* @deprecated as of 0.31.0, use {@link #search(EmbeddingSearchRequest)} instead.
|
||||
*/
|
||||
// TODO deprecate once the new experimental API is settled
|
||||
@Deprecated
|
||||
default List<EmbeddingMatch<Embedded>> findRelevant(
|
||||
Object memoryId, Embedding referenceEmbedding, int maxResults, double minScore) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.langchain4j.store.embedding.filter;
|
||||
|
||||
import dev.langchain4j.Experimental;
|
||||
import dev.langchain4j.store.embedding.EmbeddingStore;
|
||||
import dev.langchain4j.store.embedding.filter.comparison.*;
|
||||
import dev.langchain4j.store.embedding.filter.logical.And;
|
||||
|
@ -31,7 +30,6 @@ import dev.langchain4j.store.embedding.filter.logical.Or;
|
|||
* @see Not
|
||||
* @see Or
|
||||
*/
|
||||
@Experimental
|
||||
public interface Filter {
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package dev.langchain4j.store.embedding.filter;
|
||||
|
||||
import dev.langchain4j.Experimental;
|
||||
|
||||
/**
|
||||
* Parses a filter expression string into a {@link Filter} object.
|
||||
* <br>
|
||||
* Currently, there is only one implementation: {@code SqlFilterParser}
|
||||
* in the {@code langchain4j-embedding-store-filter-parser-sql} module.
|
||||
*/
|
||||
@Experimental
|
||||
public interface FilterParser {
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.langchain4j.store.embedding.filter;
|
||||
|
||||
import dev.langchain4j.Experimental;
|
||||
import dev.langchain4j.data.document.Metadata;
|
||||
import dev.langchain4j.store.embedding.filter.comparison.*;
|
||||
|
||||
|
@ -16,7 +15,6 @@ import static java.util.stream.Collectors.toList;
|
|||
/**
|
||||
* A helper class for building a {@link Filter} for {@link Metadata} key.
|
||||
*/
|
||||
@Experimental
|
||||
public class MetadataFilterBuilder {
|
||||
|
||||
private final String key;
|
||||
|
@ -25,7 +23,6 @@ public class MetadataFilterBuilder {
|
|||
this.key = ensureNotBlank(key, "key");
|
||||
}
|
||||
|
||||
@Experimental
|
||||
public static MetadataFilterBuilder metadataKey(String key) {
|
||||
return new MetadataFilterBuilder(key);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue