saveContext method

  1. @override
Future<void> saveContext({
  1. required MemoryInputValues inputValues,
  2. 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());
  }
}