Skip to content

Commit 378abaf

Browse files
authored
Vector embeddings: Use OrchestrationEmbeddingRequest (#2547)
Update AI SDK example to use new `Orchestration` API: https://sap.github.io/ai-sdk/docs/java/orchestration/embedding#embedding
1 parent 80b6016 commit 378abaf

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

guides/databases/vector-embeddings.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ Alternatively, you can compute vector embeddings in your application layer using
6060

6161
:::details Example using SAP Cloud SDK for AI
6262
```Java
63-
var aiClient = OpenAiClient.forModel(OpenAiModel.TEXT_EMBEDDING_3_SMALL);
64-
var response = aiClient.embedding(
65-
new OpenAiEmbeddingRequest(List.of(book.getDescription())));
66-
book.setEmbedding(CdsVector.of(response.getEmbeddingVectors().get(0)));
63+
String question = "Are there patterns with overheating solar inverters?";
64+
var request = OrchestrationEmbeddingRequest
65+
.forModel(TEXT_EMBEDDING_3_SMALL)
66+
.forInputs(question).asQuery();
67+
OrchestrationEmbeddingResponse response = client.embed(request);
68+
float[] embedding = response.getEmbeddingVectors().get(0);
69+
70+
CdsVector vector = CdsVector.of(embedding);
6771
```
6872
:::
6973

0 commit comments

Comments
 (0)