langchain.js
    Preparing search index...

    Class for storing chat message history with Astra DB. It extends the BaseListChatMessageHistory class and provides methods to get, add, and clear messages.

    const client = new AstraDB(
    process.env.ASTRA_DB_APPLICATION_TOKEN,
    process.env.ASTRA_DB_ENDPOINT,
    process.env.ASTRA_DB_NAMESPACE
    );

    const collection = await client.collection("test_chat");

    const chatHistory = new AstraDBChatMessageHistory({
    collection,
    sessionId: "YOUR_SESSION_ID",
    });

    const messages = await chatHistory.getMessages();

    await chatHistory.clear

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    lc_namespace: string[] = ...

    Methods

    • Parameters

      • message: BaseMessage

      Returns Promise<void>

    • Returns Promise<void>

    • Returns Promise<BaseMessage[]>

    • async initializer function to return a new instance of AstraDBChatMessageHistory in a single step

      Parameters

      Returns Promise<AstraDBChatMessageHistory>

      Promise

      const chatHistory = await AstraDBChatMessageHistory.initialize({
      token: process.env.ASTRA_DB_APPLICATION_TOKEN,
      endpoint: process.env.ASTRA_DB_ENDPOINT,
      namespace: process.env.ASTRA_DB_NAMESPACE,
      collectionName:"test_chat",
      sessionId: "YOUR_SESSION_ID"
      });