Change EmbeddingOptions from class into interface

This commit is contained in:
Christian Tzolov
2024-01-28 19:10:08 +01:00
parent da12b56dc7
commit 7c7392e657
4 changed files with 8 additions and 5 deletions

View File

@@ -156,7 +156,7 @@ public class PostgresMlEmbeddingClient extends AbstractEmbeddingClient implement
@Override
public EmbeddingResponse embedForResponse(List<String> texts) {
return this.call(new EmbeddingRequest(texts, new EmbeddingOptions()));
return this.call(new EmbeddingRequest(texts, EmbeddingOptions.EMPTY));
}
@Override

View File

@@ -214,7 +214,7 @@ public class TransformersEmbeddingClient extends AbstractEmbeddingClient impleme
@Override
public List<List<Double>> embed(List<String> texts) {
return this.call(new EmbeddingRequest(texts, new EmbeddingOptions()))
return this.call(new EmbeddingRequest(texts, EmbeddingOptions.EMPTY))
.getResults()
.stream()
.map(e -> e.getOutput())

View File

@@ -50,7 +50,7 @@ public interface EmbeddingClient extends ModelClient<EmbeddingRequest, Embedding
*/
default List<List<Double>> embed(List<String> texts) {
Assert.notNull(texts, "Texts must not be null");
return this.call(new EmbeddingRequest(texts, new EmbeddingOptions()))
return this.call(new EmbeddingRequest(texts, EmbeddingOptions.EMPTY))
.getResults()
.stream()
.map(Embedding::getOutput)
@@ -64,7 +64,7 @@ public interface EmbeddingClient extends ModelClient<EmbeddingRequest, Embedding
*/
default EmbeddingResponse embedForResponse(List<String> texts) {
Assert.notNull(texts, "Texts must not be null");
return this.call(new EmbeddingRequest(texts, new EmbeddingOptions()));
return this.call(new EmbeddingRequest(texts, EmbeddingOptions.EMPTY));
}
/**

View File

@@ -21,6 +21,9 @@ import org.springframework.ai.model.ModelOptions;
/**
* @author Christian Tzolov
*/
public class EmbeddingOptions implements ModelOptions {
public interface EmbeddingOptions extends ModelOptions {
public static EmbeddingOptions EMPTY = new EmbeddingOptions() {
};
}