Package org.codelibs.fess.entity
Class ChatSession
java.lang.Object
org.codelibs.fess.entity.ChatSession
Represents a chat session containing conversation history.
- Author:
- FessProject
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ChatSession(String userId) Creates a new chat session for the specified user. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAssistantMessage(String content) Adds an assistant message to this session.voidaddMessage(ChatMessage message) Adds a message to this session and updates the last accessed timestamp.voidaddUserMessage(String content) Adds a user message to this session.voidClears all messages in this session and updates the last accessed timestamp.Gets the creation timestamp.Gets the last accessed timestamp.intReturns the number of messages in this session.Returns a copy of the message list in this session.Gets the session ID.Gets the user ID.voidsetCreatedAt(LocalDateTime createdAt) Sets the creation timestamp.voidsetLastAccessedAt(LocalDateTime lastAccessedAt) Sets the last accessed timestamp.voidsetMessages(List<ChatMessage> messages) Sets the message list for this session.voidsetSessionId(String sessionId) Sets the session ID.voidSets the user ID.voidtouch()Updates the last accessed timestamp to the current time.voidtrimHistory(int maxMessages) Trims the message history to keep only the most recent messages.
-
Constructor Details
-
ChatSession
public ChatSession()Default constructor. -
ChatSession
Creates a new chat session for the specified user.- Parameters:
userId- the user ID
-
-
Method Details
-
getSessionId
Gets the session ID.- Returns:
- the session ID
-
setSessionId
Sets the session ID.- Parameters:
sessionId- the session ID
-
getUserId
Gets the user ID.- Returns:
- the user ID
-
setUserId
Sets the user ID.- Parameters:
userId- the user ID
-
getCreatedAt
Gets the creation timestamp.- Returns:
- the creation timestamp
-
setCreatedAt
Sets the creation timestamp.- Parameters:
createdAt- the creation timestamp
-
getLastAccessedAt
Gets the last accessed timestamp.- Returns:
- the last accessed timestamp
-
setLastAccessedAt
Sets the last accessed timestamp.- Parameters:
lastAccessedAt- the last accessed timestamp
-
getMessages
Returns a copy of the message list in this session.- Returns:
- a new list containing all messages
-
setMessages
Sets the message list for this session.- Parameters:
messages- the messages to set
-
addMessage
Adds a message to this session and updates the last accessed timestamp.- Parameters:
message- the message to add
-
addUserMessage
Adds a user message to this session.- Parameters:
content- the message content
-
addAssistantMessage
Adds an assistant message to this session.- Parameters:
content- the message content
-
touch
public void touch()Updates the last accessed timestamp to the current time. -
getMessageCount
public int getMessageCount()Returns the number of messages in this session.- Returns:
- the message count
-
clearMessages
public void clearMessages()Clears all messages in this session and updates the last accessed timestamp. -
trimHistory
public void trimHistory(int maxMessages) Trims the message history to keep only the most recent messages.- Parameters:
maxMessages- the maximum number of messages to retain
-