|
25 | 25 |
|
26 | 26 | """
|
27 | 27 |
|
| 28 | +import logging |
28 | 29 | import os
|
| 30 | + |
| 31 | +from importlib.util import find_spec |
29 | 32 | from pathlib import Path
|
30 | 33 |
|
31 | 34 | import openai
|
| 35 | +import toml |
32 | 36 | import typer
|
| 37 | + |
33 | 38 | from dotenv import load_dotenv
|
34 | 39 |
|
35 |
| -from gpt_engineer.core.default.file_store import FileStore |
36 |
| -from gpt_engineer.core.default.disk_memory import DiskMemory |
37 |
| -from gpt_engineer.core.ai import AI |
38 |
| -from gpt_engineer.core.default.paths import PREPROMPTS_PATH, memory_path |
39 |
| -from gpt_engineer.applications.cli.file_selector import ask_for_files, get_all_code |
40 |
| -from gpt_engineer.tools.custom_steps import ( |
41 |
| - lite_gen, |
42 |
| - clarified_gen, |
43 |
| - self_heal, |
44 |
| -) |
45 |
| -from gpt_engineer.tools.experimental.experimental_steps import ( |
46 |
| - improve_automatic_file_selection, |
47 |
| -) |
48 |
| -from gpt_engineer.core.default.steps import gen_code, execute_entrypoint, improve |
49 | 40 | from gpt_engineer.applications.cli.cli_agent import CliAgent
|
50 | 41 | from gpt_engineer.applications.cli.collect import collect_and_send_human_review
|
51 |
| -from gpt_engineer.core.preprompts_holder import PrepromptsHolder |
| 42 | +from gpt_engineer.applications.cli.file_selector import ask_for_files |
| 43 | +from gpt_engineer.core.ai import AI |
52 | 44 | from gpt_engineer.core.default.disk_execution_env import DiskExecutionEnv
|
53 |
| -import logging |
| 45 | +from gpt_engineer.core.default.disk_memory import DiskMemory |
| 46 | +from gpt_engineer.core.default.file_store import FileStore |
| 47 | +from gpt_engineer.core.default.paths import PREPROMPTS_PATH, memory_path |
| 48 | +from gpt_engineer.core.default.steps import execute_entrypoint, gen_code, improve |
| 49 | +from gpt_engineer.core.preprompts_holder import PrepromptsHolder |
| 50 | +from gpt_engineer.tools.custom_steps import clarified_gen, lite_gen, self_heal |
| 51 | + |
| 52 | +# Load the names of the optional dependencies from the pyprojecct file and determine whether |
| 53 | +# they can be imported |
| 54 | +with open("pyproject.toml", "r") as file: |
| 55 | + pyproject = toml.load(file) |
| 56 | + |
| 57 | +dependency_group = pyproject["tool"]["poetry"]["group"]["experimental"]["dependencies"] |
| 58 | +optional_deps_importable = all( |
| 59 | + [find_spec(dep_name.replace("-", "_")) is not None for dep_name in dependency_group] |
| 60 | +) |
54 | 61 |
|
55 | 62 | app = typer.Typer() # creates a CLI app
|
56 | 63 |
|
@@ -105,7 +112,7 @@ def main(
|
105 | 112 | ),
|
106 | 113 | improve_all_mode: bool = typer.Option(
|
107 | 114 | False,
|
108 |
| - "--improve_all_experimental", |
| 115 | + "--improve-all-experimental", |
109 | 116 | help="Improve files_dict from existing project, without manually choosing which files to improve, using vector store (EXPERIMENTAL).",
|
110 | 117 | ),
|
111 | 118 | lite_mode: bool = typer.Option(
|
@@ -185,8 +192,16 @@ def main(
|
185 | 192 | else:
|
186 | 193 | execution_fn = execute_entrypoint
|
187 | 194 |
|
188 |
| - if improve_all_mode: |
| 195 | + if improve_all_mode and optional_deps_importable: |
| 196 | + from gpt_engineer.tools.experimental.experimental_steps import ( |
| 197 | + improve_automatic_file_selection, |
| 198 | + ) |
| 199 | + |
189 | 200 | improve_fn = improve_automatic_file_selection
|
| 201 | + elif improve_all_mode: |
| 202 | + raise ImportError( |
| 203 | + "The experimental improve_all_mode is selected, but the optional dependencies to use it are not installed. Please run 'poetry install --with experimental'" |
| 204 | + ) |
190 | 205 | else:
|
191 | 206 | improve_fn = improve
|
192 | 207 |
|
|
0 commit comments