Skip to content

Commit

Permalink
Lite mode - run without pre prompts for execution (#733)
Browse files Browse the repository at this point in the history
* cli flag

* lite mode step config

* precommits

* docs

* pre-commits

* rename function
  • Loading branch information
lukaspetersson authored Sep 22, 2023
1 parent 13d557e commit 830b5c9
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 4 deletions.
61 changes: 58 additions & 3 deletions docs/api_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ Functions
ai.get_tokenizer
ai.serialize_messages

:mod:`gpt_engineer.api`: Api
=============================

.. automodule:: gpt_engineer.api
:no-members:
:no-inherited-members:

Functions
--------------
.. currentmodule:: gpt_engineer

.. autosummary::
:toctree: api

api.step_handler
api.task_handler

:mod:`gpt_engineer.chat_to_files`: Chat To Files
=================================================

Expand All @@ -37,6 +54,9 @@ Functions
.. autosummary::
:toctree: chat_to_files

chat_to_files.format_file_to_input
chat_to_files.get_code_strings
chat_to_files.overwrite_files
chat_to_files.parse_chat
chat_to_files.to_files

Expand Down Expand Up @@ -74,6 +94,35 @@ Functions

db.archive

:mod:`gpt_engineer.file_selector`: File Selector
=================================================

.. automodule:: gpt_engineer.file_selector
:no-members:
:no-inherited-members:

Classes
--------------
.. currentmodule:: gpt_engineer

.. autosummary::
:toctree: file_selector
:template: class.rst

file_selector.DisplayablePath

Functions
--------------
.. currentmodule:: gpt_engineer

.. autosummary::
:toctree: file_selector

file_selector.ask_for_files
file_selector.gui_file_selector
file_selector.is_in_ignoring_extensions
file_selector.terminal_file_selector

:mod:`gpt_engineer.learning`: Learning
=======================================

Expand All @@ -93,7 +142,7 @@ Functions
learning.collect_consent
learning.extract_learning
learning.get_session
learning.human_input
learning.human_review_input
learning.logs_to_string

:mod:`gpt_engineer.main`: Main
Expand All @@ -110,6 +159,7 @@ Functions
.. autosummary::
:toctree: main

main.load_env_if_needed
main.main

:mod:`gpt_engineer.steps`: Steps
Expand All @@ -136,18 +186,23 @@ Functions
.. autosummary::
:toctree: steps

steps.assert_files_ready
steps.clarify
steps.curr_fn
steps.execute_entrypoint
steps.fix_code
steps.gen_clarified_code
steps.gen_code
steps.gen_code_after_unit_tests
steps.gen_entrypoint
steps.gen_spec
steps.gen_unit_tests
steps.get_prompt
steps.get_improve_prompt
steps.human_review
steps.improve_existing_code
steps.lite_gen
steps.respec
steps.set_improve_filelist
steps.setup_sys_prompt
steps.setup_sys_prompt_existing_code
steps.simple_gen
steps.use_feedback
11 changes: 11 additions & 0 deletions gpt_engineer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ def main(
"-i",
help="Improve code from existing project.",
),
lite_mode: bool = typer.Option(
False,
"--lite",
"-l",
help="Lite mode - run only the main prompt.",
),
azure_endpoint: str = typer.Option(
"",
"--azure",
Expand All @@ -48,6 +54,11 @@ def main(
):
logging.basicConfig(level=logging.DEBUG if verbose else logging.INFO)

if lite_mode:
assert not improve_option, "Lite mode cannot improve code"
if steps_config == StepsConfig.DEFAULT:
steps_config = StepsConfig.LITE

# For the improve option take current project as path and add .gpteng folder
if improve_option:
# The default option for the --improve is the IMPROVE_CODE, not DEFAULT
Expand Down
15 changes: 14 additions & 1 deletion gpt_engineer/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,17 @@ def curr_fn() -> str:
# All steps below have the Step signature


def lite_gen(ai: AI, dbs: DBs) -> List[Message]:
"""Run the AI on only the main prompt and save the results"""
messages = ai.start(
dbs.input["prompt"], dbs.preprompts["file_format"], step_name=curr_fn()
)
to_files(messages[-1].content.strip(), dbs.workspace)
return messages


def simple_gen(ai: AI, dbs: DBs) -> List[Message]:
"""Run the AI on the main prompt and save the results"""
"""Run the AI on the default prompts and save the results"""
messages = ai.start(setup_sys_prompt(dbs), dbs.input["prompt"], step_name=curr_fn())
to_files(messages[-1].content.strip(), dbs.workspace)
return messages
Expand Down Expand Up @@ -393,6 +402,7 @@ class Config(str, Enum):
DEFAULT = "default"
BENCHMARK = "benchmark"
SIMPLE = "simple"
LITE = "lite"
TDD = "tdd"
TDD_PLUS = "tdd+"
CLARIFY = "clarify"
Expand All @@ -413,6 +423,9 @@ class Config(str, Enum):
execute_entrypoint,
human_review,
],
Config.LITE: [
lite_gen,
],
Config.BENCHMARK: [
simple_gen,
gen_entrypoint,
Expand Down

0 comments on commit 830b5c9

Please sign in to comment.