Spaces:
Runtime error
Runtime error
Download app/utils/handle_api.py from tongyi21/LLM_Powered_Legal_RAG: direct link, hf CLI and curl.
- Browser
- Download file 412 Bytes
-
https://huggingface.co/spaces/tongyi21/LLM_Powered_Legal_RAG/resolve/main/app/utils/handle_api.py
- Command line
-
hf download hf://spaces/tongyi21/LLM_Powered_Legal_RAG/app/utils/handle_api.py
-
curl -L -o handle_api.py https://huggingface.co/spaces/tongyi21/LLM_Powered_Legal_RAG/resolve/main/app/utils/handle_api.py
412 Bytes
| import os | |
| import getpass | |
| from dotenv import load_dotenv | |
| def get_api(api_name="OPENAI_API_KEY"): | |
| load_dotenv() | |
| api_key = os.getenv(api_name) | |
| if api_key == None: | |
| api_key = getpass.getpass(f"Enter API key for {api_name}: ") | |
| if api_key == None: | |
| raise ValueError(f"API key is required. Please set it in the environment variable {api_name} or provide it directly.") | |
| return api_key |