Class ChatConversation

java.lang.Object
ecmwf.common.ai.ChatConversation
All Implemented Interfaces:
Serializable

public class ChatConversation extends Object implements Serializable
Represents a chat conversation between a user and the AI assistant. Maintains a limited message history to avoid unbounded memory growth.
See Also:
  • Constructor Details

    • ChatConversation

      public ChatConversation()
      Default constructor with 20 messages max.
    • ChatConversation

      public ChatConversation(int maxHistorySize)
      Constructor with custom max history size.
  • Method Details

    • addUserMessage

      public void addUserMessage(String message)
      Add a user message.
    • addAiMessage

      public void addAiMessage(String message)
      Add an AI message.
    • getHistory

      public List<ChatConversation.Message> getHistory()
      Returns a copy of the conversation history.
    • getLastUserMessage

      public Optional<ChatConversation.Message> getLastUserMessage()
      Returns the most recent user message, if any.
    • getLastAiMessage

      public Optional<ChatConversation.Message> getLastAiMessage()
      Returns the most recent AI message, if any.