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 aUserMessage
from contents.UserMessage
(String text) Creates aUserMessage
from a text.UserMessage
(String name, Content... contents) Creates aUserMessage
from a name and contents.UserMessage
(String name, String text) Creates aUserMessage
from a name and a text.UserMessage
(String name, List<Content> contents) Creates aUserMessage
from a name and contents.UserMessage
(List<Content> contents) Creates aUserMessage
from contents. -
Method Summary
Modifier and TypeMethodDescriptioncontents()
The contents of the message.boolean
static UserMessage
Create aUserMessage
from contents.static UserMessage
Create aUserMessage
from a text.static UserMessage
Create aUserMessage
from a name and contents.static UserMessage
Create aUserMessage
from a name and a text.static UserMessage
Create aUserMessage
from a name and contents.static UserMessage
Create aUserMessage
from contents.int
hashCode()
boolean
Whether this message has a single text content.name()
The name of the user.text()
Deprecated.toString()
type()
The type of the message.static UserMessage
userMessage
(Content... contents) Create aUserMessage
from contents.static UserMessage
userMessage
(String text) Create aUserMessage
from a text.static UserMessage
userMessage
(String name, Content... contents) Create aUserMessage
from a name and contents.static UserMessage
userMessage
(String name, String text) Create aUserMessage
from a name and a text.static UserMessage
userMessage
(String name, List<Content> contents) Create aUserMessage
from a name and contents.static UserMessage
userMessage
(List<Content> contents) Create aUserMessage
from contents.
-
Constructor Details
-
UserMessage
Creates aUserMessage
from a text.- Parameters:
text
- the text.
-
UserMessage
Creates aUserMessage
from a name and a text.- Parameters:
name
- the name.text
- the text.
-
UserMessage
Creates aUserMessage
from contents.Will have a {code null} name.
- Parameters:
contents
- the contents.
-
UserMessage
Creates aUserMessage
from a name and contents.- Parameters:
name
- the name.contents
- the contents.
-
UserMessage
Creates aUserMessage
from contents.Will have a {code null} name.
- Parameters:
contents
- the contents.
-
UserMessage
Creates aUserMessage
from a name and contents.- Parameters:
name
- the name.contents
- the contents.
-
-
Method Details
-
name
The name of the user.- Returns:
- the name, or
null
if not set.
-
contents
The contents of the message.- Returns:
- the contents.
-
text
Deprecated.Description copied from interface:ChatMessage
The text of the message.- Specified by:
text
in interfaceChatMessage
- Returns:
- the text of the message
-
hasSingleText
public boolean hasSingleText()Whether this message has a single text content.- Returns:
true
if this message has a single text content,false
otherwise.
-
type
Description copied from interface:ChatMessage
The type of the message.- Specified by:
type
in interfaceChatMessage
- Returns:
- the type of the message
-
equals
-
hashCode
public int hashCode() -
toString
-
from
Create aUserMessage
from a text.- Parameters:
text
- the text.- Returns:
- the
UserMessage
.
-
from
Create aUserMessage
from a name and a text.- Parameters:
name
- the name.text
- the text.- Returns:
- the
UserMessage
.
-
from
Create aUserMessage
from contents.- Parameters:
contents
- the contents.- Returns:
- the
UserMessage
.
-
from
Create aUserMessage
from a name and contents.- Parameters:
name
- the name.contents
- the contents.- Returns:
- the
UserMessage
.
-
from
Create aUserMessage
from contents.- Parameters:
contents
- the contents.- Returns:
- the
UserMessage
.
-
from
Create aUserMessage
from a name and contents.- Parameters:
name
- the name.contents
- the contents.- Returns:
- the
UserMessage
.
-
userMessage
Create aUserMessage
from a text.- Parameters:
text
- the text.- Returns:
- the
UserMessage
.
-
userMessage
Create aUserMessage
from a name and a text.- Parameters:
name
- the name.text
- the text.- Returns:
- the
UserMessage
.
-
userMessage
Create aUserMessage
from contents.- Parameters:
contents
- the contents.- Returns:
- the
UserMessage
.
-
userMessage
Create aUserMessage
from a name and contents.- Parameters:
name
- the name.contents
- the contents.- Returns:
- the
UserMessage
.
-
userMessage
Create aUserMessage
from contents.- Parameters:
contents
- the contents.- Returns:
- the
UserMessage
.
-
userMessage
Create aUserMessage
from a name and contents.- Parameters:
name
- the name.contents
- the contents.- Returns:
- the
UserMessage
.
-