detectChatFormatNameForGguf function

String? detectChatFormatNameForGguf(
  1. Uint8List headerPrefix
)

Detects the chat-format name for the GGUF whose first bytes are headerPrefix, or null when the header is unreadable or matches no known family.

GGUF writers emit general.* keys early and the tokenizer keys after them, so a prefix of a few MiB is normally enough; when the header is larger the caller should retry with a bigger prefix (absence is indistinguishable from truncation only past the key/value section).

Implementation

String? detectChatFormatNameForGguf(Uint8List headerPrefix) {
  final result = readGgufMetadata(
    headerPrefix: headerPrefix,
    keys: const <String>{ggufArchitectureKey, ggufChatTemplateKey},
  );
  if (result is! GgufMetadata) return null;
  return detectChatFormatName(
    architecture: result.values[ggufArchitectureKey],
    chatTemplate: result.values[ggufChatTemplateKey],
  );
}