Skip to content

Commit

Permalink
Merge pull request gpt-engineer-org#931 from similato87/version-3.8-s…
Browse files Browse the repository at this point in the history
…upport

Updated type hints and dictionary merging for Python 3.8 compatibility.
  • Loading branch information
ATheorell authored Dec 24, 2023
2 parents 3716fe2 + ab719ae commit 98b0abc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
6 changes: 4 additions & 2 deletions gpt_engineer/applications/cli/cli_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def init(self, prompt: str) -> FilesDict:
entrypoint = gen_entrypoint(
self.ai, files_dict, self.memory, self.preprompts_holder
)
files_dict = FilesDict(files_dict | entrypoint)
combined_dict = {**files_dict, **entrypoint}
files_dict = FilesDict(combined_dict)
files_dict = self.process_code_fn(
self.ai,
self.execution_env,
Expand All @@ -135,7 +136,8 @@ def improve(
entrypoint = gen_entrypoint(
self.ai, files_dict, self.memory, self.preprompts_holder
)
files_dict = FilesDict(files_dict | entrypoint)
combined_dict = {**files_dict, **entrypoint}
files_dict = FilesDict(combined_dict)
files_dict = self.process_code_fn(
self.ai,
self.execution_env,
Expand Down
9 changes: 7 additions & 2 deletions gpt_engineer/benchmark/run.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import time

from typing import List, Optional

from gpt_engineer.benchmark.types import Assertable, Benchmark, TaskResult
from gpt_engineer.core.base_agent import BaseAgent
from gpt_engineer.core.default.disk_execution_env import DiskExecutionEnv


def run(
agent: BaseAgent, benchmark: Benchmark, task_name: str | None = None, verbose=False
) -> list[TaskResult]:
agent: BaseAgent,
benchmark: Benchmark,
task_name: Optional[str] = None,
verbose=False,
) -> List[TaskResult]:
task_results = []
for task in benchmark.tasks:
t0 = time.time()
Expand Down
16 changes: 8 additions & 8 deletions gpt_engineer/benchmark/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from subprocess import Popen
from typing import Callable
from typing import Callable, Dict, Optional

from gpt_engineer.core.base_execution_env import BaseExecutionEnv
from gpt_engineer.core.files_dict import FilesDict
Expand All @@ -21,9 +21,9 @@ class Assertable:

files: FilesDict
env: BaseExecutionEnv
process: Popen | None
stdout: str | None
stderr: str | None
process: Optional[Popen]
stdout: Optional[str]
stderr: Optional[str]


Assertion = Callable[[Assertable], bool]
Expand All @@ -32,10 +32,10 @@ class Assertable:
@dataclass
class Task:
name: str
initial_code: FilesDict | None
command: str | None
initial_code: Optional[FilesDict]
command: Optional[str]
prompt: str
assertions: dict[str, Assertion] | None
assertions: Optional[Dict[str, Assertion]]


@dataclass
Expand All @@ -44,7 +44,7 @@ class Benchmark:

name: str
tasks: list[Task]
timeout: int | None = None
timeout: Optional[int] = None


@dataclass
Expand Down
3 changes: 2 additions & 1 deletion gpt_engineer/core/default/simple_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def init(self, prompt: str) -> FilesDict:
entrypoint = gen_entrypoint(
self.ai, files_dict, self.memory, self.preprompts_holder
)
files_dict = FilesDict(files_dict | entrypoint)
combined_dict = {**files_dict, **entrypoint}
files_dict = FilesDict(combined_dict)
return files_dict

def improve(
Expand Down

0 comments on commit 98b0abc

Please sign in to comment.