trohrbaugh commited on
Commit
649bd46
·
verified ·
1 Parent(s): 2508503

Detect GGUF-only repos by file list (not just name)

Browse files
Files changed (1) hide show
  1. scan.py +14 -6
scan.py CHANGED
@@ -287,9 +287,13 @@ def fetch_config(model_id: str) -> Optional[dict]:
287
 
288
 
289
  def fetch_model_metadata(model_id: str) -> dict:
290
- """Fetch HF model metadata (downloads, likes, author, tags)."""
291
  try:
292
- r = requests.get(f"{HF_API}/api/models/{model_id}", timeout=10)
 
 
 
 
293
  r.raise_for_status()
294
  d = r.json()
295
  return {
@@ -302,6 +306,7 @@ def fetch_model_metadata(model_id: str) -> dict:
302
  "license": d.get("cardData", {}).get("license", ""),
303
  "created_at": d.get("createdAt", ""),
304
  "last_modified": d.get("lastModified", ""),
 
305
  }
306
  except Exception:
307
  return {}
@@ -827,7 +832,8 @@ def generate_verdict(
827
 
828
  _GGUF_ARCH_MAP = {
829
  "qwen35": "Qwen3.5", "qwen3_5": "Qwen3.5", "qwen3": "Qwen3", "qwen2": "Qwen2.5",
830
- "llama": "Llama", "gemma": "Gemma", "gemma2": "Gemma", "gemma3": "Gemma",
 
831
  "phi3": "Phi-3", "mistral": "Mistral", "deepseek2": "DeepSeek V2/V3",
832
  }
833
 
@@ -892,9 +898,12 @@ def scan(model_id: str) -> dict:
892
  t0 = time.time()
893
 
894
  # GGUF: no standard config.json — offer metadata inspection + source resolution.
 
 
895
  name_lower = model_id.lower()
896
- if "gguf" in name_lower:
897
- metadata = fetch_model_metadata(model_id)
 
898
  gguf_md = fetch_gguf_metadata(model_id)
899
  source = resolve_gguf_source(model_id, metadata, gguf_md)
900
  offers = []
@@ -933,7 +942,6 @@ def scan(model_id: str) -> dict:
933
  "error": "Could not fetch config.json — model may be private, gated, or not exist on HuggingFace.",
934
  "scanned_at": datetime.now(timezone.utc).isoformat(),
935
  }
936
- metadata = fetch_model_metadata(model_id)
937
  claims = detect_claimed_base(model_id, config, metadata)
938
  stage1 = stage1_screen(model_id, config)
939
  chat_template = fetch_chat_template(model_id)
 
287
 
288
 
289
  def fetch_model_metadata(model_id: str) -> dict:
290
+ """Fetch HF model metadata (downloads, likes, author, tags, file list)."""
291
  try:
292
+ headers = {}
293
+ token = os.environ.get("HF_TOKEN", "")
294
+ if token:
295
+ headers["Authorization"] = f"Bearer {token}"
296
+ r = requests.get(f"{HF_API}/api/models/{model_id}", headers=headers, timeout=10)
297
  r.raise_for_status()
298
  d = r.json()
299
  return {
 
306
  "license": d.get("cardData", {}).get("license", ""),
307
  "created_at": d.get("createdAt", ""),
308
  "last_modified": d.get("lastModified", ""),
309
+ "files": [s.get("rfilename", "") for s in d.get("siblings", [])],
310
  }
311
  except Exception:
312
  return {}
 
832
 
833
  _GGUF_ARCH_MAP = {
834
  "qwen35": "Qwen3.5", "qwen3_5": "Qwen3.5", "qwen3": "Qwen3", "qwen2": "Qwen2.5",
835
+ "qwen35moe": "Qwen3.5/3.6 MoE", "qwen3moe": "Qwen3 MoE", "qwen2moe": "Qwen2 MoE",
836
+ "llama": "Llama", "llama4": "Llama 4", "gemma": "Gemma", "gemma2": "Gemma", "gemma3": "Gemma",
837
  "phi3": "Phi-3", "mistral": "Mistral", "deepseek2": "DeepSeek V2/V3",
838
  }
839
 
 
898
  t0 = time.time()
899
 
900
  # GGUF: no standard config.json — offer metadata inspection + source resolution.
901
+ # Detect by name OR by the repo actually containing .gguf files (many GGUF-only repos
902
+ # don't put "gguf" in the name, e.g. HauhauCS/Qwen3.6-...-Aggressive).
903
  name_lower = model_id.lower()
904
+ metadata = fetch_model_metadata(model_id)
905
+ repo_has_gguf = any(str(f).lower().endswith(".gguf") for f in metadata.get("files", []))
906
+ if "gguf" in name_lower or repo_has_gguf:
907
  gguf_md = fetch_gguf_metadata(model_id)
908
  source = resolve_gguf_source(model_id, metadata, gguf_md)
909
  offers = []
 
942
  "error": "Could not fetch config.json — model may be private, gated, or not exist on HuggingFace.",
943
  "scanned_at": datetime.now(timezone.utc).isoformat(),
944
  }
 
945
  claims = detect_claimed_base(model_id, config, metadata)
946
  stage1 = stage1_screen(model_id, config)
947
  chat_template = fetch_chat_template(model_id)