cleanModelResponse static method
Remove model response wrappers (Gemma turn markers).
Implementation
static String cleanModelResponse(String response) {
final turnRegex = RegExp(r'<start_of_turn>model\s*([\s\S]*?)<end_of_turn>');
if (turnRegex.hasMatch(response)) {
return turnRegex.firstMatch(response)!.group(1)!.trim();
}
return response.replaceAll(RegExp(r'<end_of_turn>\s*$'), '').trim();
}