Skip to content

Commit a5923f5

Browse files
izeyetzolov
authored andcommitted
Fix sample in "Manual Configuration" section of OpenAI Embeddings API
1 parent 6b9f8d3 commit a5923f5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/embeddings/openai-embeddings.adoc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,17 @@ Next, create an `OpenAiEmbeddingClient` instance and use it to compute the simil
187187
----
188188
var openAiApi = new OpenAiApi(System.getenv("OPENAI_API_KEY"));
189189
190-
var embeddingClient = new OpenAiEmbeddingClient(openAiApi)
191-
.withDefaultOptions(OpenAiChatOptions.build()
192-
.withModel("text-embedding-ada-002")
193-
.withUser("user-6")
194-
.build());
190+
var embeddingClient = new OpenAiEmbeddingClient(
191+
openAiApi,
192+
MetadataMode.EMBED,
193+
OpenAiEmbeddingOptions.builder()
194+
.withModel("text-embedding-ada-002")
195+
.withUser("user-6")
196+
.build(),
197+
RetryUtils.DEFAULT_RETRY_TEMPLATE);
195198
196199
EmbeddingResponse embeddingResponse = embeddingClient
197-
.embedForResponse(List.of("Hello World", "World is big and salvation is near"));
200+
.embedForResponse(List.of("Hello World", "World is big and salvation is near"));
198201
----
199202

200203
The `OpenAiEmbeddingOptions` provides the configuration information for the embedding requests.

0 commit comments

Comments
 (0)