diff --git a/docs/docs/Guides/guides-chat-memory.md b/docs/docs/Guides/guides-chat-memory.md index 100d19a19..a9a63b43e 100644 --- a/docs/docs/Guides/guides-chat-memory.md +++ b/docs/docs/Guides/guides-chat-memory.md @@ -51,3 +51,43 @@ You can also display all messages stored across every flow and session by going ![](/img/settings-messages.png) + + +## Store chat memory in an external database + +Chat memory is retrieved from an external database or vector store using the [**Chat Memory**](/components-helpers#chat-memory) component. + +Chat memory is stored to an external database or vector store using the [Store Message](/components-helpers#store-message) component. + +The [**Chat Memories**](/Components/components-memories) components provide access to their respective external databases **as memory**. This allows AIs to access external memory for persistence and context retention. For example, connect the **Chat Memory** component to an **AstraDBChatMemory*** component to store the message history in an external Astra DB database. + +This example stores and retrieves chat history from an [AstraDBChatMemory](/Components/components-memories#astradbchatmemory-component) component with **Store Message** and **Chat Memory** components. + +### Prerequisites + +* [An OpenAI API key](https://platform.openai.com/) +* [An Astra DB vector database](https://docs.datastax.com/en/astra-db-serverless/get-started/quickstart.html) with: + * Application Token + * API Endpoint + +### Connect the chat memory component to an external database + +1. Load the [Memory Chatbot](/starter-projects-memory-chatbot) starter project. +This starter project extends the basic prompting flow to include a chat memory component. +2. Add the [Store Message](/components-helpers#store-message) component to the flow. +The **Store message** component stores messages in the external database. +3. Add the [AstraDBChatMemory Component](/Components/components-memories#astradbchatmemory-component) to the flow. +The **Astra DB Chat Memory** component stores and retrieves messages from **Astra DB**. +4. Configure the **AstraDBChatMemory** component with your AstraDB instance details. + 1. In the **Astra DB Application Token** field, add your Astra token. (`AstraCS:...`) + 2. In the **API Endpoint** field, add your Astra database's endpoint. (for example, `https://12adb-bc-5378c845f05a6-e0a12-bd889b4-us-east-2.apps.astra.datastax.com`) +5. Connect the **AstraDBChatMemory** component output to the external memory inputs of the [Chat Memory](/components-helpers#chat-memory) and [Store Message](/components-helpers#store-message) components. +6. Link the [Chat Output](/components-io#chat-output) component to the input of the [Store Message](/components-helpers#store-message) component. + +Your completed flow should look like this: + +![Sample Flow storing Chat Memory in AstraDB](/img/astra_db_chat_memory_rounded.png) + +7. In Langflow, create message traffic by running a flow. +8. Inspect your Astra database's tables and activity. +You will see new tables and traffic created. diff --git a/docs/docs/Starter-Projects/starter-projects-memory-chatbot.md b/docs/docs/Starter-Projects/starter-projects-memory-chatbot.md index 00039a034..efd1bdbb6 100644 --- a/docs/docs/Starter-Projects/starter-projects-memory-chatbot.md +++ b/docs/docs/Starter-Projects/starter-projects-memory-chatbot.md @@ -49,7 +49,7 @@ Check and adjust advanced parameters by opening the Advanced Settings of the ** -## Use Session ID in with the memory chatbot flow {#4e68c3c0750942f98c45c1c45d7ffbbe} +## Use Session ID with the memory chatbot flow {#4e68c3c0750942f98c45c1c45d7ffbbe} --- diff --git a/docs/static/img/astra_db_chat_memory_rounded.png b/docs/static/img/astra_db_chat_memory_rounded.png new file mode 100644 index 000000000..630e74bc0 Binary files /dev/null and b/docs/static/img/astra_db_chat_memory_rounded.png differ