langchain.js
    Preparing search index...

    Class used to store chat message history in Redis. It provides methods to add, retrieve, and clear messages from the chat history.

    const chatHistory = new RedisChatMessageHistory({
    sessionId: new Date().toISOString(),
    sessionTTL: 300,
    url: "redis:
    });

    const chain = new ConversationChain({
    llm: new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
    memory: { chatHistory },
    });

    const response = await chain.invoke({
    input: "What did I just say my name was?",
    });
    console.log({ response });

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    client: Redis
    lc_namespace: string[] = ...

    Accessors

    • get lc_secrets(): {
          "config.password": string;
          "config.username": string;
          url: string;
      }

      Returns { "config.password": string; "config.username": string; url: string }

    Methods

    • Adds a message to the chat history.

      Parameters

      • message: BaseMessage

        The message to add to the chat history.

      Returns Promise<void>

      Promise that resolves when the message has been added.

    • Clears all messages from the chat history.

      Returns Promise<void>

      Promise that resolves when the chat history has been cleared.

    • Retrieves all messages from the chat history.

      Returns Promise<BaseMessage[]>

      Promise that resolves with an array of BaseMessage instances.