Spaces:
Running
Running
File size: 515 Bytes
a0e37e2 bdb86a2 a0e37e2 e8a8618 a0e37e2 bdb86a2 a0e37e2 bdb86a2 a0e37e2 bdb86a2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from typing import TypedDict
import os
from dotenv import dotenv_values, find_dotenv
class Api(TypedDict):
"""REST API configuration template
"""
url: str
key: str
__env_values__ = dotenv_values(
dotenv_path=find_dotenv(".env", raise_error_if_not_found=False)
)
def _load_value(key: str):
return __env_values__.get(key) or os.getenv(key)
CDS_API = Api(
url=_load_value("CDS_API_URL"),
key=_load_value("CDS_API_KEY")
)
OPENAI = Api(url=None, key=_load_value("OPENAI_API_KEY"))
|