1
0
Fork
You've already forked ai-agent-coding
0

Add hf-model-settings-scraper: HuggingFace LLM settings scraper + offline test suite #2

Merged
Copilot merged 4 commits from copilot/add-llm-settings-scraper into main 2026年03月11日 22:37:57 +01:00
Copilot commented 2026年03月07日 05:27:10 +01:00 (Migrated from github.com)
Copy link

Adds a new CLI script that scrapes sampling parameters, context length, sources, and notes from HuggingFace model pages and emits project-compatible YAML. Includes 63 offline unit + integration tests documenting exact input/output behaviour.

Script (bin/hf-model-settings-scraper.py)

Input — any of:

hf-model-settings-scraper.py owner/model
hf-model-settings-scraper.py https://huggingface.co/owner/model
hf-model-settings-scraper.py -f models.txt -o model-settings.yml

Output — YAML in the project's model-settings format:

models:hf.co/Qwen/Qwen2.5-Coder-7B-Instruct:settings:temperature:0.7top_p:0.8top_k:20do_sample:truemax_ctx:32768sources:- https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instructnotes:| Here provides a code snippet with `apply_chat_template` ...hf.co/unsloth/Qwen3-30B-A3B-Thinking-2507-GGUF:modes:thinking:# detected via name/tag keywordstemperature:0.6top_k:20sources:- https://huggingface.co/unsloth/Qwen3-30B-A3B-Thinking-2507-GGUF- https://huggingface.co/Qwen/Qwen3-30B-A3B-Thinking-2507 # base model fallback

Key behaviours:

  • Falls back to base_model's generation_config.json when missing (common for GGUF repos)
  • Detects thinking/reasoning models by name keywords (thinking, reasoning, cot) or HF tags → emits modes.thinking instead of settings
  • Extracts sampling params from README code blocks (YAML/Python/JSON styles) as last resort; ignores trivial max_new_tokens values < 1024
  • Strips markdown blockquote markers (>, [!IMPORTANT]) from notes
  • Source URL filtering: enforces /{owner}/{repo} shape on HF URLs; blocks datasets/, papers/, blob/, resolve/, fragments, CDN images, and org-only pages; caps at 6 per model
  • Gated models (HTTP 401) degrade gracefully to sources-only output

Tests (bin/tests/test_hf_model_settings_scraper.py)

63 pytest tests, zero network calls. Covers every extraction function via inline synthetic fixtures, plus a full end-to-end integration test using unittest.mock.patch on _fetch_json/_fetch_text that verifies the YAML dict and file output from spec string to disk.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Adds a new CLI script that scrapes sampling parameters, context length, sources, and notes from HuggingFace model pages and emits project-compatible YAML. Includes 63 offline unit + integration tests documenting exact input/output behaviour. ## Script (`bin/hf-model-settings-scraper.py`) **Input** — any of: ``` hf-model-settings-scraper.py owner/model hf-model-settings-scraper.py https://huggingface.co/owner/model hf-model-settings-scraper.py -f models.txt -o model-settings.yml ``` **Output** — YAML in the project's model-settings format: ```yaml models: hf.co/Qwen/Qwen2.5-Coder-7B-Instruct: settings: temperature: 0.7 top_p: 0.8 top_k: 20 do_sample: true max_ctx: 32768 sources: - https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct notes: | Here provides a code snippet with `apply_chat_template` ... hf.co/unsloth/Qwen3-30B-A3B-Thinking-2507-GGUF: modes: thinking: # detected via name/tag keywords temperature: 0.6 top_k: 20 sources: - https://huggingface.co/unsloth/Qwen3-30B-A3B-Thinking-2507-GGUF - https://huggingface.co/Qwen/Qwen3-30B-A3B-Thinking-2507 # base model fallback ``` **Key behaviours:** - Falls back to `base_model`'s `generation_config.json` when missing (common for GGUF repos) - Detects thinking/reasoning models by name keywords (`thinking`, `reasoning`, `cot`) or HF tags → emits `modes.thinking` instead of `settings` - Extracts sampling params from README code blocks (YAML/Python/JSON styles) as last resort; ignores trivial `max_new_tokens` values < 1024 - Strips markdown blockquote markers (`>`, `[!IMPORTANT]`) from notes - Source URL filtering: enforces `/{owner}/{repo}` shape on HF URLs; blocks `datasets/`, `papers/`, `blob/`, `resolve/`, fragments, CDN images, and org-only pages; caps at 6 per model - Gated models (HTTP 401) degrade gracefully to sources-only output ## Tests (`bin/tests/test_hf_model_settings_scraper.py`) 63 pytest tests, zero network calls. Covers every extraction function via inline synthetic fixtures, plus a full end-to-end integration test using `unittest.mock.patch` on `_fetch_json`/`_fetch_text` that verifies the YAML dict and file output from spec string to disk. <!-- START COPILOT CODING AGENT TIPS --> --- 🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. [Learn more about Advanced Security.](https://gh.io/cca-advanced-security)
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mutablecc/ai-agent-coding!2
Reference in a new issue
mutablecc/ai-agent-coding
No description provided.
Delete branch "copilot/add-llm-settings-scraper"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?