Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Sep 24, 2024
1 parent c79c063 commit aec4e72
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions docs/core_docs/docs/versions/migrating_memory/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The concept of memory has evolved significantly in LangChain since its initial r
Broadly speaking, LangChain 0.0.x memory was used to handle three main use cases:

| Use Case | Example |
|--------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| Managing conversation history | Keep only the last `n` turns of the conversation between the user and the AI. |
| Extraction of structured information | Extract structured information from the conversation history, such as a list of facts learned about the user. |
| Composite memory implementations | Combine multiple memory sources, e.g., a list of known facts about the user along with facts learned during a given conversation. |
Expand All @@ -33,10 +33,11 @@ The main advantages of persistence implementation in LangGraph are:
:::info Prerequisites

These guides assume some familiarity with the following concepts:

- [LangGraph](https://langchain-ai.github.io/langgraphjs/)
- [v0.0.x Memory](https://js.langchain.com/v0.1/docs/modules/memory/)
- [How to add persistence ("memory") to your graph](https://langchain-ai.github.io/langgraphjs/how-tos/persistence/)
:::
:::

### 1. Managing conversation history

Expand All @@ -47,26 +48,25 @@ Often this involves trimming and / or summarizing the conversation history to ke
Memory classes that fall into this category include:

| Memory Type | How to Migrate | Description |
|-----------------------------------|:-------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| --------------------------------- | :----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ConversationTokenBufferMemory` | [Link to Migration Guide](conversation_buffer_window_memory) | Keeps only the most recent messages in the conversation under the constraint that the total number of tokens in the conversation does not exceed a certain limit. |
| `ConversationSummaryMemory` | [Link to Migration Guide](conversation_summary_memory) | Continually summarizes the conversation history. The summary is updated after each conversation turn. The abstraction returns the summary of the conversation history. |
| `ConversationSummaryBufferMemory` | [Link to Migration Guide](conversation_summary_memory) | Provides a running summary of the conversation together with the most recent messages in the conversation under the constraint that the total number of tokens in the conversation does not exceed a certain limit. |
| `VectorStoreRetrieverMemory` | No migration guide yet | Stores the conversation history in a vector store and retrieves the most relevant parts of past conversation based on the input. |


### 2. Extraction of structured information from the conversation history

Memory classes that fall into this category include:

| Memory Type | Description |
|----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `BaseEntityStore` | An abstract interface that resembles a key-value store. It was used for storing structured information learned during the conversation. The information had to be represented as a dictionary of key-value pairs. |
| Memory Type | Description |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `BaseEntityStore` | An abstract interface that resembles a key-value store. It was used for storing structured information learned during the conversation. The information had to be represented as a dictionary of key-value pairs. |

And specific backend implementations of abstractions:

| Memory Type | Description |
|---------------------------|----------------------------------------------------------------------------------------------------------|
| `InMemoryEntityStore` | An implementation of `BaseEntityStore` that stores the information in the literal computer memory (RAM). |
| Memory Type | Description |
| --------------------- | -------------------------------------------------------------------------------------------------------- |
| `InMemoryEntityStore` | An implementation of `BaseEntityStore` that stores the information in the literal computer memory (RAM). |

These abstraction(s) have not received much development since their initial release. The reason
is that for these abstractions to be useful they typically require a lot of specialization for a particular application, so these
Expand All @@ -83,9 +83,9 @@ The extracted information can then be saved into an appropriate data structure (

Memory classes that fall into this category include:

| Memory Type | Description |
|------------------------|--------------------------------------------------------------------------------------------------------------------------------|
| `CombinedMemory` | This abstraction accepted a list of `BaseMemory` and fetched relevant memory information from each of them based on the input. |
| Memory Type | Description |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `CombinedMemory` | This abstraction accepted a list of `BaseMemory` and fetched relevant memory information from each of them based on the input. |

These implementation(s) did not seem to be used widely or provide significant value. Users should be able
to re-implement these without too much difficulty in custom code.
Expand All @@ -94,17 +94,17 @@ to re-implement these without too much difficulty in custom code.

Explore persistence with LangGraph:

* [LangGraph quickstart tutorial](https://langchain-ai.github.io/langgraphjs/tutorials/quickstart/)
* [How to add persistence ("memory") to your graph](https://langchain-ai.github.io/langgraphjs/how-tos/persistence/)
* [How to manage conversation history](https://langchain-ai.github.io/langgraphjs/how-tos/manage-conversation-history/)
* [How to add summary of the conversation history](https://langchain-ai.github.io/langgraphjs/how-tos/add-summary-conversation-history/)
- [LangGraph quickstart tutorial](https://langchain-ai.github.io/langgraphjs/tutorials/quickstart/)
- [How to add persistence ("memory") to your graph](https://langchain-ai.github.io/langgraphjs/how-tos/persistence/)
- [How to manage conversation history](https://langchain-ai.github.io/langgraphjs/how-tos/manage-conversation-history/)
- [How to add summary of the conversation history](https://langchain-ai.github.io/langgraphjs/how-tos/add-summary-conversation-history/)

Add persistence with simple LCEL (favor LangGraph for more complex use cases):

* [How to add message history](https://js.langchain.com/docs/how_to/message_history/)
- [How to add message history](https://js.langchain.com/docs/how_to/message_history/)

Working with message history:

* [How to trim messages](https://js.langchain.com/docs/how_to/trim_messages)
* [How to filter messages](https://js.langchain.com/docs/how_to/filter_messages/)
* [How to merge message runs](https://js.langchain.com/docs/how_to/merge_message_runs/)
- [How to trim messages](https://js.langchain.com/docs/how_to/trim_messages)
- [How to filter messages](https://js.langchain.com/docs/how_to/filter_messages/)
- [How to merge message runs](https://js.langchain.com/docs/how_to/merge_message_runs/)

0 comments on commit aec4e72

Please sign in to comment.