Spaces:
Sleeping
Sleeping
Download news/business_types.py from Success-dev/venthrive-api: direct link, hf CLI and curl.
- Browser
- Download file 897 Bytes
-
https://huggingface.co/spaces/Success-dev/venthrive-api/resolve/main/news/business_types.py
- Command line
-
hf download hf://spaces/Success-dev/venthrive-api/news/business_types.py
-
curl -L -o business_types.py https://huggingface.co/spaces/Success-dev/venthrive-api/resolve/main/news/business_types.py
897 Bytes
| """ | |
| Subsector ids the news classifier is allowed to use for `business_types`. | |
| Sourced from data/sectors.ts via scripts/export-subsectors.mjs — re-run that | |
| script and this file picks up the change automatically, no code edit needed. | |
| See ADR-0015 for why subsector-level (not sector or niche) was chosen. | |
| """ | |
| import json | |
| from pathlib import Path | |
| _PATH = Path(__file__).resolve().parent / "subsectors.json" | |
| SUBSECTORS: list[dict] = json.loads(_PATH.read_text(encoding="utf-8")) | |
| VALID_IDS: set[str] = {s["id"] for s in SUBSECTORS} | |
| def labels_for_prompt() -> str: | |
| """'id — label' lines, for embedding the allowed list in the classifier prompt.""" | |
| return "\n".join(f"- {s['id']} — {s['label']}" for s in SUBSECTORS) | |
| def valid_subset(ids: list[str]) -> list[str]: | |
| """Drops any id the model hallucinated that isn't in our taxonomy.""" | |
| return [i for i in ids if i in VALID_IDS] | |