saveState method
Fills the context with exactly promptPrefix, samples nothing, and writes the state to path. A recurrent
state cannot be rewound, so the state ends at the prefix's last token. Failures throw StateFileException.
Implementation
@override
Future<SavedState> saveState(String path, String promptPrefix) async {
_checkOpen();
_contextEpoch++;
return _queue.run(() async {
saves++;
_checkPersistence();
try {
File(path).writeAsStringSync(promptPrefix);
} catch (e) {
throw StateFileException('cannot write $path', cause: e);
}
return SavedState(path: path, tokens: promptPrefix.length ~/ 4, bytes: promptPrefix.length, ms: 0);
});
}