Interface ChatMemory

  • All Implemented Interfaces:

    
    public interface ChatMemory
    
                        

    Represents the memory (history) of a chat conversation. Since language models do not keep the state of the conversation, it is necessary to provide all previous messages on every interaction with the language model. ChatMemory helps with keeping track of the conversation and ensuring that messages fit within language model's context window.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract Object id() The ID of the ChatMemory.
      abstract void add(ChatMessage message) Adds a message to the chat memory.
      abstract List<ChatMessage> messages() Retrieves messages from the chat memory.
      abstract void clear() Clears the chat memory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • add

         abstract void add(ChatMessage message)

        Adds a message to the chat memory.

        Parameters:
        message - The ChatMessage to add.
      • messages

         abstract List<ChatMessage> messages()

        Retrieves messages from the chat memory. Depending on the implementation, it may not return all previously added messages, but rather a subset, a summary, or a combination thereof.

        Returns:

        A list of ChatMessage objects that represent the current state of the chat memory.

      • clear

         abstract void clear()

        Clears the chat memory.