Package dev.langchain4j.data.message
Class UserMessage
java.lang.Object
dev.langchain4j.data.message.UserMessage
- All Implemented Interfaces:
ChatMessage
Represents a message from a user, typically an end user of the application.
-
Constructor Summary
ConstructorsConstructorDescriptionUserMessage(Content... contents) Creates aUserMessagefrom contents.UserMessage(String text) Creates aUserMessagefrom a text.UserMessage(String name, Content... contents) Creates aUserMessagefrom a name and contents.UserMessage(String name, String text) Creates aUserMessagefrom a name and a text.UserMessage(String name, List<Content> contents) Creates aUserMessagefrom a name and contents.UserMessage(List<Content> contents) Creates aUserMessagefrom contents. -
Method Summary
Modifier and TypeMethodDescriptioncontents()The contents of the message.booleanstatic UserMessageCreate aUserMessagefrom contents.static UserMessageCreate aUserMessagefrom a text.static UserMessageCreate aUserMessagefrom a name and contents.static UserMessageCreate aUserMessagefrom a name and a text.static UserMessageCreate aUserMessagefrom a name and contents.static UserMessageCreate aUserMessagefrom contents.inthashCode()booleanWhether this message has a single text content.name()The name of the user.text()Deprecated.toString()type()The type of the message.static UserMessageuserMessage(Content... contents) Create aUserMessagefrom contents.static UserMessageuserMessage(String text) Create aUserMessagefrom a text.static UserMessageuserMessage(String name, Content... contents) Create aUserMessagefrom a name and contents.static UserMessageuserMessage(String name, String text) Create aUserMessagefrom a name and a text.static UserMessageuserMessage(String name, List<Content> contents) Create aUserMessagefrom a name and contents.static UserMessageuserMessage(List<Content> contents) Create aUserMessagefrom contents.
-
Constructor Details
-
UserMessage
Creates aUserMessagefrom a text.- Parameters:
text- the text.
-
UserMessage
Creates aUserMessagefrom a name and a text.- Parameters:
name- the name.text- the text.
-
UserMessage
Creates aUserMessagefrom contents.Will have a {code null} name.
- Parameters:
contents- the contents.
-
UserMessage
Creates aUserMessagefrom a name and contents.- Parameters:
name- the name.contents- the contents.
-
UserMessage
Creates aUserMessagefrom contents.Will have a {code null} name.
- Parameters:
contents- the contents.
-
UserMessage
Creates aUserMessagefrom a name and contents.- Parameters:
name- the name.contents- the contents.
-
-
Method Details
-
name
The name of the user.- Returns:
- the name, or
nullif not set.
-
contents
The contents of the message.- Returns:
- the contents.
-
text
Deprecated.Description copied from interface:ChatMessageThe text of the message.- Specified by:
textin interfaceChatMessage- Returns:
- the text of the message
-
hasSingleText
public boolean hasSingleText()Whether this message has a single text content.- Returns:
trueif this message has a single text content,falseotherwise.
-
type
Description copied from interface:ChatMessageThe type of the message.- Specified by:
typein interfaceChatMessage- Returns:
- the type of the message
-
equals
-
hashCode
public int hashCode() -
toString
-
from
Create aUserMessagefrom a text.- Parameters:
text- the text.- Returns:
- the
UserMessage.
-
from
Create aUserMessagefrom a name and a text.- Parameters:
name- the name.text- the text.- Returns:
- the
UserMessage.
-
from
Create aUserMessagefrom contents.- Parameters:
contents- the contents.- Returns:
- the
UserMessage.
-
from
Create aUserMessagefrom a name and contents.- Parameters:
name- the name.contents- the contents.- Returns:
- the
UserMessage.
-
from
Create aUserMessagefrom contents.- Parameters:
contents- the contents.- Returns:
- the
UserMessage.
-
from
Create aUserMessagefrom a name and contents.- Parameters:
name- the name.contents- the contents.- Returns:
- the
UserMessage.
-
userMessage
Create aUserMessagefrom a text.- Parameters:
text- the text.- Returns:
- the
UserMessage.
-
userMessage
Create aUserMessagefrom a name and a text.- Parameters:
name- the name.text- the text.- Returns:
- the
UserMessage.
-
userMessage
Create aUserMessagefrom contents.- Parameters:
contents- the contents.- Returns:
- the
UserMessage.
-
userMessage
Create aUserMessagefrom a name and contents.- Parameters:
name- the name.contents- the contents.- Returns:
- the
UserMessage.
-
userMessage
Create aUserMessagefrom contents.- Parameters:
contents- the contents.- Returns:
- the
UserMessage.
-
userMessage
Create aUserMessagefrom a name and contents.- Parameters:
name- the name.contents- the contents.- Returns:
- the
UserMessage.
-