Skip to content

Commit be70506

Browse files
committed
Add documentation and release notes
1 parent eaf2632 commit be70506

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

docs/guides/ORCHESTRATION_CHAT_COMPLETION.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,39 @@ try (Stream<String> stream = client.streamChatCompletion(prompt, config)) {
259259
Please find [an example in our Spring Boot application](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/OrchestrationService.java).
260260
It shows the usage of Spring Boot's `ResponseBodyEmitter` to stream the chat completion delta messages to the frontend in real-time.
261261

262+
263+
## Add images and multiple text inputs to a message
264+
265+
It's possible to add images and multiple text inputs to a message.
266+
267+
### Add images to a message
268+
269+
There are multiple ways to add an image to a user message as detailed below. Note, that currently only user messages are supported for image attachments.
270+
271+
```java
272+
var message1 = Message.user("What is in this image?").addImage("https://url.to/image.jpg");
273+
var message2 = Message.user("And what is in this image?").add(MessageContent.image("https://url.to/image.jpg"));
274+
```
275+
Some AI models, like GPT 4o, support additionally setting the detail level with which the image is read. This can be set via the `DetailLevel` parameter.
276+
277+
```java
278+
message.addImage("https://url.to/image.jpg", ImageItem.DetailLevel.low);
279+
```
280+
281+
### Add multiple text inputs to a message
282+
283+
It's also possible to add multiple text inputs to a message. This can be useful for providing additional context to the AI model.
284+
There are multiple ways to do this as detailed below. Note, that only user and system messages are supported for multiple text inputs.
285+
286+
```java
287+
var message1 = Message.user("What is chess about?", "Answer in two sentences.");
288+
var message2 = Message.user("What is chess about?").addText("Answer in two sentences.");
289+
var message3 = Message.user("What is chess about?").add(MessageContent.text("Answer in two sentences."));
290+
```
291+
292+
Please find [an example in our Spring Boot application](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/OrchestrationService.java).
293+
294+
262295
## Set model parameters
263296

264297
Change your LLM configuration to add model parameters:

docs/release-notes/release_notes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
### 🔧 Compatibility Notes
1010

11-
-
11+
- `Message.content()` returns a `ContentItem` now instead of a `String`. Use `((TextItem) Message.content().contentItemList().get(0)).text()` if the corresponding `ContentItem` is a `TextItem` and the string representation is needed.
1212

1313
### ✨ New Functionality
1414

1515
- [Add Orchestration `LlamaGuardFilter`](../guides/ORCHESTRATION_CHAT_COMPLETION.md#chat-completion-filter).
16+
- [Convenient methods to create messages containing images and multiple text inputs](../guides/ORCHESTRATION_CHAT_COMPLETION.md#add-images-and-multiple-text-inputs-to-a-message)
1617

1718
### 📈 Improvements
1819

0 commit comments

Comments
 (0)