mirror of
https://github.com/aljazceru/gpt-engineer.git
synced 2025-12-17 12:45:26 +01:00
28 lines
536 B
Python
28 lines
536 B
Python
|
|
from dataclasses import dataclass
|
|
import os
|
|
from pathlib import Path
|
|
|
|
|
|
class DB:
|
|
def __init__(self, path):
|
|
self.path = Path(path).absolute()
|
|
os.makedirs(self.path, exist_ok=True)
|
|
|
|
def __getitem__(self, key):
|
|
with open(self.path / key) as f:
|
|
return f.read()
|
|
|
|
def __setitem__(self, key, val):
|
|
with open(self.path / key, 'w') as f:
|
|
f.write(val)
|
|
|
|
|
|
# dataclass for all dbs:
|
|
@dataclass
|
|
class DBs:
|
|
memory: DB
|
|
logs: DB
|
|
identity: DB
|
|
input: DB
|
|
workspace: DB |