-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
40 lines (33 loc) · 1.21 KB
/
config.py
File metadata and controls
40 lines (33 loc) · 1.21 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
import os
import json
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
DEFAULT_BRAIN_PATH = Path.home() / ".gemini/antigravity/brain"
CONFIG_FILE_NAME = "brain_surgeon.config.json"
class Config:
def __init__(self):
self.brain_path = DEFAULT_BRAIN_PATH
self.api_key = os.getenv("GOOGLE_API_KEY")
self._load_config()
def _load_config(self):
config_path = Path(CONFIG_FILE_NAME)
if config_path.exists():
try:
data = json.loads(config_path.read_text())
if "brain_path" in data:
self.brain_path = Path(data["brain_path"]).expanduser()
if "api_key" in data:
self.api_key = data["api_key"]
except Exception as e:
print(f"Warning: Failed to load config file: {e}")
env_brain = os.getenv("BRAIN_SURGEON_PATH")
if env_brain:
self.brain_path = Path(env_brain).expanduser()
env_key = os.getenv("GOOGLE_API_KEY")
if env_key:
self.api_key = env_key
@property
def readable_root(self):
return self.brain_path.parent / (self.brain_path.name + "-readable")
config = Config()