Skip to content
Open
34 changes: 32 additions & 2 deletions docs-java/orchestration/chat-completion.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ config = config.withStreamConfig(

## Using Images

It's possible to add images and multiple text inputs to a message.
It's possible to add images, files, and multiple text inputs to a message.

### Add Images to a Message

Expand All @@ -521,6 +521,36 @@ var newMessage = message.withImage("https://url.to/image.jpg", ImageItem.DetailL

Note, that currently only user messages are supported for image attachments.

### Add File Attachment to a Message

A file can be added to a message either via a file path or via a base64 encoded string as follows.
Only PDF files are currently supported for file attachments.

#### Add File via Local File Path

```java
var message = Message.user("What is the title of the topic discussed here?");
var newMessage = message.withFile(Path.of("path/to/sample.pdf"));
```

#### Add File via Remote File Path

Filename is an optional parameter to the `withFileUrl` method shown below and could be set to null.

```java
var message = Message.user("What is the title of the topic discussed here?");
var newMessage = message.withFileUrl("https://somefile.pdf", "sample.pdf");
```

#### Add File via Base64 Encoded String

```java
var message = Message.user("What is the title of the topic discussed here?");
var newMessage = message.withFileBase64(base64Data, "sample.pdf");
```

Note, that currently only user messages are supported for file attachments.

### Add Multiple Text Inputs to a Message

It's also possible to add multiple text inputs to a message.
Expand Down Expand Up @@ -623,7 +653,7 @@ Please find [an example in our Spring Boot application](https://github.com/SAP/a

Translate the input or output to [any supported language](https://help.sap.com/docs/translation-hub/sap-translation-hub/supported-languages?version=Cloud#translation-provider-sap-machine-translation).
The following sample will translate the prompt into English, send it to the LLM, and then translate the output to German.
Source Language is identified on the whole user input.
The source language is identified from the whole user input.

```java
var prompt = new OrchestrationPrompt("Quelle est la couleur de la tour Eiffel?");
Expand Down
1 change: 1 addition & 0 deletions styles/config/vocabularies/SAP/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ www
semver
XML
MDX
PDF
classpath
[Ss]ervlet
[Aa]ccessor
Expand Down
Loading