Class ChatSession

java.lang.Object
org.codelibs.fess.entity.ChatSession

public class ChatSession extends Object
Represents a chat session containing conversation history.
Author:
FessProject
  • Constructor Details

    • ChatSession

      public ChatSession()
      Default constructor.
    • ChatSession

      public ChatSession(String userId)
      Creates a new chat session for the specified user.
      Parameters:
      userId - the user ID
  • Method Details

    • getSessionId

      public String getSessionId()
      Gets the session ID.
      Returns:
      the session ID
    • setSessionId

      public void setSessionId(String sessionId)
      Sets the session ID.
      Parameters:
      sessionId - the session ID
    • getUserId

      public String getUserId()
      Gets the user ID.
      Returns:
      the user ID
    • setUserId

      public void setUserId(String userId)
      Sets the user ID.
      Parameters:
      userId - the user ID
    • getCreatedAt

      public LocalDateTime getCreatedAt()
      Gets the creation timestamp.
      Returns:
      the creation timestamp
    • setCreatedAt

      public void setCreatedAt(LocalDateTime createdAt)
      Sets the creation timestamp.
      Parameters:
      createdAt - the creation timestamp
    • getLastAccessedAt

      public LocalDateTime getLastAccessedAt()
      Gets the last accessed timestamp.
      Returns:
      the last accessed timestamp
    • setLastAccessedAt

      public void setLastAccessedAt(LocalDateTime lastAccessedAt)
      Sets the last accessed timestamp.
      Parameters:
      lastAccessedAt - the last accessed timestamp
    • getMessages

      public List<ChatMessage> getMessages()
      Returns a copy of the message list in this session.
      Returns:
      a new list containing all messages
    • setMessages

      public void setMessages(List<ChatMessage> messages)
      Sets the message list for this session.
      Parameters:
      messages - the messages to set
    • addMessage

      public void addMessage(ChatMessage message)
      Adds a message to this session and updates the last accessed timestamp.
      Parameters:
      message - the message to add
    • addUserMessage

      public void addUserMessage(String content)
      Adds a user message to this session.
      Parameters:
      content - the message content
    • addAssistantMessage

      public void addAssistantMessage(String content)
      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