llmModelFamilyFrom function
The family LlmMetadata.llm_model_type (field 6) names: its oneof
gemma4 = 8, function_gemma = 3 (LiteRT-LM v0.19.1
runtime/proto/llm_model_type.proto), LlmModelFamily.other for any other
case, and null when the bundle has no LlmMetadata or no model type.
Implementation
LlmModelFamily? llmModelFamilyFrom(Uint8List llmMetadata) {
try {
for (final f in _ProtoReader(llmMetadata).fields()) {
if (f.number != 6 || f.bytes == null) continue;
for (final type in _ProtoReader(f.bytes!).fields()) {
if (type.bytes == null) continue;
return switch (type.number) {
8 => LlmModelFamily.gemma4,
3 => LlmModelFamily.functionGemma,
_ => LlmModelFamily.other,
};
}
}
return null;
} on RangeError {
throw const FormatException('LlmMetadata proto is truncated');
}
}