Download setup_data.py from Rahul-rr/CAMS-AI: direct link, hf CLI and curl.
- Browser
- Download file 1.79 kB
-
https://huggingface.co/spaces/Rahul-rr/CAMS-AI/resolve/main/setup_data.py
- Command line
-
hf download hf://spaces/Rahul-rr/CAMS-AI/setup_data.py
-
curl -L -o setup_data.py https://huggingface.co/spaces/Rahul-rr/CAMS-AI/resolve/main/setup_data.py
1.79 kB
| """ | |
| setup_data.py | |
| -------------- | |
| Generates synthetic investor data and knowledge base. | |
| Auto-runs on first startup if data files don't exist. | |
| Can also be run manually: python setup_data.py | |
| """ | |
| import sys, json | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).parent)) | |
| def run(): | |
| data_dir = Path("data") | |
| data_dir.mkdir(exist_ok=True) | |
| investors_path = data_dir / "investors.json" | |
| kb_path = data_dir / "knowledge_base.json" | |
| # ββ Investor data ββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| if not investors_path.exists(): | |
| print("[setup] Generating synthetic investor records...") | |
| from data.synthetic_investors import generate_investors | |
| investors = generate_investors(20) | |
| with open(investors_path, "w") as f: | |
| json.dump(investors, f, indent=2) | |
| print(f"[setup] β {len(investors)} investor records β {investors_path}") | |
| else: | |
| print(f"[setup] β investors.json already exists β skipping") | |
| # ββ Knowledge base βββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| if not kb_path.exists(): | |
| print("[setup] Generating CAMS knowledge base...") | |
| from data.knowledge_base_generator import KNOWLEDGE_BASE | |
| with open(kb_path, "w") as f: | |
| json.dump(KNOWLEDGE_BASE, f, indent=2) | |
| print(f"[setup] β {len(KNOWLEDGE_BASE)} KB documents β {kb_path}") | |
| else: | |
| print(f"[setup] β knowledge_base.json already exists β skipping") | |
| print("[setup] Data ready β ") | |
| if __name__ == "__main__": | |
| run() | |