parse static method
Parses model output: the first JSON object in raw (surrounding
prose and code fences are ignored), then parseJson. Never throws.
Implementation
static IntentParseResult parse(String raw) {
final object = _firstJsonObject(raw);
if (object == null) {
return IntentParseResult(ThemeIntent.none, const ['no JSON object']);
}
Object? decoded;
try {
decoded = jsonDecode(object);
} on FormatException {
return IntentParseResult(ThemeIntent.none, const ['unparseable JSON']);
}
return parseJson(decoded);
}