Spaces:
Sleeping
Sleeping
Quincy Hsieh commited on
Commit Β·
6ee8606
1
Parent(s): dddc53b
Read config.json in the /data folder, instead of reading from the root
Browse files483 unmodified lines48448548648748848949049149234 unmodified lines527528529530531532483 unmodified lines## Configuration### Step 1 β Edit `config.json`Open [`config.json`](config.json) at the project root and replace the placeholders with your Azure OpenAI resource details:```json{34 unmodified linesWhen deploying to Hugging Face Spaces, add it as a **Space Secret** (Settings β Secrets β New secret β name it `AZURE_API_KEY`).### Tunable ParametersThe following constants in `app.py` can also be adjusted directly:483 unmodified lines48448548648748848949049149249349449549649749849950050150250334 unmodified lines538539540541542543544545546547548549550551552553554555483 unmodified lines## ConfigurationThe application loads model configuration with the following priority:1. **`./data/config.json`** β the live runtime config (read at startup)2. **`./config.json`** (project root) β example/template file used as fallback when no runtime config exists; **never put real credentials here**### Step 1 β Create `data/config.json`Copy the root template to `./data/` and fill in your Azure OpenAI resource details:```bashcp config.json data/config.json```Then edit `data/config.json`:```json{34 unmodified linesWhen deploying to Hugging Face Spaces, add it as a **Space Secret** (Settings β Secrets β New secret β name it `AZURE_API_KEY`).### Step 3 β Push `data/config.json` to the HF Bucket`data/config.json` lives under `./data` so a normal bucket sync includes it automatically:```bashhf sync ./data hf://buckets/millimanfrance/Example-App-Hackathon-Gustave-Eiffel-2026-storage --delete```The Space container will then find it at `/data/config.json` on next restart.> **Do not commit `data/config.json` to Git** β it contains endpoint URLs tied to your Azure resource. Add `data/config.json` to `.gitignore`. The root `config.json` is safe to commit as it only contains placeholder values.### Tunable ParametersThe following constants in `app.py` can also be adjusted directly:
55 unmodified lines565758596061626355 unmodified linesCHUNK_OVERLAP = 50TOP_K_RESULTS = 3# Settings loaded from config.json_CONFIG_PATH = Path(__file__).parent / "config.json"with open(_CONFIG_PATH, encoding="utf-8") as _f:_config = json.load(_f)55 unmodified lines56575859606162636465666768697055 unmodified linesCHUNK_OVERLAP = 50TOP_K_RESULTS = 3# Settings loaded from data/config.json (runtime config).# Falls back to the root config.json which serves as the example/template._CONFIG_PATH = DATA_DIR / "config.json"if not _CONFIG_PATH.exists():_CONFIG_PATH = Path(__file__).parent / "config.json"logger.warning(f"No config.json found in {DATA_DIR} β falling back to root config.json (example file). ""Copy config.json to the data directory and fill in your values for production use.")with open(_CONFIG_PATH, encoding="utf-8") as _f:_config = json.load(_f)
README.md+25-2
app.py+9-2