Share via


ChatMessageContent<T> Class

Type Parameters

T

the type of the inner content within the messages

public class ChatMessageContent<T>
extends KernelContentImpl<T>

Represents the content of a chat message

This class defaults to a TEXT content type if none is specified. However, if using this for text content, consider using ChatMessageTextContent and its builders instead.

Constructor Summary

Constructor Description
ChatMessageContent(AuthorRole authorRole, String content)

Creates a new instance of the ChatMessageContent<T> class.

ChatMessageContent(AuthorRole authorRole, String content, String modelId, T innerContent, Charset encoding, FunctionResultMetadata metadata)

Creates a new instance of the ChatMessageContent<T> class.

ChatMessageContent(AuthorRole authorRole, String content, String modelId, T innerContent, Charset encoding, FunctionResultMetadata metadata, ChatMessageContentType contentType)

Creates a new instance of the ChatMessageContent<T> class.

ChatMessageContent(AuthorRole authorRole, List<KernelContent<T>> items, String modelId, T innerContent, Charset encoding, FunctionResultMetadata metadata, ChatMessageContentType contentType)

Creates a new instance of the ChatMessageContent<T> class.

Method Summary

Modifier and Type Method and Description
AuthorRole getAuthorRole()

Gets the author role that generated the content

java.lang.String getContent()

Gets the content

ChatMessageContentType getContentType()

Gets the content type

java.nio.charset.Charset getEncoding()

Gets the encoding of the content

java.util.List<KernelContent<T>> getItems()

Gets the KernelContent items that comprise the content.

java.lang.String toString()

Methods inherited from KernelContentImpl

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

ChatMessageContent

public ChatMessageContent(AuthorRole authorRole, String content)

Creates a new instance of the ChatMessageContent<T> class. Defaults to TEXT content type.

Parameters:

authorRole - the author role that generated the content
content - the content

ChatMessageContent

public ChatMessageContent(AuthorRole authorRole, String content, String modelId, T innerContent, Charset encoding, FunctionResultMetadata metadata)

Creates a new instance of the ChatMessageContent<T> class. Defaults to TEXT content type.

Parameters:

authorRole - the author role that generated the content
content - the content
modelId - the model id
innerContent - the inner content
encoding - the encoding
metadata - the metadata

ChatMessageContent

public ChatMessageContent(AuthorRole authorRole, String content, String modelId, T innerContent, Charset encoding, FunctionResultMetadata metadata, ChatMessageContentType contentType)

Creates a new instance of the ChatMessageContent<T> class.

Parameters:

authorRole - the author role that generated the content
content - the content
modelId - the model id
innerContent - the inner content
encoding - the encoding
metadata - the metadata
contentType - the content type

ChatMessageContent

public ChatMessageContent(AuthorRole authorRole, List> items, String modelId, T innerContent, Charset encoding, FunctionResultMetadata metadata, ChatMessageContentType contentType)

Creates a new instance of the ChatMessageContent<T> class.

Parameters:

authorRole - the author role that generated the content
items - the items
modelId - the model id
innerContent - the inner content
encoding - the encoding
metadata - the metadata
contentType - the content type

Method Details

getAuthorRole

public AuthorRole getAuthorRole()

Gets the author role that generated the content

Returns:

the author role that generated the content

getContent

public String getContent()

Gets the content

Returns:

the content, which may be null

getContentType

public ChatMessageContentType getContentType()

Gets the content type

Returns:

the content type

getEncoding

public Charset getEncoding()

Gets the encoding of the content

Returns:

the encoding, which may be null

getItems

public List> getItems()

Gets the KernelContent items that comprise the content.

Returns:

the items, which may be null

toString

public String toString()

Overrides:

ChatMessageContent<T>.toString()

Applies to