Class TokenWindowChatMemory.Builder

java.lang.Object
dev.langchain4j.memory.chat.TokenWindowChatMemory.Builder
Enclosing class:
TokenWindowChatMemory

public static class TokenWindowChatMemory.Builder extends Object
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • id

      Parameters:
      id - The ID of the ChatMemory. If not provided, a "default" will be used.
      Returns:
      builder
    • maxTokens

      public TokenWindowChatMemory.Builder maxTokens(Integer maxTokens, TokenCountEstimator tokenCountEstimator)
      Parameters:
      maxTokens - The maximum number of tokens to retain. Chat memory will retain as many of the most recent messages as can fit into maxTokens. Messages are indivisible. If an old message doesn't fit, it is evicted completely.
      tokenCountEstimator - A TokenCountEstimator responsible for counting tokens in the messages.
      Returns:
      builder
    • chatMemoryStore

      public TokenWindowChatMemory.Builder chatMemoryStore(ChatMemoryStore store)
      Parameters:
      store - The chat memory store responsible for storing the chat memory state. If not provided, an SingleSlotChatMemoryStore will be used.
      Returns:
      builder
    • build

      public TokenWindowChatMemory build()