You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please find [an example in our Spring Boot application](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/SpringAiOrchestrationService.java).
55
57
56
-
##Orchestration Masking
58
+
###Masking
57
59
58
60
Configure Orchestration modules withing Spring AI:
find [an example in our Spring Boot application](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/SpringAiOrchestrationService.java).
79
81
80
-
## Stream chat completion
82
+
###Stream chat completion
81
83
82
84
It's possible to pass a stream of chat completion delta elements, e.g. from the application backend
83
85
to the frontend in real-time.
@@ -93,15 +95,15 @@ Prompt prompt =
93
95
Flux<ChatResponse> flux = client.stream(prompt);
94
96
95
97
// also possible to keep only the chat completion text
_Note: A Spring endpoint can return `Flux` instead of `ResponseEntity`._
101
103
102
104
Please find [an example in our Spring Boot application](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/SpringAiOrchestrationService.java).
103
105
104
-
## Tool Calling
106
+
###Tool Calling
105
107
106
108
First define a function that will be called by the LLM:
Please find [an example in our Spring Boot application](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/SpringAiOrchestrationService.java).
139
141
142
+
## OpenAI
143
+
144
+
### Embedding
145
+
146
+
With SpringAI integration (_since v1.5.0_), you may now obtain embedding vectors for a list of strings as follows:
147
+
148
+
You first initialize the OpenAI client for your model of choice and attach it `OpenAiSpringEmbeddingModel` object.
Then you can invoke `embded` method on the `embeddingModel` object with the text items to embed.
156
+
157
+
```java
158
+
List<String> texts =List.of("Hello", "World");
159
+
float[] embeddings = embeddingModel.embed(texts);
160
+
```
161
+
162
+
Please find [an example in our Spring Boot application](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/SpringAiOpenAiService.java).
Copy file name to clipboardExpand all lines: foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/spring/OpenAiSpringEmbeddingModel.java
Copy file name to clipboardExpand all lines: foundation-models/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/spring/EmbeddingModelTest.java
0 commit comments