类 UserMessage
java.lang.Object
com.ajaxjs.mcp.message.UserMessage
- 所有已实现的接口:
ChatMessage
Represents a message from a user, typically an end user of the application.
Depending on the supported modalities (text, image, audio, video, etc.) of the model, user messages can contain either a single text (a
,
,
,
, or
.
Optionally, user message can contain a
Depending on the supported modalities (text, image, audio, video, etc.) of the model, user messages can contain either a single text (a
String) or multiple Contents,
which can be either TextContent,
引用无效
ImageContent
引用无效
AudioContent
引用无效
VideoContent
引用无效
PdfFileContent
引用无效
TextFileContent
Optionally, user message can contain a
name of the user.
Be aware that not all models support names in UserMessage.-
嵌套类概要
嵌套类 -
构造器概要
构造器构造器说明UserMessage(Content... contents) Creates aUserMessagefrom one or multipleContents.UserMessage(String text) Creates aUserMessagefrom a text.UserMessage(String name, Content... contents) Creates aUserMessagefrom a name and one or multipleContents.UserMessage(String name, String text) Creates aUserMessagefrom a name and a text.UserMessage(String name, List<Content> contents) Creates aUserMessagefrom a name and a list ofContents.UserMessage(List<Content> contents) Creates aUserMessagefrom a list ofContents. -
方法概要
修饰符和类型方法说明static UserMessage.Builderbuilder()contents()TheContents of the message.static 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.booleanWhether this message contains a singleTextContent.name()The name of the user.Returns text from a singleTextContent.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.
-
构造器详细资料
-
UserMessage
Creates aUserMessagefrom a text.- 参数:
text- the text.
-
UserMessage
Creates aUserMessagefrom a name and a text.- 参数:
name- the name.text- the text.
-
UserMessage
- 参数:
contents- the contents.
-
UserMessage
Creates aUserMessagefrom a name and one or multipleContents.- 参数:
name- the name.contents- the contents.
-
UserMessage
- 参数:
contents- the contents.
-
UserMessage
Creates aUserMessagefrom a name and a list ofContents.- 参数:
name- the name.contents- the contents.
-
-
方法详细资料
-
name
The name of the user.- 返回:
- the name, or
nullif not set.
-
contents
TheContents of the message.- 返回:
- the contents.
-
singleText
Returns text from a singleTextContent. Use this accessor only if you are certain that the message contains only a single text. If the message contains multipleContents, or if the onlyContentis not aTextContent, aRuntimeExceptionis thrown.- 返回:
- a single text.
- 另请参阅:
-
hasSingleText
public boolean hasSingleText()Whether this message contains a singleTextContent.- 返回:
trueif this message contains a singleTextContent,falseotherwise.
-
type
从接口复制的说明:ChatMessageThe type of the message.- 指定者:
type在接口中ChatMessage- 返回:
- the type of the message
-
builder
-
from
Create aUserMessagefrom a text.- 参数:
text- the text.- 返回:
- the
UserMessage.
-
from
Create aUserMessagefrom a name and a text.- 参数:
name- the name.text- the text.- 返回:
- the
UserMessage.
-
from
Create aUserMessagefrom contents.- 参数:
contents- the contents.- 返回:
- the
UserMessage.
-
from
Create aUserMessagefrom a name and contents.- 参数:
name- the name.contents- the contents.- 返回:
- the
UserMessage.
-
from
Create aUserMessagefrom contents.- 参数:
contents- the contents.- 返回:
- the
UserMessage.
-
from
Create aUserMessagefrom a name and contents.- 参数:
name- the name.contents- the contents.- 返回:
- the
UserMessage.
-
userMessage
Create aUserMessagefrom a text.- 参数:
text- the text.- 返回:
- the
UserMessage.
-
userMessage
Create aUserMessagefrom a name and a text.- 参数:
name- the name.text- the text.- 返回:
- the
UserMessage.
-
userMessage
Create aUserMessagefrom contents.- 参数:
contents- the contents.- 返回:
- the
UserMessage.
-
userMessage
Create aUserMessagefrom a name and contents.- 参数:
name- the name.contents- the contents.- 返回:
- the
UserMessage.
-
userMessage
Create aUserMessagefrom contents.- 参数:
contents- the contents.- 返回:
- the
UserMessage.
-
userMessage
Create aUserMessagefrom a name and contents.- 参数:
name- the name.contents- the contents.- 返回:
- the
UserMessage.
-