From 7d9e3f177059ff3b3d9e0b26da7fe6de9e1bb257 Mon Sep 17 00:00:00 2001 From: Milder Hernandez Cagua Date: Mon, 28 Oct 2024 00:58:23 -0700 Subject: [PATCH] Remove default dimensions for models that don't support it --- .../OpenAITextEmbeddingGenerationService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aiservices/openai/src/main/java/com/microsoft/semantickernel/aiservices/openai/textembedding/OpenAITextEmbeddingGenerationService.java b/aiservices/openai/src/main/java/com/microsoft/semantickernel/aiservices/openai/textembedding/OpenAITextEmbeddingGenerationService.java index 89b52831..355f2ab9 100644 --- a/aiservices/openai/src/main/java/com/microsoft/semantickernel/aiservices/openai/textembedding/OpenAITextEmbeddingGenerationService.java +++ b/aiservices/openai/src/main/java/com/microsoft/semantickernel/aiservices/openai/textembedding/OpenAITextEmbeddingGenerationService.java @@ -26,7 +26,6 @@ public class OpenAITextEmbeddingGenerationService extends OpenAiService> generateEmbeddingsAsync(List data) { protected Mono> internalGenerateTextEmbeddingsAsync(List data) { EmbeddingsOptions options = new EmbeddingsOptions(data) .setModel(getModelId()) - .setDimensions(dimensions) .setInputType("string"); + if (dimensions > 0) { + options.setDimensions(dimensions); + } return getClient() .getEmbeddings(getModelId(), options) @@ -118,7 +119,7 @@ protected Mono> internalGenerateTextEmbeddingsAsync(List public static class Builder extends OpenAiServiceBuilder { - private int dimensions = DEFAULT_DIMENSIONS; + private int dimensions = -1; /** * Sets the dimensions for the embeddings.