-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<IChainValues> InternalCall(IChainValues values) | ||
{ | ||
values.Value[_outputKey] = _chatMemory.BufferAsString; | ||
Check warning on line 24 in src/libs/LangChain.Core/Chains/StackableChains/LoadMemoryChain.cs GitHub Actions / Build and test / Build, test and publish
Check warning on line 24 in src/libs/LangChain.Core/Chains/StackableChains/LoadMemoryChain.cs GitHub Actions / Build and test / Build, test and publish
Check warning on line 24 in src/libs/LangChain.Core/Chains/StackableChains/LoadMemoryChain.cs GitHub Actions / Build and test / Build, test and publish
Check warning on line 24 in src/libs/LangChain.Core/Chains/StackableChains/LoadMemoryChain.cs GitHub Actions / Build and test / Build, test and publish
Check warning on line 24 in src/libs/LangChain.Core/Chains/StackableChains/LoadMemoryChain.cs GitHub Actions / Build and test / Build, test and publish
Check warning on line 24 in src/libs/LangChain.Core/Chains/StackableChains/LoadMemoryChain.cs GitHub Actions / Build and test / Build, test and publish
Check warning on line 24 in src/libs/LangChain.Core/Chains/StackableChains/LoadMemoryChain.cs GitHub Actions / Build and test / Build, test and publish
Check warning on line 24 in src/libs/LangChain.Core/Chains/StackableChains/LoadMemoryChain.cs GitHub Actions / Build and test / Build, test and publish
Check warning on line 24 in src/libs/LangChain.Core/Chains/StackableChains/LoadMemoryChain.cs GitHub Actions / Build and test / Build, test and publish
|
||
return Task.FromResult(values); | ||
} | ||
} |