API Reference

gpt_engineer.applications: Applications

Classes

applications.cli.cli_agent.CliAgent(memory, ...)

The CliAgent class is responsible for managing the lifecycle of code generation and improvement using an AI model.

applications.cli.file_selector.DisplayablePath(...)

Represents and displays a file system path in a tree-like structure.

Functions

applications.cli.collect.collect_and_send_human_review(...)

Collects human feedback on the code and sends it for analysis.

applications.cli.collect.collect_learnings(...)

Collect the learning data and send it to RudderStack for analysis.

applications.cli.collect.send_learning(learning)

Send the learning data to RudderStack for analysis.

applications.cli.learning.ask_collection_consent()

Asks the user for their consent to store their data for the purpose of improving the GPT Engineer tool.

applications.cli.learning.ask_for_valid_input(ran)

applications.cli.learning.check_collection_consent()

Checks if the user has previously given consent to store their data for feedback collection.

applications.cli.learning.extract_learning(...)

Constructs a Learning object containing the session's metadata and user feedback.

applications.cli.learning.get_session()

Retrieves or generates a unique identifier for the current user session.

applications.cli.learning.human_review_input()

Interactively prompts the user to review the generated code and returns their feedback encapsulated in a Review object.

applications.cli.main.compare(f1, f2)

applications.cli.main.concatenate_paths(...)

applications.cli.main.format_installed_packages(...)

applications.cli.main.get_installed_packages()

applications.cli.main.get_preprompts_path(...)

Get the path to the preprompts, using custom ones if specified.

applications.cli.main.get_system_info()

applications.cli.main.load_env_if_needed()

Load environment variables if the OPENAI_API_KEY is not already set.

applications.cli.main.load_prompt(...[, ...])

Load or request a prompt from the user based on the mode.

applications.cli.main.main([project_path, ...])

The main entry point for the CLI tool that generates or improves a project.

applications.cli.main.prompt_yesno()

gpt_engineer.benchmark: Benchmark

Functions

benchmark.__main__.get_agent(path)

Dynamically imports and returns the default configuration agent from the given path.

benchmark.__main__.main(path_to_agent[, ...])

The main function that runs the specified benchmarks with the given agent and outputs the results to the console.

benchmark.benchmarks.apps.load.load_apps(config)

Loads the APPS benchmark, which consists of a series coding problems.

benchmark.benchmarks.gptme.load.load_gptme(config)

Loads the GPT-Me benchmark, which consists of a series of tasks for evaluation.

benchmark.benchmarks.load.get_benchmark(...)

Retrieves a Benchmark object by name.

benchmark.benchmarks.mbpp.load.load_mbpp(config)

Loads the MBPP benchmark, which consists of a series coding problems.

benchmark.run.export_yaml_results(yaml_path, ...)

benchmark.run.print_results(results)

Prints the results of the benchmark tasks to the console.

benchmark.run.run(agent, benchmark[, verbose])

Runs the benchmark tasks using the provided agent and returns a list of TaskResult objects.

gpt_engineer.core: Core

Classes

core.ai.ClipboardAI(**_)

Initialize the AI class.

core.base_agent.BaseAgent()

Abstract base class for an agent that interacts with code.

core.base_execution_env.BaseExecutionEnv()

Abstract base class for an execution environment capable of running code.

core.default.disk_execution_env.DiskExecutionEnv([path])

An execution environment that runs code on the local file system and captures the output of the execution.

core.default.disk_memory.DiskMemory(path)

A file-based key-value store where keys correspond to filenames and values to file contents.

core.default.simple_agent.SimpleAgent(...[, ...])

An agent that uses AI to generate and improve code based on a given prompt.

core.default.steps.Tee(*files)

core.files_dict.FilesDict

A dictionary-based container for managing code files.

core.version_manager.BaseVersionManager(path)

Abstract base class for a version manager.

Functions

core.ai.serialize_messages(messages)

core.chat_to_files.apply_diffs(diffs, files)

Applies diffs to the provided files.

core.chat_to_files.chat_to_files_dict(chat)

Converts a chat string containing file paths and code blocks into a FilesDict object.

core.chat_to_files.parse_diff_block(diff_block)

Parses a block of diff text into a Diff object.

core.chat_to_files.parse_diffs(diff_string)

Parses a diff string in the unified git diff format.

core.chat_to_files.parse_hunk_header(header_line)

Parses the header of a hunk from a diff.

core.default.paths.memory_path(path)

Constructs the full path to the memory directory based on a given base path.

core.default.paths.metadata_path(path)

Constructs the full path to the metadata directory based on a given base path.

core.default.simple_agent.default_config_agent()

Creates an instance of SimpleAgent with default configuration.

core.default.steps.curr_fn()

Returns the name of the current function.

core.default.steps.execute_entrypoint(ai, ...)

Executes the entrypoint of the codebase.

core.default.steps.gen_code(ai, prompt, ...)

Generates code from a prompt using AI and returns the generated files.

core.default.steps.gen_entrypoint(ai, ...)

Generates an entrypoint for the codebase and returns the entrypoint files.

core.default.steps.handle_improve_mode(...)

core.default.steps.improve_fn(ai, prompt, ...)

Improves the code based on user input and returns the updated files.

core.default.steps.salvage_correct_hunks(...)

core.default.steps.setup_sys_prompt(preprompts)

Sets up the system prompt for generating code.

core.default.steps.setup_sys_prompt_existing_code(...)

Sets up the system prompt for improving existing code.

core.diff.count_ratio(str1, str2)

Computes the ratio of common characters to the length of the longer string, ignoring spaces and case.

core.diff.is_similar(str1, str2[, ...])

Compares two strings for similarity, ignoring spaces and case.

core.files_dict.file_to_lines_dict(file_content)

Converts file content into a dictionary where each line number is a key and the corresponding line content is the value.

core.git.filter_by_gitignore(path, file_list)

core.git.filter_files_with_uncommitted_changes(...)

core.git.has_uncommitted_changes(path)

core.git.init_git_repo(path)

core.git.is_git_installed()

core.git.is_git_repo(path)

core.git.stage_files(path, files)

core.git.stage_uncommitted_to_git(path, ...)

core.project_config.filter_none(d)

core.project_config.read_config(config_file)

Read the configuration file

gpt_engineer.tools: Tools

Functions

tools.custom_steps.clarified_gen(ai, prompt, ...)

Generates code based on clarifications obtained from the user and saves it to a specified workspace.

tools.custom_steps.get_platform_info()

Returns a string containing the OS and Python version information.

tools.custom_steps.lite_gen(ai, prompt, ...)

Executes the AI model using the main prompt and saves the generated results to the specified workspace.

tools.custom_steps.self_heal(ai, ...[, ...])

Attempts to execute the code from the entrypoint and if it fails, sends the error output back to the AI with instructions to fix.