Package org.codelibs.fess.entity
Class ChatMessage
java.lang.Object
org.codelibs.fess.entity.ChatMessage
- All Implemented Interfaces:
Serializable
Represents a message in a chat conversation.
- Author:
- FessProject
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a source document referenced in the chat response. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ChatMessage(String role, String content) Creates a new chat message with the specified role and content. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSource(ChatMessage.ChatSource source) Adds a source to the message.static ChatMessageassistantMessage(String content) Creates an assistant message with the specified content.Gets the message content.Gets the HTML-rendered content.getId()Gets the message ID.getRole()Gets the message role.Gets the final search query for this assistant turn.Gets the list of sources referenced in the message.Gets the message timestamp.booleanChecks if this is an assistant message.booleanisUser()Checks if this is a user message.voidsetContent(String content) Sets the message content.voidsetHtmlContent(String htmlContent) Sets the HTML-rendered content.voidSets the message ID.voidSets the message role.voidsetSearchQuery(String searchQuery) Sets the final search query for this assistant turn.voidsetSources(List<ChatMessage.ChatSource> sources) Sets the list of sources referenced in the message.voidsetTimestamp(LocalDateTime timestamp) Sets the message timestamp.static ChatMessageuserMessage(String content) Creates a user message with the specified content.
-
Field Details
-
ROLE_USER
The role identifier for user messages.- See Also:
-
ROLE_ASSISTANT
The role identifier for assistant messages.- See Also:
-
-
Constructor Details
-
ChatMessage
public ChatMessage()Default constructor. -
ChatMessage
Creates a new chat message with the specified role and content.- Parameters:
role- the message rolecontent- the message content
-
-
Method Details
-
userMessage
Creates a user message with the specified content.- Parameters:
content- the message content- Returns:
- a new user message
-
assistantMessage
Creates an assistant message with the specified content.- Parameters:
content- the message content- Returns:
- a new assistant message
-
getId
Gets the message ID.- Returns:
- the message ID
-
setId
Sets the message ID.- Parameters:
id- the message ID
-
getRole
Gets the message role.- Returns:
- the message role
-
setRole
Sets the message role.- Parameters:
role- the message role
-
getContent
Gets the message content.- Returns:
- the message content
-
setContent
Sets the message content.- Parameters:
content- the message content
-
getTimestamp
Gets the message timestamp.- Returns:
- the message timestamp
-
setTimestamp
Sets the message timestamp.- Parameters:
timestamp- the message timestamp
-
getSources
Gets the list of sources referenced in the message.- Returns:
- the list of sources
-
setSources
Sets the list of sources referenced in the message.- Parameters:
sources- the list of sources
-
addSource
Adds a source to the message.- Parameters:
source- the source to add
-
isUser
public boolean isUser()Checks if this is a user message.- Returns:
- true if this is a user message
-
isAssistant
public boolean isAssistant()Checks if this is an assistant message.- Returns:
- true if this is an assistant message
-
getHtmlContent
Gets the HTML-rendered content.- Returns:
- the HTML content, or null if not rendered
-
setHtmlContent
Sets the HTML-rendered content.- Parameters:
htmlContent- the HTML content
-
getSearchQuery
Gets the final search query for this assistant turn.- Returns:
- the search query, or null
-
setSearchQuery
Sets the final search query for this assistant turn.- Parameters:
searchQuery- the search query
-