From 59448798ddcdff28f79691283e43f41b8ead88c6 Mon Sep 17 00:00:00 2001 From: kristiankyvik Date: Fri, 23 Feb 2024 00:00:33 +0100 Subject: [PATCH 01/11] deleted the intro folder and made usage and installation docs consistent with readme --- docs/index.rst | 43 ++--------- docs/installation.rst | 6 +- docs/intro/ai_class.md | 11 --- docs/intro/chat_parsing.md | 39 ---------- docs/intro/db_class.md | 33 -------- docs/intro/gate.md | 34 --------- docs/intro/harmony_db_ai_steps.md | 75 ------------------- docs/intro/main_script.md | 43 ----------- docs/intro/preprompts.md | 56 -------------- docs/intro/repository_stats.md | 20 ----- docs/intro/scripts.md | 27 ------- docs/intro/steps_module.md | 54 ------------- .../quick_overview.md => introduction.md} | 17 ++++- docs/usage.rst | 52 +++++++++---- 14 files changed, 65 insertions(+), 445 deletions(-) delete mode 100644 docs/intro/ai_class.md delete mode 100644 docs/intro/chat_parsing.md delete mode 100644 docs/intro/db_class.md delete mode 100644 docs/intro/gate.md delete mode 100644 docs/intro/harmony_db_ai_steps.md delete mode 100644 docs/intro/main_script.md delete mode 100644 docs/intro/preprompts.md delete mode 100644 docs/intro/repository_stats.md delete mode 100644 docs/intro/scripts.md delete mode 100644 docs/intro/steps_module.md rename docs/{intro/quick_overview.md => introduction.md} (84%) diff --git a/docs/index.rst b/docs/index.rst index 2a132dac2b..9813ad72cd 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,59 +1,32 @@ Welcome to GPT-ENGINEER's Documentation -======================================== +======================================= .. toctree:: :maxdepth: 2 - :caption: INTRODUCTION: + :caption: GET STARTED: - intro/quick_overview.md - intro/repository_stats.md - intro/main_script.md - intro/scripts.md - intro/preprompts.md + introduction.md + installation + usage .. toctree:: :maxdepth: 2 :caption: USER GUIDES: - installation - usage - readme_link windows_readme_link + custom_steps.md open_models.md tracing_debugging.md - -.. toctree:: - :maxdepth: 2 - :caption: CORE COMPONENTS: - - intro/gate.md - intro/ai_class.md - intro/db_class.md - intro/steps_module.md - - -.. toctree:: - :maxdepth: 2 - :caption: HARMONY OF AI, DB, & STEPS: - - intro/harmony_db_ai_steps.md - -.. toctree:: - :maxdepth: 2 - :caption: CHAT PARSING & SELF EXECUTION: - - intro/chat_parsing.md - .. toctree:: :maxdepth: 2 - :caption: CONTRIBUTING GUIDES: + :caption: CONTRIBUTE: contributing_link - DOCS_BUILDING.md roadmap_link code_conduct_link disclaimer_link + docs_building.md terms_link .. toctree:: diff --git a/docs/installation.rst b/docs/installation.rst index 5a1d1146bf..844c9471e3 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -14,7 +14,7 @@ To install gpt-engineer, run this command in your terminal: $ pip install gpt_engineer -This is the preferred method to install file-processor, as it will always install the most recent stable release. +This is the preferred method to install gpt-engineer, as it will always install the most recent stable release. If you don't have `pip`_ installed, this `Python installation guide`_ can guide you through the process. @@ -26,7 +26,7 @@ you through the process. From sources ------------ -The sources for file-processor can be downloaded from the `Github repo`_. +The sources for gpt-engineer can be downloaded from the `Github repo`_. You can either clone the public repository: @@ -46,7 +46,7 @@ Once you have a copy of the source, you can install it with: .. _Github repo: https://github.com/gpt-engineer-org/gpt-engineer.git Troubleshooting ---------------- +------------- For mac and linux system, there are sometimes slim python installations that do not include the gpt-engineer requirement tkinter, which is a standard library and thus not pip installable. diff --git a/docs/intro/ai_class.md b/docs/intro/ai_class.md deleted file mode 100644 index e880bc05cc..0000000000 --- a/docs/intro/ai_class.md +++ /dev/null @@ -1,11 +0,0 @@ -# AI Class Documentation -The AI class is the main interface to the GPT-4 model. It provides methods to start a conversation with the model, continue an existing conversation, and format system and user messages. The AI class is defined in the `gpt_engineer/ai.py` file. - -
- -## Methods -`__init__(self, model="gpt-4", temperature=0.1)`: The constructor takes the name of the AI model and the temperature parameter as arguments. It tries to retrieve the specified model from OpenAI. If the model is not available, it reverts to a fallback model. - -`start(self, system, user)`: This method starts a conversation with the AI. It takes a system message and a user message as arguments, and returns the AI's response. - -`next(self, messages: list[dict[str, str]], prompt=None)`: This method continues a conversation with the AI. It takes a list of messages and an optional prompt as arguments, and returns the AI's response. diff --git a/docs/intro/chat_parsing.md b/docs/intro/chat_parsing.md deleted file mode 100644 index 1ffc079e18..0000000000 --- a/docs/intro/chat_parsing.md +++ /dev/null @@ -1,39 +0,0 @@ -# Chat Parsing and Self-Execution of Code -The `chat_to_files.py` module plays a pivotal role in the self-execution of code generated by the AI. It parses the chat generated by the AI, extracts the code blocks, and saves them as files in the workspace. This process is crucial for making the project files a reality and enabling the self-execution of the generated code. The module is defined in the `gpt_engineer/chat_to_files.py` file. - -
- -## Functions -Here are the functions defined in the `chat_to_files.py` module: - -`parse_chat(chat)`: This function takes the chat as an argument and returns a list of tuples. Each tuple contains a filename and the corresponding file content. The function uses regular expressions to extract the filenames and the file contents from the chat. The filenames are cleaned up to remove any non-allowed characters. - -`to_files_and_memory(chat, dbs)`: This function takes the chat and the DBs as arguments. DBs contains the workspace and memory path. The function first saves the entire chat as a text file in the memory path. Then it calls the to_files function to write each file to the workspace. - -`to_files(chat, db)`: This function takes the chat and workspace DB as arguments. It calls the parse_chat function to parse the chat and get the files. Each file is then saved to the workspace. - -
- -## Self Code Execution -The `chat_to_files.py` module enables the self-execution of the code generated by the AI. When GPT-Engineer runs, it generates a chat that contains the AI's responses. These responses include code blocks that are intended to be saved as files. Each code block is preceded by a filename. - -
- -The `to_files` function is called with the chat and the workspace as arguments. It first saves the entire chat as a text file in the workspace. Then it calls the parse_chat function to parse the chat and extract the filenames and the file contents. - -
- -The `parse_chat` function uses regular expressions to find all code blocks and the preceding filenames in the chat. It cleans up the filenames and pairs them with the corresponding file contents. These pairs are then returned as a list of tuples. - -
- -Back in the `to_files` function, each tuple in the list is unpacked into a filename and a file content. Each file is then saved to the workspace with the corresponding filename and content. - -
- -Once the files are saved in the workspace, GPT-Engineer can then execute the code in the files by user permission. This enables the self-execution of the code generated by the AI. - -
- -## Disclaimer -While the self-execution of code is a powerful feature, it should be used with caution. The code generated by the AI is based on the prompts provided by the user and the training data of the AI model. It may not always produce the expected results, and in some cases, it may produce incorrect or harmful results. Always review the generated code before executing it, and never execute code that you do not understand or trust. diff --git a/docs/intro/db_class.md b/docs/intro/db_class.md deleted file mode 100644 index 87b156a8f4..0000000000 --- a/docs/intro/db_class.md +++ /dev/null @@ -1,33 +0,0 @@ -# DB Class -The DB class represents a simple database that stores its data as files in a directory. It is a key-value store, where keys are filenames and values are file contents. The DB class is defined in the `gpt_engineer/db.py` file. - -
- -### DB Class -Methods and how they are being used: - -`__init__(self, path)`: The constructor takes a path as an argument and creates a directory at that path if it does not already exist. - -`__contains__(self, key)`: This method checks if a key (filename) exists in the database. It returns True if the file exists and False otherwise. - -`__getitem__(self, key)`: This method gets the value (file content) associated with a key (filename). It raises a `KeyError` if the key does not exist in the database. - -`__setitem__(self, key, val)`: This method sets the value (file content) associated with a key (filename). It creates the file if it does not already exist. The value must be either a string or bytes. - -
- -### DBs Class -The DBs class is a dataclass that contains instances of the DB class for different types of data: - -Each instance of the DBs class contains five databases currently: - -`memory`: This database is used to store the AI's memory. -`logs`: This database is used to store logs of the AI's actions. -`preprompts`: This database is used to store preprompts that guide the AI's actions. -`input`: This database is used to store the user's input. -`workspace`: This database is used to store the AI's workspace, which includes the code it generates. - -
- -## Conclusion -The DB and DBs classes provide a simple and flexible way to manage data in the GPT-Engineer system. They allow the system to store and retrieve data as files in a directory, which makes it easy to inspect and modify the data. diff --git a/docs/intro/gate.md b/docs/intro/gate.md deleted file mode 100644 index b3caa26856..0000000000 --- a/docs/intro/gate.md +++ /dev/null @@ -1,34 +0,0 @@ -# GPT-Engineer - -GPT-Engineer is an open-source project that leverages the capabilities of OpenAI's GPT-4 model to automate various software engineering tasks. It is designed to interact with the GPT-4 model in a conversational manner, guiding the model to generate code, clarify instructions, generate specifications, and more. The project is built with a modular architecture, making it easy to extend and customize for various use cases. - -## Core Components - -GPT-Engineer is composed of several core components that work together to provide its functionality: - -- **AI Class**: The AI class serves as the main interface to the GPT-4 model. It provides methods to start a conversation with the model, continue an existing conversation, and format system and user messages. - -- **DB Class**: The DB class represents a simple database that stores its data as files in a directory. It is a key-value store, where keys are filenames and values are file contents. - -- **Steps Module**: The steps module defines a series of steps that the AI can perform to generate code, clarify instructions, generate specifications, and more. Each step is a function that takes an AI and a set of databases as arguments and returns a list of messages. - -## Usage - -GPT-Engineer is designed to be easy to use, even for users without a background in coding. Users can write prompts in plain English, and GPT-Engineer will guide the GPT-4 model to generate the desired output. The generated code is saved as files in a workspace, and can be executed independently of the GPT-Engineer system. - -## Development and Community - -GPT-Engineer is an open-source project, and contributions from the community are welcomed and encouraged. The project is hosted on GitHub, where users can report issues, suggest enhancements, and contribute code. - -## See Also - -- [User Guide](#user-guide) -- [AI Class Documentation](#ai-class) -- [DB Class Documentation](#db-class) -- [Steps Module Documentation](#steps-module) -- [Harmony of AI, DB, and Steps](#harmony-of-ai-db-and-steps) -- [Chat Parsing & Self Code Execution](#chat_to_files.py) - -## References - -- [GPT-Engineer GitHub Repository](https://github.com/gpt-engineer-org/gpt-engineer) diff --git a/docs/intro/harmony_db_ai_steps.md b/docs/intro/harmony_db_ai_steps.md deleted file mode 100644 index cd5b8f30cc..0000000000 --- a/docs/intro/harmony_db_ai_steps.md +++ /dev/null @@ -1,75 +0,0 @@ -# Harmony of AI, DB, and Steps -GPT-Engineer is a powerful tool that uses AI to automate software engineering tasks. It is designed with a modular architecture that makes it easy to extend and customize. The core components of GPT-Engineer are the AI class, the DB class, and the steps module. These components work together in harmony to provide a flexible and powerful system for automating software engineering tasks. - -
- -## AI Class -The AI class is the main interface to the GPT-3 model. It provides methods to start a conversation with the model, continue an existing conversation, and format system and user messages. The AI class is responsible for interacting with the GPT-3 model and generating the AI's responses. - -
- -## DB Class -The DB class represents a simple database that stores its data as files in a directory. It is a key-value store, where keys are filenames and values are file contents. The DB class is responsible for managing the data used by the GPT-Engineer system. - -
- -## Steps Module -The steps module defines a series of steps that the AI can perform to generate code, clarify instructions, generate specifications, and more. Each step is a function that takes an AI and a set of databases as arguments and returns a list of messages. The steps module is responsible for controlling the flow of the GPT-Engineer system. - -
- -### How Each Step is Made -Each step in the steps module is a function that takes an AI and a set of databases as arguments. The function performs a specific task, such as generating code or clarifying instructions, and returns a list of messages. The messages are then saved to the databases and used in subsequent steps. - -Here is an example of a step function: - -
- -```python -def simple_gen(ai: AI, dbs: FileRepositories): - """Generate code based on the main prompt.""" - system = dbs.preprompts["generate"] - user = dbs.input["main_prompt"] - messages = ai.start(system, user) - dbs.workspace["code.py"] = messages[-1]["content"] - return messages -``` -
- -This function uses the AI to generate code based on the main prompt. It reads the main prompt from the input database, generates the code, and saves the code to the workspace database. - -
- -### How to Make Your Own Step -To make your own step, you need to define a function that takes an AI and a set of databases as arguments. Inside the function, you can use the AI to generate responses and the databases to store and retrieve data. Here is an example: - -
- -```python -def generate_function(ai: AI, dbs: DBs): - """Generate a simple Python function.""" - function_name = dbs.input["function_name"] - function_description = dbs.input["function_description"] - system = "Please generate a Python function." - user = f"I want a function named '{function_name}' that {function_description}." - messages = ai.start(system, user) - dbs.workspace[f"{function_name}.py"] = messages[-1]["content"] - return messages -``` - -
- -In this custom step, we're asking the AI to generate a Python function based on a function name and a description provided by the user. The function name and description are read from the input database. The generated function is saved to the workspace database with a filename that matches the function name. You would simply need to provide a `function_name` file and `function_description` file with necessary details in the input database (your project folder) to use this step. - -
- -For example, if the user provides the function name "greet" and the description "prints 'Hello, world!'", the AI might generate the following Python function: - -```python -def greet(): - print('Hello, world!') -``` - -
- -This function would be saved to the workspace database as `greet.py`. diff --git a/docs/intro/main_script.md b/docs/intro/main_script.md deleted file mode 100644 index f128f9c5f2..0000000000 --- a/docs/intro/main_script.md +++ /dev/null @@ -1,43 +0,0 @@ -# Main Script -The `main.py` script is the entry point of the application. It sets up the AI model and the databases, and then runs a series of steps based on the provided configuration. The script uses the Typer library to create a command-line interface. - -
- -## Command-Line Interface -The script provides a command-line interface with several options: - -`project_path`: The path to the project directory. The default value is "example". - -`delete_existing`: A boolean flag that indicates whether to delete existing files in the project directory. The default value is `False`. - -`model`: The name of the AI model to use. The default value is "gpt-4". - -`temperature`: The temperature parameter for the AI model, which controls the randomness of the model's output. The default value is `0.1`. - -`steps_config`: The configuration of steps to run. The default value is "default". - -`verbose`: A boolean flag that controls the verbosity of the logging. If `True`, the logging level is set to `DEBUG`. Otherwise, the logging level is set to `INFO`. The default value is `False`. - -`run_prefix`: A prefix for the run, which can be used if you want to run multiple variants of the same project and later compare them. The default value is an empty string. - -
- -## Usage -To run the script, you can use the following command: - -``` -bash -python gpt_engineer/main.py --project_path [path] --delete_existing [True/False] --model [model] --temperature [temperature] --steps [steps_config] --verbose [True/False] --run_prefix [prefix] -``` - -You can replace the placeholders with the appropriate values. For example, to run the script with the default configuration on a project in the "my_project" directory, you can use the following command: - -``` -bash -python gpt_engineer/main.py --project_path my_project -``` - -
- -## Conclusion -The `main.py` script provides a flexible and user-friendly interface for running the GPT-Engineer system. It allows you to easily configure the AI model, the steps to run, and other parameters. The script also provides detailed logging, which can be useful for debugging and understanding the behavior of the system. diff --git a/docs/intro/preprompts.md b/docs/intro/preprompts.md deleted file mode 100644 index 9e8c2d54c2..0000000000 --- a/docs/intro/preprompts.md +++ /dev/null @@ -1,56 +0,0 @@ -# Preprompts - -The preprompts are a set of predefined prompts that guide the AI in performing different tasks. They are stored as text files in the `gpt_engineer/preprompts` directory. - -
- -### 1. Fix Code (`gpt_engineer/preprompts/fix_code`) - -This prompt instructs the AI to fix a program and make it work according to the best of its knowledge. The AI is expected to provide fully functioning, well-formatted code with few comments, that works and has no bugs. - -
- -### 2. Generate (`gpt_engineer/preprompts/generate`) - -This prompt instructs the AI to generate code based on a set of instructions. The AI is expected to think step by step and reason itself to the right decisions to make sure it gets it right. It should first lay out the names of the core classes, functions, methods that will be necessary, as well as a quick comment on their purpose. Then it should output the content of each file including ALL code. - -
- -### 3. Philosophy (`gpt_engineer/preprompts/philosophy`) - -This prompt provides the AI with a set of best practices to follow when writing code. For example, it instructs the AI to always put different classes in different files, to always create an appropriate requirements.txt file for Python, and to always follow the best practices for the requested languages in terms of describing the code written as a defined package/project. - -
- -### 4. QA (`gpt_engineer/preprompts/qa`) - -This prompt instructs the AI to read instructions and seek to clarify them. The AI is expected to first summarise a list of super short bullets of areas that need clarification. Then it should pick one clarifying question, and wait for an answer from the user. - -
- -### 5. Respec (`gpt_engineer/preprompts/respec`) - -This prompt instructs the AI to review a specification for a new feature and give feedback on it. The AI is expected to identify anything that might not work the way intended by the instructions, anything missing for the program to work as expected, and anything that can be simplified without significant drawback. - -
- -### 6. Spec (`gpt_engineer/preprompts/spec`) - -This prompt instructs the AI to make a specification for a program. The AI is expected to be super explicit about what the program should do, which features it should have, and give details about anything that might be unclear. - -
- -### 7. Unit Tests (`gpt_engineer/preprompts/unit_tests`) - -This prompt instructs the AI to write tests according to a specification using Test Driven Development. The tests should be as simple as possible, but still cover all the functionality. - -
- -### 8. Use Feedback (`gpt_engineer/preprompts/use_feedback`) -This prompt instructs the AI to generate code based on a set of instructions and feedback defined by the user. - -
- -## Conclusion - -GPT-Engineer provides a powerful tool for automating software engineering tasks using GPT-4. It includes a flexible framework for running different sequences of steps, each guided by a set of predefined prompts. The AI is expected to follow best practices and reason itself to the right decisions to ensure high-quality code generation. diff --git a/docs/intro/repository_stats.md b/docs/intro/repository_stats.md deleted file mode 100644 index d44abf2bc7..0000000000 --- a/docs/intro/repository_stats.md +++ /dev/null @@ -1,20 +0,0 @@ -# Repository Overview - -The GPT-Engineer repository is a project developed by Anton Osika, which uses GPT-4 to automate the process of software engineering. The repository is written in Python and is publicly available on GitHub. - -
- - -## Contributing -Contributions are welcome. If you want to contribute, please check out the [roadmap](https://github.com/gpt-engineer-org/gpt-engineer/blob/main/ROADMAP.md), [projects](https://github.com/gpt-engineer-org/gpt-engineer/projects?query=is%3Aopen) or [issues tab](https://github.com/gpt-engineer-org/gpt-engineer/issues) in the GitHub repo. You can also join the [Discord](https://discord.gg/4t5vXHhu) for discussions. - -
- -## Example -You can find an example of the project in action [here](https://github.com/gpt-engineer-org/gpt-engineer/assets/4467025/6e362e45-4a94-4b0d-973d-393a31d92d9b). - - diff --git a/docs/intro/scripts.md b/docs/intro/scripts.md deleted file mode 100644 index 81ac9dfb0d..0000000000 --- a/docs/intro/scripts.md +++ /dev/null @@ -1,27 +0,0 @@ -# Scripts -GPT-Engineer includes several Python scripts that provide additional functionality, such as running benchmarks, cleaning benchmarks, printing chat logs, and rerunning edited message logs. These scripts are located in the scripts directory. - -
- -### 1. Benchmark Script (`scripts/benchmark.py`) -The benchmark script runs a series of benchmarks to evaluate the performance of the GPT-Engineer system. It iterates over all folders in the benchmark directory and runs the benchmark for each folder. The results are saved to a log file in the benchmark folder. - -
- -### 2. Clean Benchmarks Script (`scripts/clean_benchmarks.py`) -The clean benchmarks script is used to clean up the benchmark folders after running the benchmarks. It iterates over all folders in the benchmark directory and deletes all files and directories except for the main_prompt file. - -
- -### 3. Print Chat Script (`scripts/print_chat.py`) -The print chat script is used to print a chat conversation in a human-readable format. It takes a JSON file containing a list of messages and prints each message with a color that corresponds to the role of the message sender (system, user, or assistant). - -
- -### 4. Rerun Edited Message Logs Script (`scripts/rerun_edited_message_logs.py`) -The rerun edited message logs script is used to rerun a conversation with the AI after editing the message logs. It takes a JSON file containing a list of messages, reruns the conversation with the AI, and saves the new messages to an output file. - -
- -## Conclusion -The scripts included in the GPT-Engineer repository provide additional functionality for running benchmarks, cleaning up after benchmarks, printing chat logs, and rerunning conversations with the AI. They are an integral part of the GPT-Engineer system and contribute to its flexibility and ease of use. diff --git a/docs/intro/steps_module.md b/docs/intro/steps_module.md deleted file mode 100644 index 2219ed0b54..0000000000 --- a/docs/intro/steps_module.md +++ /dev/null @@ -1,54 +0,0 @@ -# Steps Module -The steps module defines a series of steps that the AI can perform to generate code, clarify instructions, generate specifications, and more. Each step is a function that takes an AI and a set of databases as arguments and returns a list of messages. The steps are defined in the `gpt_engineer/steps.py` file. - -
- -## Steps -Here are the steps defined in the steps module: - -`setup_sys_prompt(dbs)`: This function sets up the system prompt by combining the generate preprompt and the philosophy preprompt. - -`simple_gen(ai: AI, dbs: DBs)`: This function runs the AI on the main prompt and saves the results. - -`clarify(ai: AI, dbs: DBs)`: This function asks the user if they want to clarify anything and saves the results to the workspace. - -`gen_spec(ai: AI, dbs: DBs)`: This function generates a spec from the main prompt + clarifications and saves the results to the workspace. - -`respec(ai: AI, dbs: DBs)`: This function asks the AI to review a specification for a new feature and give feedback on it. - -`gen_unit_tests(ai: AI, dbs: DBs)`: This function generates unit tests based on the specification. - -`gen_clarified_code(ai: AI, dbs: DBs)`: This function generates code based on the main prompt and clarifications. - -`gen_code(ai: AI, dbs: DBs)`: This function generates code based on the specification and unit tests. - -`execute_entrypoint(ai, dbs)`: This function executes the entrypoint of the generated code. - -`gen_entrypoint(ai, dbs)`: This function generates the entrypoint for the generated code. - -`use_feedback(ai: AI, dbs: DBs)`: This function uses feedback from the user to improve the generated code. - -`fix_code(ai: AI, dbs: DBs)`: This function fixes any errors in the generated code. - -
- -## Configurations -Different configurations of steps are defined in the STEPS dictionary. Each configuration is a list of steps that are run in order. - -The available configurations are: -```python -DEFAULT: clarify, gen_clarified_code, gen_entrypoint, execute_entrypoint -BENCHMARK: simple_gen, gen_entrypoint -SIMPLE: simple_gen, gen_entrypoint, execute_entrypoint -TDD: gen_spec, gen_unit_tests, gen_code, gen_entrypoint, execute_entrypoint -TDD_PLUS: gen_spec, gen_unit_tests, gen_code, fix_code, gen_entrypoint, execute_entrypoint -CLARIFY: clarify, gen_clarified_code, gen_entrypoint, execute_entrypoint -RESPEC: gen_spec, respec, gen_unit_tests, gen_code, fix_code, gen_entrypoint, execute_entrypoint -USE_FEEDBACK: use_feedback, gen_entrypoint, execute_entrypoint -EXECUTE_ONLY: execute_entrypoint -``` - -
- -## Conclusion -The steps module provides a flexible framework for running different sequences of steps in the GPT-Engineer system. Each step is a function that performs a specific task, such as generating code, clarifying instructions, or executing the generated code. The steps can be combined in different configurations to achieve different outcomes. diff --git a/docs/intro/quick_overview.md b/docs/introduction.md similarity index 84% rename from docs/intro/quick_overview.md rename to docs/introduction.md index 2c3ef2f97e..7038874411 100644 --- a/docs/intro/quick_overview.md +++ b/docs/introduction.md @@ -1,4 +1,4 @@ -# GPT-Engineer Documentation +# Introduction GPT-Engineer is a project that uses LLMs (such as GPT-4) to automate the process of software engineering. It includes several Python scripts that interact with the LLM to generate code, clarify requirements, generate specifications, and more.
@@ -57,3 +57,18 @@ The main steps are: ### 6. Main Script (`gpt_engineer/applications/cli/main.py`) The main script is the is the entry point of the application and uses the `Typer` library to create a command-line interface. It sets up instances of an [`AI`](ai_class), a [`Files Dictionary`](files_dictionary_class), a `BaseMemory`, a `BaseExecutionEnv` and an [`Agent`](agent_class) that runs a series of [steps](steps) based on the provided configuration. + +## Repository Overview + +The GPT-Engineer repository is a project developed by Anton Osika, which uses GPT-4 to automate the process of software engineering. The repository is written in Python and is publicly available on GitHub. + +
+ +## Example +You can find an example of the project in action [here](https://github.com/gpt-engineer-org/gpt-engineer/assets/4467025/6e362e45-4a94-4b0d-973d-393a31d92d9b). + + diff --git a/docs/usage.rst b/docs/usage.rst index 1a1ab9ad5d..0ad919d4f4 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -1,31 +1,55 @@ ===== -Usage +Quickstart ===== -Setup +Setup API Key ===== -With an OpenAI API key (preferably with GPT-4 access) run: +Choose one of the following: -- `export OPENAI_API_KEY=[your api key]` +- Export env variable (you can add this to .bashrc so that you don't have to do it each time you start the terminal) -To set API key on windows check the [Windows README](.github/WINDOWS_README.md). + .. code-block:: console + + $ export OPENAI_API_KEY=[your api key] + +- Add it to the .env file: + + - Create a copy of .env.template named .env + - Add your ``OPENAI_API_KEY`` in .env + +- If you want to use a custom model, visit our docs on `using open models and azure models <./open_models.html>`_. + +- To set API key on windows check the `Windows README <./windows_readme_link.html>`_. Run === -- Create an empty folder. If inside the repo, you can run: - - `cp -r projects/example/ projects/my-new-project` -- Fill in the `prompt` file in your new folder -- `gpt-engineer projects/my-new-project` - - (Note, `gpt-engineer --help` lets you see all available options. For example `--steps use_feedback` lets you improve/fix code in a project) +Create new code (default usage) +------------------------------- + +- Create an empty folder for your project anywhere on your computer +- Create a file called prompt (no extension) inside your new folder and fill it with instructions +- Run gpte with a relative path to your folder +- For example, if you create a new project inside the gpt-engineer /projects directory: + + .. code-block:: console + + $ gpte projects/my-new-project + +Improve Existing Code +--------------------- + +- Locate a folder with code which you want to improve anywhere on your computer +- Create a file called prompt (no extension) inside your new folder and fill it with instructions for how you want to improve the code +- Run gpte -i with a relative path to your folder +- For example, if you want to run it against an existing project inside the gpt-engineer /projects directory: -By running gpt-engineer you agree to our [terms](https://github.com/gpt-engineer-org/gpt-engineer/blob/main/TERMS_OF_USE.md). + .. code-block:: console -Results -======= -- Check the generated files in `projects/my-new-project/workspace` + $ gpte projects/my-old-project -i +By running gpt-engineer you agree to our `terms <./terms_link.html>`_. To **run in the browser** you can simply: From 35ba08bd79a3fa83f41d5c13a6b4a1181e7d8cf7 Mon Sep 17 00:00:00 2001 From: kristiankyvik Date: Fri, 23 Feb 2024 00:07:16 +0100 Subject: [PATCH 02/11] commiting changes of api_reference.rst --- docs/api_reference.rst | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/api_reference.rst b/docs/api_reference.rst index 42a1f26a3d..1f0912e09d 100644 --- a/docs/api_reference.rst +++ b/docs/api_reference.rst @@ -33,6 +33,7 @@ Functions applications.cli.collect.collect_learnings applications.cli.collect.send_learning applications.cli.learning.ask_collection_consent + applications.cli.learning.ask_for_valid_input applications.cli.learning.check_collection_consent applications.cli.learning.extract_learning applications.cli.learning.get_session @@ -103,10 +104,11 @@ Functions :toctree: core core.ai.serialize_messages - core.chat_to_files.apply_edits + core.chat_to_files.apply_diffs core.chat_to_files.chat_to_files_dict - core.chat_to_files.overwrite_code_with_edits - core.chat_to_files.parse_edits + core.chat_to_files.parse_diff_block + core.chat_to_files.parse_diffs + core.chat_to_files.parse_hunk_header core.default.paths.memory_path core.default.paths.metadata_path core.default.simple_agent.default_config_agent @@ -115,9 +117,12 @@ Functions core.default.steps.gen_code core.default.steps.gen_entrypoint core.default.steps.improve - core.default.steps.incorrect_edit + core.default.steps.salvage_correct_hunks core.default.steps.setup_sys_prompt core.default.steps.setup_sys_prompt_existing_code + core.diff.count_ratio + core.diff.is_similar + core.files_dict.file_to_lines_dict :mod:`gpt_engineer.tools`: Tools ================================= From c3681dea83836c2d8de11b052960960246f3034d Mon Sep 17 00:00:00 2001 From: kristiankyvik Date: Fri, 23 Feb 2024 00:10:50 +0100 Subject: [PATCH 03/11] fixed error raised by doc buulding process --- docs/custom_steps.md | 57 +++++++++++++++++++++++++++++++++++++++++++ docs/installation.rst | 2 +- docs/results_link.rst | 2 -- docs/usage.rst | 6 ++--- 4 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 docs/custom_steps.md delete mode 100644 docs/results_link.rst diff --git a/docs/custom_steps.md b/docs/custom_steps.md new file mode 100644 index 0000000000..f9a397550c --- /dev/null +++ b/docs/custom_steps.md @@ -0,0 +1,57 @@ +# Customizing steps + +### How Each Step is Made +Each step in the steps module is a function that takes an AI and a set of databases as arguments. The function performs a specific task, such as generating code or clarifying instructions, and returns a list of messages. The messages are then saved to the databases and used in subsequent steps. + +Here is an example of a step function: + +
+ +```python +def simple_gen(ai: AI, dbs: FileRepositories): + """Generate code based on the main prompt.""" + system = dbs.preprompts["generate"] + user = dbs.input["main_prompt"] + messages = ai.start(system, user) + dbs.workspace["code.py"] = messages[-1]["content"] + return messages +``` +
+ +This function uses the AI to generate code based on the main prompt. It reads the main prompt from the input database, generates the code, and saves the code to the workspace database. + +
+ +### How to Make Your Own Step +To make your own step, you need to define a function that takes an AI and a set of databases as arguments. Inside the function, you can use the AI to generate responses and the databases to store and retrieve data. Here is an example: + +
+ +```python +def generate_function(ai: AI, dbs: DBs): + """Generate a simple Python function.""" + function_name = dbs.input["function_name"] + function_description = dbs.input["function_description"] + system = "Please generate a Python function." + user = f"I want a function named '{function_name}' that {function_description}." + messages = ai.start(system, user) + dbs.workspace[f"{function_name}.py"] = messages[-1]["content"] + return messages +``` + +
+ +In this custom step, we're asking the AI to generate a Python function based on a function name and a description provided by the user. The function name and description are read from the input database. The generated function is saved to the workspace database with a filename that matches the function name. You would simply need to provide a `function_name` file and `function_description` file with necessary details in the input database (your project folder) to use this step. + +
+ +For example, if the user provides the function name "greet" and the description "prints 'Hello, world!'", the AI might generate the following Python function: + +```python +def greet(): + print('Hello, world!') +``` + +
+ +This function would be saved to the workspace database as `greet.py`. diff --git a/docs/installation.rst b/docs/installation.rst index 844c9471e3..4fbd3cd588 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -46,7 +46,7 @@ Once you have a copy of the source, you can install it with: .. _Github repo: https://github.com/gpt-engineer-org/gpt-engineer.git Troubleshooting -------------- +--------------- For mac and linux system, there are sometimes slim python installations that do not include the gpt-engineer requirement tkinter, which is a standard library and thus not pip installable. diff --git a/docs/results_link.rst b/docs/results_link.rst deleted file mode 100644 index d407b71049..0000000000 --- a/docs/results_link.rst +++ /dev/null @@ -1,2 +0,0 @@ -.. include:: ../benchmark/RESULTS.md - :parser: myst_parser.sphinx_ diff --git a/docs/usage.rst b/docs/usage.rst index 0ad919d4f4..01b2d5a668 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -1,9 +1,9 @@ -===== +========== Quickstart -===== +========== Setup API Key -===== +============= Choose one of the following: From b07a33a1c80e2805ab7517575a637f5a2cd1c439 Mon Sep 17 00:00:00 2001 From: kristiankyvik Date: Fri, 23 Feb 2024 00:11:57 +0100 Subject: [PATCH 04/11] addressed new errors raised by myst parser --- docs/custom_steps.md | 4 ++-- docs/readme_link.rst | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 docs/readme_link.rst diff --git a/docs/custom_steps.md b/docs/custom_steps.md index f9a397550c..8f192f3db9 100644 --- a/docs/custom_steps.md +++ b/docs/custom_steps.md @@ -1,6 +1,6 @@ # Customizing steps -### How Each Step is Made +## How Each Step is Made Each step in the steps module is a function that takes an AI and a set of databases as arguments. The function performs a specific task, such as generating code or clarifying instructions, and returns a list of messages. The messages are then saved to the databases and used in subsequent steps. Here is an example of a step function: @@ -22,7 +22,7 @@ This function uses the AI to generate code based on the main prompt. It reads th
-### How to Make Your Own Step +## How to Make Your Own Step To make your own step, you need to define a function that takes an AI and a set of databases as arguments. Inside the function, you can use the AI to generate responses and the databases to store and retrieve data. Here is an example:
diff --git a/docs/readme_link.rst b/docs/readme_link.rst deleted file mode 100644 index 339dc8f42d..0000000000 --- a/docs/readme_link.rst +++ /dev/null @@ -1,2 +0,0 @@ -.. include:: ../README.md - :parser: myst_parser.sphinx_ From 0a4c291635998bf3bf0ce812ab46aef741cf5f1f Mon Sep 17 00:00:00 2001 From: kristiankyvik Date: Fri, 23 Feb 2024 00:16:54 +0100 Subject: [PATCH 05/11] small fixes --- docs/DOCS_BUILDING.md | 3 ++- docs/tracing_debugging.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/DOCS_BUILDING.md b/docs/DOCS_BUILDING.md index b135580463..84c761120e 100644 --- a/docs/DOCS_BUILDING.md +++ b/docs/DOCS_BUILDING.md @@ -30,6 +30,7 @@ Update `repository_stats.md` file under `docs/intro` # Install required Python dependencies (MkDocs etc.) poetry install cd docs/ + # Create the `api_reference.rst` python create_api_rst.py @@ -37,7 +38,7 @@ python create_api_rst.py make html ## Alternatively, to rebuild the docs on changes with live-reload in the browser -sphinx-autobuild docs _build/html +sphinx-autobuild . _build/html ``` Project Docs Structure diff --git a/docs/tracing_debugging.md b/docs/tracing_debugging.md index 745b561098..0f443925fa 100644 --- a/docs/tracing_debugging.md +++ b/docs/tracing_debugging.md @@ -1,7 +1,7 @@ Tracing and Debugging with Weights and Biases ============================ -## **[How to store results in Weights & Biases]()** +## How to store results in Weights & Biases W&B Prompts is a suite of LLMOps tools built for the development of LLM-powered applications. Use W&B Prompts to visualize and inspect the execution flow of your LLMs, analyze the inputs and outputs of your LLMs, view the intermediate results and securely store and manage your prompts and LLM chain configurations. Read more at https://docs.wandb.ai/guides/prompts From 9067795315bd649a10c41b66d779e0355de94e98 Mon Sep 17 00:00:00 2001 From: kristiankyvik Date: Fri, 23 Feb 2024 00:17:37 +0100 Subject: [PATCH 06/11] added -i for improve example in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75653393be..fcde56d1a4 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Check the [Windows README](./WINDOWS_README.md) for windows usage. - Locate a folder with code which you want to improve anywhere on your computer - Create a file called `prompt` (no extension) inside your new folder and fill it with instructions for how you want to improve the code - Run `gpte -i` with a relative path to your folder - - For example: `gpte projects/my-old-project` from the gpt-engineer directory root with your folder in `projects/` + - For example: `gpte projects/my-old-project -i` from the gpt-engineer directory root with your folder in `projects/` By running gpt-engineer you agree to our [terms](https://github.com/gpt-engineer-org/gpt-engineer/blob/main/TERMS_OF_USE.md). From 15e4c113ba7c1d056b45f356c853d3563e4e82cd Mon Sep 17 00:00:00 2001 From: kristiankyvik Date: Fri, 23 Feb 2024 00:36:09 +0100 Subject: [PATCH 07/11] small updates --- WINDOWS_README.md | 2 +- docs/DOCS_BUILDING.md | 6 +++--- docs/installation.rst | 10 +++++----- docs/introduction.md | 2 +- docs/usage.rst | 18 +++++++++--------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/WINDOWS_README.md b/WINDOWS_README.md index 81943336fd..4b3d1f5d92 100644 --- a/WINDOWS_README.md +++ b/WINDOWS_README.md @@ -27,7 +27,7 @@ Or: For **development**: -- `git clone git@github.com:AntonOsika/gpt-engineer.git` +- `git clone git@github.com:gpt-engineer-org/gpt-engineer.git` - `cd gpt-engineer` - `poetry install` - `poetry shell` to activate the virtual environment diff --git a/docs/DOCS_BUILDING.md b/docs/DOCS_BUILDING.md index 84c761120e..52fc35a73c 100644 --- a/docs/DOCS_BUILDING.md +++ b/docs/DOCS_BUILDING.md @@ -16,15 +16,15 @@ Read the Docs Build configuration is stored in `.readthedocs.yaml`. Example Project usage --------------------- -`Poetry` is the package manager for `gpt-engineer`. In order to build documentation, we have to add docs requirements in +``Poetry`` is the package manager for ``gpt-engineer``. In order to build documentation, we have to add docs requirements in development environment. This project has a standard readthedocs layout which is built by Read the Docs almost the same way that you would build it locally (on your own laptop!). -You can build and view this documentation project locally - we recommend that you activate a `poetry shell`. +You can build and view this documentation project locally - we recommend that you activate a ``poetry shell``. -Update `repository_stats.md` file under `docs/intro` +Update ``repository_stats.md`` file under ``docs/intro`` ```console # Install required Python dependencies (MkDocs etc.) diff --git a/docs/installation.rst b/docs/installation.rst index 4fbd3cd588..6dc776bbcf 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -8,13 +8,13 @@ Installation Stable release -------------- -To install gpt-engineer, run this command in your terminal: +To install ``gpt-engineer``, run this command in your terminal: .. code-block:: console - $ pip install gpt_engineer + $ python -m pip install gpt-engineer -This is the preferred method to install gpt-engineer, as it will always install the most recent stable release. +This is the preferred method to install ``gpt-engineer``, as it will always install the most recent stable release. If you don't have `pip`_ installed, this `Python installation guide`_ can guide you through the process. @@ -26,7 +26,7 @@ you through the process. From sources ------------ -The sources for gpt-engineer can be downloaded from the `Github repo`_. +The sources for ``gpt-engineer`` can be downloaded from the `Github repo`_. You can either clone the public repository: @@ -48,7 +48,7 @@ Once you have a copy of the source, you can install it with: Troubleshooting --------------- -For mac and linux system, there are sometimes slim python installations that do not include the gpt-engineer requirement tkinter, which is a standard library and thus not pip installable. +For mac and linux system, there are sometimes slim python installations that do not include the ``gpt-engineer`` requirement tkinter, which is a standard library and thus not pip installable. To install tkinter on mac, you can for example use brew: diff --git a/docs/introduction.md b/docs/introduction.md index 7038874411..a9d5177509 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -1,5 +1,5 @@ # Introduction -GPT-Engineer is a project that uses LLMs (such as GPT-4) to automate the process of software engineering. It includes several Python scripts that interact with the LLM to generate code, clarify requirements, generate specifications, and more. +``gpt-engineer`` is a project that uses LLMs (such as GPT-4) to automate the process of software engineering. It includes several Python scripts that interact with the LLM to generate code, clarify requirements, generate specifications, and more.
diff --git a/docs/usage.rst b/docs/usage.rst index 01b2d5a668..3f44fb5e23 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -7,7 +7,7 @@ Setup API Key Choose one of the following: -- Export env variable (you can add this to .bashrc so that you don't have to do it each time you start the terminal) +- Export env variable (you can add this to ``.bashrc`` so that you don't have to do it each time you start the terminal) .. code-block:: console @@ -15,7 +15,7 @@ Choose one of the following: - Add it to the .env file: - - Create a copy of .env.template named .env + - Create a copy of ``.env.template`` named ``.env`` - Add your ``OPENAI_API_KEY`` in .env - If you want to use a custom model, visit our docs on `using open models and azure models <./open_models.html>`_. @@ -29,9 +29,9 @@ Create new code (default usage) ------------------------------- - Create an empty folder for your project anywhere on your computer -- Create a file called prompt (no extension) inside your new folder and fill it with instructions -- Run gpte with a relative path to your folder -- For example, if you create a new project inside the gpt-engineer /projects directory: +- Create a file called ``prompt`` (no extension) inside your new folder and fill it with instructions +- Run ``gpte `` with a relative path to your folder +- For example, if you create a new project inside the gpt-engineer ``/projects`` directory: .. code-block:: console @@ -41,15 +41,15 @@ Improve Existing Code --------------------- - Locate a folder with code which you want to improve anywhere on your computer -- Create a file called prompt (no extension) inside your new folder and fill it with instructions for how you want to improve the code -- Run gpte -i with a relative path to your folder -- For example, if you want to run it against an existing project inside the gpt-engineer /projects directory: +- Create a file called ``prompt`` (no extension) inside your new folder and fill it with instructions for how you want to improve the code +- Run ``gpte -i`` with a relative path to your folder +- For example, if you want to run it against an existing project inside the gpt-engineer ``/projects`` directory: .. code-block:: console $ gpte projects/my-old-project -i -By running gpt-engineer you agree to our `terms <./terms_link.html>`_. +By running ``gpt-engineer`` you agree to our `terms <./terms_link.html>`_. To **run in the browser** you can simply: From faf6c65d27321927da4031934bb967974898871b Mon Sep 17 00:00:00 2001 From: kristiankyvik Date: Fri, 23 Feb 2024 10:32:20 +0100 Subject: [PATCH 08/11] small changes --- docs/index.rst | 4 ++-- docs/introduction.md | 9 +++++---- docs/{usage.rst => quickstart.rst} | 17 ++++++++++++++--- 3 files changed, 21 insertions(+), 9 deletions(-) rename docs/{usage.rst => quickstart.rst} (86%) diff --git a/docs/index.rst b/docs/index.rst index 9813ad72cd..faa6599f7c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -7,15 +7,15 @@ Welcome to GPT-ENGINEER's Documentation introduction.md installation - usage + quickstart .. toctree:: :maxdepth: 2 :caption: USER GUIDES: windows_readme_link - custom_steps.md open_models.md + custom_steps.md tracing_debugging.md .. toctree:: diff --git a/docs/introduction.md b/docs/introduction.md index a9d5177509..a9b0c9c682 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -3,6 +3,11 @@
+### Get started +[Here’s](/installation.html) how to install ``gpt-engineer``, set up your environment, and start building. + +We recommend following our [Quickstart](/quickstart.html) guide to familiarize yourself with the framework by building your first application with ``gpt-engineer``. + ## Core Components (ai_class)= @@ -58,10 +63,6 @@ The main steps are: ### 6. Main Script (`gpt_engineer/applications/cli/main.py`) The main script is the is the entry point of the application and uses the `Typer` library to create a command-line interface. It sets up instances of an [`AI`](ai_class), a [`Files Dictionary`](files_dictionary_class), a `BaseMemory`, a `BaseExecutionEnv` and an [`Agent`](agent_class) that runs a series of [steps](steps) based on the provided configuration. -## Repository Overview - -The GPT-Engineer repository is a project developed by Anton Osika, which uses GPT-4 to automate the process of software engineering. The repository is written in Python and is publicly available on GitHub. -
## Example diff --git a/docs/usage.rst b/docs/quickstart.rst similarity index 86% rename from docs/usage.rst rename to docs/quickstart.rst index 3f44fb5e23..ee26403192 100644 --- a/docs/usage.rst +++ b/docs/quickstart.rst @@ -2,6 +2,17 @@ Quickstart ========== +Installation +============ + +To install LangChain run: + +.. code-block:: console + + $ python -m pip install gpt-engineer + +For more details, see our [Installation guide](/instllation.html). + Setup API Key ============= @@ -13,7 +24,7 @@ Choose one of the following: $ export OPENAI_API_KEY=[your api key] -- Add it to the .env file: +- Add it to the ``.env`` file: - Create a copy of ``.env.template`` named ``.env`` - Add your ``OPENAI_API_KEY`` in .env @@ -22,8 +33,8 @@ Choose one of the following: - To set API key on windows check the `Windows README <./windows_readme_link.html>`_. -Run -=== +Building with ``gpt-engineer`` +============================== Create new code (default usage) ------------------------------- From c86c9ae929761c8972e3d7293501ebb650eb0745 Mon Sep 17 00:00:00 2001 From: kristiankyvik Date: Fri, 1 Mar 2024 21:17:03 +0100 Subject: [PATCH 09/11] removed the core components section --- docs/introduction.md | 55 -------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/docs/introduction.md b/docs/introduction.md index a9b0c9c682..4fc81aa8eb 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -8,61 +8,6 @@ We recommend following our [Quickstart](/quickstart.html) guide to familiarize yourself with the framework by building your first application with ``gpt-engineer``. -## Core Components - -(ai_class)= -### 1. AI Class (`gpt_engineer/core/ai.py`) -The `AI` class is the main interface to the LLM. It provides methods to start a conversation with the model, continue an existing conversation, and format system and user messages. - -
- -(agent_class)= -### 2. Agent Class (`gpt_engineer/applications/cli/cli_agent.py`) -The `Agent` class is responsible for managing the lifecycle of code generation and improvement. Its main functions are: - -- `init(self, prompt)`: Generates a new piece of code using the AI based on the provided prompt. It also generates a entrypoint file based on the generated code. - -- `improve(self, files_dict, prompt)`: Improves an existing piece of code using the AI class based on the provided prompt and files dictionary. - -
- -(files_dictionary_class)= -### 3. Files Dictionary Class (`gpt_engineer/core/files_dict.py`) -The `Files Dictionary` class extends the standard dictionary to enforce string keys and values, representing filenames and their corresponding code content. It provides a method to format its contents for chat-based interaction with the `AI` class. - -
- -### 4. Chat to Files (`gpt_engineer/core/chat_to_files.py`) -This module provides utilities to handle and process chat content, including parsing chat messages to retrieve code blocks, storing these blocks in the [`Files Dictionary`](files_dictionary_class), and overwriting the files based on new chat messages. The module contains four main functions: - -- `chat_to_files_dict(chat)`: This function takes a chat conversation and extracts all the code blocks and preceding filenames. It returns an instance of [`Files Dictionary`](files_dictionary_class) representing filenames and their corresponding code content. - -- `parse_edits(chat)`: This function parses edits from a chat and returns them as a list of `Edit` class objects. - -- `apply_edits(edits, files_dict)`: This function takes a list of Edit objects and applies each edit to the code object. It handles the creation of new files and the modification of existing files when required. - -- `overwrite_code_with_edits(chat, files_dict)`: This function takes a chat string, and employs the `parse_edits` function to parse it for edits, before applying the edits to the relevant code object via the `apply_edits` function. - -
- -(steps)= -### 5. Steps (`gpt_engineer/core/default/steps.py`) -This module defines a series of steps that can be run by the agent. -The main steps are: - -- `gen_code(ai, prompt, memory, preprompts_holder)`: Generate new code based on the specification. - -- `gen_entrypoint(ai, files_dict, memory, preprompts_holder)`: Generate an entrypoint file code based on the generated code. - -- `execute_entrypoint(ai, execution_env, files_dict, preprompts_holder)`: Uses the entrypoint file to run the generated code inside the execution environment. - -- `improve(ai, prompt, files_dict, memory, preprompts_holder)`: Improves an existing codebase based on the provided specifications. - -
- -### 6. Main Script (`gpt_engineer/applications/cli/main.py`) -The main script is the is the entry point of the application and uses the `Typer` library to create a command-line interface. It sets up instances of an [`AI`](ai_class), a [`Files Dictionary`](files_dictionary_class), a `BaseMemory`, a `BaseExecutionEnv` and an [`Agent`](agent_class) that runs a series of [steps](steps) based on the provided configuration. -
## Example From a82aeaae29becab7fe453e27988d3729a772b828 Mon Sep 17 00:00:00 2001 From: kristiankyvik Date: Fri, 1 Mar 2024 21:18:16 +0100 Subject: [PATCH 10/11] removed the custom steps file --- docs/custom_steps.md | 57 -------------------------------------------- docs/index.rst | 1 - 2 files changed, 58 deletions(-) delete mode 100644 docs/custom_steps.md diff --git a/docs/custom_steps.md b/docs/custom_steps.md deleted file mode 100644 index 8f192f3db9..0000000000 --- a/docs/custom_steps.md +++ /dev/null @@ -1,57 +0,0 @@ -# Customizing steps - -## How Each Step is Made -Each step in the steps module is a function that takes an AI and a set of databases as arguments. The function performs a specific task, such as generating code or clarifying instructions, and returns a list of messages. The messages are then saved to the databases and used in subsequent steps. - -Here is an example of a step function: - -
- -```python -def simple_gen(ai: AI, dbs: FileRepositories): - """Generate code based on the main prompt.""" - system = dbs.preprompts["generate"] - user = dbs.input["main_prompt"] - messages = ai.start(system, user) - dbs.workspace["code.py"] = messages[-1]["content"] - return messages -``` -
- -This function uses the AI to generate code based on the main prompt. It reads the main prompt from the input database, generates the code, and saves the code to the workspace database. - -
- -## How to Make Your Own Step -To make your own step, you need to define a function that takes an AI and a set of databases as arguments. Inside the function, you can use the AI to generate responses and the databases to store and retrieve data. Here is an example: - -
- -```python -def generate_function(ai: AI, dbs: DBs): - """Generate a simple Python function.""" - function_name = dbs.input["function_name"] - function_description = dbs.input["function_description"] - system = "Please generate a Python function." - user = f"I want a function named '{function_name}' that {function_description}." - messages = ai.start(system, user) - dbs.workspace[f"{function_name}.py"] = messages[-1]["content"] - return messages -``` - -
- -In this custom step, we're asking the AI to generate a Python function based on a function name and a description provided by the user. The function name and description are read from the input database. The generated function is saved to the workspace database with a filename that matches the function name. You would simply need to provide a `function_name` file and `function_description` file with necessary details in the input database (your project folder) to use this step. - -
- -For example, if the user provides the function name "greet" and the description "prints 'Hello, world!'", the AI might generate the following Python function: - -```python -def greet(): - print('Hello, world!') -``` - -
- -This function would be saved to the workspace database as `greet.py`. diff --git a/docs/index.rst b/docs/index.rst index faa6599f7c..11a428de13 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -15,7 +15,6 @@ Welcome to GPT-ENGINEER's Documentation windows_readme_link open_models.md - custom_steps.md tracing_debugging.md .. toctree:: From d845a5c70ad5ad901031f87cb42cafa738622597 Mon Sep 17 00:00:00 2001 From: kristiankyvik Date: Fri, 1 Mar 2024 21:26:02 +0100 Subject: [PATCH 11/11] fixed heading error --- docs/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/introduction.md b/docs/introduction.md index 4fc81aa8eb..7e88f83405 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -3,7 +3,7 @@
-### Get started +## Get started [Here’s](/installation.html) how to install ``gpt-engineer``, set up your environment, and start building. We recommend following our [Quickstart](/quickstart.html) guide to familiarize yourself with the framework by building your first application with ``gpt-engineer``.