forked from ttunguz/evo_blog_public
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_env.py
More file actions
41 lines (34 loc) · 1.11 KB
/
load_env.py
File metadata and controls
41 lines (34 loc) · 1.11 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
"""
Environment variable loader for evo_blog_public
"""
import os
from pathlib import Path
def load_env_file(env_path: str = ".env"):
"""Load environment variables from .env file"""
env_file = Path(env_path)
if env_file.exists():
with open(env_file, 'r') as f:
for line in f:
line = line.strip()
if line and not line.startswith('#') and '=' in line:
key, value = line.split('=', 1)
os.environ[key] = value
def ensure_env_vars():
"""Ensure required environment variables are set"""
required_vars = [
'ANTHROPIC_API_KEY',
'OPENAI_API_KEY',
'GOOGLE_API_KEY'
]
missing_vars = []
for var in required_vars:
if not os.getenv(var):
missing_vars.append(var)
if missing_vars:
print(f"⚠️ Missing required environment variables: {', '.join(missing_vars)}")
print("Please copy .env.example to .env and fill in your API keys")
return False
return True
# Auto-load .env file when imported
load_env_file()