#!/bin/bash
# Find the correct Qwen3-4B text encoder for Z-Image-Turbo

cd /home/fabian/ComfyUI

# Check HuggingFace cache for previous downloads
echo "=== HF download logs ==="
ls -la models/unet/.cache/huggingface/ 2>/dev/null
cat models/unet/.cache/huggingface/download/*.json 2>/dev/null | head -20

echo ""
echo "=== Check sd-models text_encoders ==="
ls -la /home/fabian/sd-models/text_encoders/ 2>/dev/null
find /home/fabian/sd-models -name '*.safetensors' 2>/dev/null

echo ""
echo "=== Try to find the model via huggingface_hub ==="
/home/fabian/ComfyUI/venv/bin/python3 << 'PYEOF'
from huggingface_hub import HfApi, list_repo_files
api = HfApi()

# Check common repos for z-image text encoders
repos_to_check = [
    "Comfy-Org/z_image_text_encoders",
    "city96/z-image-turbo-GGUF",
    "THUDM/z-image-turbo",
    "Comfy-Org/lumina2_text_encoders",
]

for repo in repos_to_check:
    try:
        files = list_repo_files(repo)
        print(f"\n{repo}:")
        for f in files:
            print(f"  {f}")
    except Exception as e:
        print(f"\n{repo}: {str(e)[:80]}")

# Also search for z_image text encoder repos
try:
    results = api.list_models(search="z_image text_encoder", limit=5)
    print("\n=== Search: z_image text_encoder ===")
    for m in results:
        print(f"  {m.modelId}: {m.tags[:3] if m.tags else 'no tags'}")
except Exception as e:
    print(f"Search failed: {e}")
PYEOF
