This file provides guidance to agents when working with code in this repository.
Build EXE:
pyinstaller web_dashboard.spec --cleanResult: dist/web_dashboard.exe (includes auto-launch browser)
Run directly:
python web_dashboard.py
python model_scraper.pyInstallation:
pip install -r requirements.txt
# or
install.bat # Windows one-click installerTesting: No test framework present. Manual testing required:
- Run
python web_dashboard.pyand verify localhost:5000 loads - Run
python model_scraper.pyand check database is populated - Verify GGUF parsing with gguf-parser.exe in
tools/folder
Standard library → Third-party → Local modules:
import os
import sys
from datetime import datetime
import sqlite3
import requests
from pathlib import Path
from gguf_parser import parse_gguf_from_hf- Variables/Functions:
snake_case(e.g.,get_db_connection,model_dict) - Constants:
UPPER_SNAKE_CASE(e.g.,DEFAULT_CONFIG,MAX_RETRIES) - Classes:
PascalCase(rare in this codebase) - Private functions: Leading underscore (e.g.,
_migrate_gguf_columns,_run_parser)
Use type hints for function signatures:
def parse_gguf_from_hf(repo: str, filename: str, retries: int = MAX_RETRIES) -> dict | None:- Optional dependencies: Try/except ImportError with warning
try:
from gguf_parser import parse_gguf_from_hf
GGUF_PARSER_AVAILABLE = True
except ImportError:
GGUF_PARSER_AVAILABLE = False
print("Warning: gguf_parser not available...")- API calls: Try/except with timeout and logging
try:
response = requests.get(url, timeout=30, headers={})
if response.status_code == 200:
data = response.json()
except Exception as e:
print(f"Error fetching: {e}")- Database operations: Try/except specific exceptions (IntegrityError)
try:
cursor.execute(...)
except sqlite3.IntegrityError:
pass # Handle duplicates
except Exception as e:
print(f"Error: {e}")- Use parameterized queries (never f-strings in SQL)
ON CONFLICT(url) DO UPDATEfor upserts- Always close connections (
conn.close()) - Index frequently queried fields (source, category, release_date, is_gguf)
- Migrations with
ALTER TABLEif column not exists
Always use pathlib.Path for cross-platform compatibility:
from pathlib import Path
DB_PATH = Path(__file__).parent / "data" / "models.db"Handle both development and EXE environments:
if getattr(sys, 'frozen', False):
base_path = Path(sys._MEIPASS)
else:
base_path = Path(__file__).parentMerge defaults with user config:
return {**DEFAULT_CONFIG, **json.load(f)}- Parser at
tools/gguf-parser.exeis OPTIONAL - Graceful fallback if missing (no crash)
- Wrapper handles retries with exponential backoff
- Prefer Q4_K_M quantization files
- Three-phase HuggingFace: popular by likes, recent by modified, GGUF-specific
- ModelScope uses inference API, not models API
- Size estimation: actual file sizes OR name patterns (0.5b, 1b, 7b, etc.)
- Chinese detection: qwen, deepseek, yi-, baichuan, chatglm, internlm keywords
- Single-file Flask app with embedded HTML (no separate templates)
- Auto-refresh every 5 minutes via setInterval
- GGUF detection uses database field AND name fallback
- Stats API at
/api/stats, models at/api/models, refresh at/api/refresh
data/- SQLite database and reportstools/- External binaries (gguf-parser.exe)venv/- Virtual environment (created by install.bat)dist/- Compiled executables