#!/bin/bash
# Read GGUF metadata from correct path + ZImage model config
echo "=== GGUF metadata ==="
/home/fabian/ComfyUI/venv/bin/python3 -c "
import gguf
reader = gguf.GGUFReader('/home/fabian/ComfyUI/models/unet/z_image_turbo-Q5_K_S.gguf')
for key in sorted(reader.fields.keys()):
    field = reader.fields[key]
    try:
        parts = field.parts
        data_indices = field.data
        tp = str(field.types)
        if len(data_indices) > 0 and len(data_indices) < 10:
            raw = parts[data_indices[0]]
            if hasattr(raw, 'tobytes'):
                val = raw.tobytes().decode('utf-8', errors='replace')
            else:
                val = str(list(raw)[:5]) if hasattr(raw, '__len__') and len(raw) > 1 else str(raw)
        else:
            val = f'data_len={len(data_indices)}'
        print(f'  {key} = {val} ({tp})')
    except Exception as e:
        print(f'  {key} = ERROR: {e}')
"

echo ""
echo "=== ZImage class in supported_models ==="
sed -n '/^class ZImage/,/^class [A-Z]/p' /home/fabian/ComfyUI/comfy/supported_models.py | head -40

echo ""
echo "=== Lumina2 class (parent) ==="
sed -n '/^class Lumina2/,/^class [A-Z]/p' /home/fabian/ComfyUI/comfy/supported_models.py | head -40

echo ""
echo "=== What text encoder files exist ==="
ls /home/fabian/ComfyUI/models/text_encoders/
