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
Copy file name to clipboardExpand all lines: docs/guides/ORCHESTRATION_CHAT_COMPLETION.md
+20-8Lines changed: 20 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -266,29 +266,41 @@ It's possible to add images and multiple text inputs to a message.
266
266
267
267
### Add images to a message
268
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.
269
+
An image can be added to an existing message as follows.
270
270
271
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"));
272
+
message.addImage("https://url.to/image.jpg");
274
273
```
274
+
275
+
You can also construct a message with an image directly, using the `MessageContent` class.
276
+
277
+
```java
278
+
var message =Message.user(MessageContent.image("https://url.to/image.jpg"));
279
+
```
280
+
275
281
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.
Note, that currently only user messages are supported for image attachments.
280
287
281
288
### Add multiple text inputs to a message
282
289
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.
290
+
It's also possible to add multiple text inputs to a message. This can be useful for providing additional context to the AI model. You can construct a message with multiple text inputs as follows.
285
291
286
292
```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."));
293
+
var message =Message.user("What is chess about?", "Answer in two sentences.");
290
294
```
291
295
296
+
Or you can add additional text inputs to an existing message.
297
+
298
+
```java
299
+
message.addText("Please use many emojis in your answer.");
300
+
```
301
+
302
+
Note, that only user and system messages are supported for multiple text inputs.
303
+
292
304
Please find [an example in our Spring Boot application](../../sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/OrchestrationService.java).
0 commit comments