Package com.sap.ai.sdk.orchestration
Class UserMessage
java.lang.Object
com.sap.ai.sdk.orchestration.UserMessage
- All Implemented Interfaces:
Message
Represents a chat message as 'user' to the orchestration service.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncontent()The content of the message.Converts the message to a serializable ChatMessage object.booleaninthashCode()role()The role of the assistant.toString()Add a file to the message by reading it from disk.withFileBase64(String base64Data, String filename) Add a file to the message from a base64-encoded payload.withFileUrl(String fileUrl, String filename) Add a file to the message by passing its URL.Add an image to the message with the given image URL.withImage(String imageUrl, ImageItem.DetailLevel detailLevel) Add an image to the message with the given image URL and detail level.Add text to the message.
-
Constructor Details
-
UserMessage
Creates a new user message from a string.- Parameters:
message- the first message.
-
-
Method Details
-
withText
Add text to the message.- Parameters:
message- the text to add.- Returns:
- the new message.
- Since:
- 1.3.0
-
withImage
@Nonnull public UserMessage withImage(@Nonnull String imageUrl, @Nonnull ImageItem.DetailLevel detailLevel) Add an image to the message with the given image URL and detail level.- Parameters:
imageUrl- the URL of the image.detailLevel- the detail level of the image.- Returns:
- the new message.
- Since:
- 1.3.0
-
withImage
Add an image to the message with the given image URL.- Parameters:
imageUrl- the URL of the image.- Returns:
- the new message.
- Since:
- 1.3.0
-
withFile
Add a file to the message by reading it from disk.- Parameters:
filePath- the path to a local file.- Returns:
- the new message.
- Since:
- 1.18.0
-
withFileUrl
Add a file to the message by passing its URL.- Parameters:
fileUrl- the URL of the file.filename- optional name of the file.- Returns:
- the new message.
- Since:
- 1.18.0
-
withFileBase64
Add a file to the message from a base64-encoded payload.- Parameters:
base64Data- base64-encoded payload.filename- optional name of the file.- Returns:
- the new message.
- Since:
- 1.18.0
-
createChatMessage
Description copied from interface:MessageConverts the message to a serializable ChatMessage object.- Specified by:
createChatMessagein interfaceMessage- Returns:
- the corresponding
ChatMessageobject.
-
role
The role of the assistant. -
equals
-
hashCode
public int hashCode() -
toString
-
content
The content of the message.
-