mirror of
https://github.com/aljazceru/gpt-engineer.git
synced 2025-12-18 21:25:11 +01:00
Update benchmarks
This commit is contained in:
@@ -3,41 +3,29 @@ from pathlib import Path
|
||||
|
||||
|
||||
# This class represents a simple database that stores its data as files in a directory.
|
||||
# It supports both text and binary files, and can handle directory structures.
|
||||
class DB:
|
||||
"""A simple key-value store, where keys are filenames and values are file contents."""
|
||||
|
||||
def __init__(self, path):
|
||||
# Convert the path string to a Path object and get its absolute path.
|
||||
self.path = Path(path).absolute()
|
||||
|
||||
# Create the directory if it doesn't exist.
|
||||
self.path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
def __getitem__(self, key):
|
||||
# Combine the database directory with the provided file path.
|
||||
full_path = self.path / key
|
||||
|
||||
# Check if the file exists before trying to open it.
|
||||
if full_path.is_file():
|
||||
# Open the file in text mode and return its content.
|
||||
with full_path.open("r") as f:
|
||||
with full_path.open("r", encoding="utf-8") as f:
|
||||
return f.read()
|
||||
else:
|
||||
# If the file doesn't exist, raise an error.
|
||||
raise FileNotFoundError(f"No such file: '{full_path}'")
|
||||
raise KeyError(key)
|
||||
|
||||
def __setitem__(self, key, val):
|
||||
# Combine the database directory with the provided file path.
|
||||
full_path = self.path / key
|
||||
|
||||
# Create the directory tree if it doesn't exist.
|
||||
full_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Write the data to the file. If val is a string, it's written as text.
|
||||
# If val is bytes, it's written as binary data.
|
||||
if isinstance(val, str):
|
||||
full_path.write_text(val)
|
||||
elif isinstance(val, bytes):
|
||||
full_path.write_bytes(val)
|
||||
full_path.write_text(val, encoding="utf-8")
|
||||
else:
|
||||
# If val is neither a string nor bytes, raise an error.
|
||||
raise TypeError("val must be either a str or bytes")
|
||||
|
||||
@@ -157,9 +157,9 @@ def gen_entrypoint(ai, dbs):
|
||||
messages = ai.start(
|
||||
system=(
|
||||
"You will get information about a codebase that is currently on disk in "
|
||||
f"the folder {dbs.workspace.path}.\n"
|
||||
"the current folder.\n"
|
||||
"From this you will answer with code blocks that includes all the necessary "
|
||||
"Windows, MacOS, and Linux terminal commands to "
|
||||
"unix terminal commands to "
|
||||
"a) install dependencies "
|
||||
"b) run all necessary parts of the codebase (in parallell if necessary).\n"
|
||||
"Do not install globally. Do not use sudo.\n"
|
||||
|
||||
Reference in New Issue
Block a user