diff --git a/src/libs/LangChain.Core/Chains/Chain.cs b/src/libs/LangChain.Core/Chains/Chain.cs
index a3342fc5..0b391b4b 100644
--- a/src/libs/LangChain.Core/Chains/Chain.cs
+++ b/src/libs/LangChain.Core/Chains/Chain.cs
@@ -149,13 +149,20 @@ public static StuffDocumentsChain CombineDocuments(
///
///
public static UpdateMemoryChain UpdateMemory(
- BaseChatMemory memory,
+ ConversationBufferMemory memory,
string requestKey = "text",
string responseKey = "text")
{
return new UpdateMemoryChain(memory, requestKey, responseKey);
}
+ public static LoadMemoryChain LoadMemory(
+ ConversationBufferMemory memory,
+ string outputKey = "text")
+ {
+ return new LoadMemoryChain(memory, outputKey);
+ }
+
///
///
///
diff --git a/src/libs/LangChain.Core/Chains/StackableChains/LoadMemoryChain.cs b/src/libs/LangChain.Core/Chains/StackableChains/LoadMemoryChain.cs
new file mode 100644
index 00000000..7224b8d8
--- /dev/null
+++ b/src/libs/LangChain.Core/Chains/StackableChains/LoadMemoryChain.cs
@@ -0,0 +1,27 @@
+using LangChain.Abstractions.Schema;
+using LangChain.Chains.HelperChains;
+using LangChain.Memory;
+
+namespace LangChain.Chains.StackableChains;
+
+public class LoadMemoryChain: BaseStackableChain
+{
+
+ private readonly ConversationBufferMemory _chatMemory;
+ private readonly string _outputKey;
+
+ public LoadMemoryChain(ConversationBufferMemory chatMemory,string outputKey)
+ {
+
+ _chatMemory = chatMemory;
+ _outputKey = outputKey;
+
+ OutputKeys = new[] {_outputKey};
+ }
+
+ protected override Task InternalCall(IChainValues values)
+ {
+ values.Value[_outputKey] = _chatMemory.BufferAsString;
+ return Task.FromResult(values);
+ }
+}
\ No newline at end of file