From f3e760d65333027d96f2ca269b0cd67d4c2e3ba5 Mon Sep 17 00:00:00 2001 From: I538344 Date: Thu, 5 Dec 2024 15:22:36 +0100 Subject: [PATCH] Added embedding documentation --- docs/guides/OPENAI_CHAT_COMPLETION.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/guides/OPENAI_CHAT_COMPLETION.md b/docs/guides/OPENAI_CHAT_COMPLETION.md index 783bb50ce..6f89ff12d 100644 --- a/docs/guides/OPENAI_CHAT_COMPLETION.md +++ b/docs/guides/OPENAI_CHAT_COMPLETION.md @@ -200,3 +200,15 @@ System.out.println("Tokens used: " + tokensUsed); Please find [an example in our Spring Boot application](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OpenAiController.java). It shows the usage of Spring Boot's `ResponseBodyEmitter` to stream the chat completion delta messages to the frontend in real-time. + +### Embedding + +Get the embeddings of a text input in list of float values: + +```java +OpenAiEmbeddingParameters request = new OpenAiEmbeddingParameters().setInput("Hello World"); + +OpenAiEmbeddingOutput embedding = OpenAiClient.forModel(TEXT_EMBEDDING_ADA_002).embedding(request); +``` + +See [an example in our Spring Boot application](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OpenAiController.java)