-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenvironment.py
More file actions
27 lines (22 loc) · 1.06 KB
/
Copy pathenvironment.py
File metadata and controls
27 lines (22 loc) · 1.06 KB
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
27
import os
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
# Access environment variable
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
GITHUB_CLIENT_ID = os.getenv('GITHUB_CLIENT_ID')
GITHUB_CLIENT_SECRETS = os.getenv('GITHUB_CLIENT_SECRETS')
REDIRECT_URL = os.getenv('REDIRECT_URL')
GOOGLE_MAP_API = os.getenv('GOOGLE_MAP_API')
if OPENAI_API_KEY is None:
raise Exception("API key not found in the .env file")
# to avoid the error message
os.environ["TOKENIZERS_PARALLELISM"] = "false" # or "true" depending on your needs
'''
This means the tokenizers library will attempt to use multiple threads to speed up tokenization processes.
However, if your environment involves forking processes, enabling parallelism can lead to potential issues like deadlocks (as described in the warning you provided).
'''
# Any remote API (OpenAI, Cohere etc.)
OPENAI_TIMEOUT = float(os.getenv("REMOTE_API_TIMEOUT_SEC", 30))
OPENAI_BACKOFF = float(os.getenv("REMOTE_API_BACKOFF_SEC", 10))
OPENAI_MAX_RETRIES = int(os.getenv("REMOTE_API_MAX_RETRIES", 5))