Spaces:
Runtime error
Runtime error
Download config.py from dwaynefernandes05/EduGenerator: direct link, hf CLI and curl.
- Browser
- Download file 798 Bytes
-
https://huggingface.co/spaces/dwaynefernandes05/EduGenerator/resolve/main/config.py
- Command line
-
hf download hf://spaces/dwaynefernandes05/EduGenerator/config.py
-
curl -L -o config.py https://huggingface.co/spaces/dwaynefernandes05/EduGenerator/resolve/main/config.py
798 Bytes
| """Configuration and Groq client initialization. | |
| - Loads environment variables via python-dotenv. | |
| - Exposes a single `get_groq_client()` helper. | |
| Never hardcode secrets. Put `GROQ_API_KEY` in `.env`. | |
| """ | |
| from __future__ import annotations | |
| import os | |
| from functools import lru_cache | |
| from dotenv import load_dotenv | |
| from groq import Groq | |
| def get_groq_client() -> Groq: | |
| """Create and cache a Groq client. | |
| Raises: | |
| RuntimeError: if GROQ_API_KEY is missing. | |
| """ | |
| # Load .env (if present) once per process. | |
| load_dotenv() | |
| api_key = os.getenv("GROQ_API_KEY") | |
| if not api_key: | |
| raise RuntimeError( | |
| "Missing GROQ_API_KEY. Create a .env file (see .env.example) and set GROQ_API_KEY." | |
| ) | |
| return Groq(api_key=api_key) | |