clearHistory method

Future<void> clearHistory({
  1. List<Message>? replayHistory,
})

Implementation

Future<void> clearHistory({List<Message>? replayHistory}) async {
  _fullHistory.clear();
  _modelHistory.clear();
  _currentTokens = 0;
  _toolsInstructionSent = false; // Reset the flag when clearing history
  await session.close();
  session = await sessionCreator!();

  if (replayHistory != null) {
    for (final message in replayHistory) {
      await addQueryChunk(message, true);
    }
  }
}