saveContext method
Future<void>
saveContext({
- required MemoryInputValues inputValues,
- required MemoryOutputValues outputValues,
override
Save the context of this model run to memory.
Implementation
@override
Future<void> saveContext({
required final MemoryInputValues inputValues,
required final MemoryOutputValues outputValues,
}) async {
// this is purposefully done in sequence so they're saved in order
final (input, output) = _getInputOutputValues(inputValues, outputValues);
if (input is ChatMessage) {
await chatHistory.addChatMessage(input);
} else {
await chatHistory.addHumanChatMessage(input.toString());
}
if (output is ChatMessage) {
await chatHistory.addChatMessage(output);
} else {
await chatHistory.addAIChatMessage(output.toString());
}
}