GPT Engineer:下一代人工智能驱动的开发

gpt-engineer-750x422-1

GPT Engineer 旨在根据您的规格创建软件。只需提供提示,GPT Engineer 就会根据需要要求澄清,然后生成根据您选择的编码风格和功能定制的整个代码库。它具有适应性强、可扩展性强,并允许您训练代理以了解您的编码偏好。在本文中,我将逐步向您展示如何使用 GPT Engineer 的下一代 AI 驱动的开发工具。

环境设置

请完成以下步骤来准备使用 GPT Engineer 的环境:

按照以下步骤克隆 GPT Engineer 存储库:

  • 启动命令提示符或终端。
  • 导航到存储库所需的克隆目录。
  • 要克隆存储库,请使用以下命令:
git clone <repository_url>

要在克隆 GPT Engineer 存储库后进入项目目录,请执行以下操作:

  • 启动命令提示符或终端。
  • 使用 cd 命令,然后是克隆存储库的目录路径。举个例子:
cd gpt-engineer

运行以下命令创建新的 Conda 环境:

conda create --name gpt-eng python=3.11.3

使用以下命令激活 Conda 环境:

对于 Windows 用户,

conda activate gpt-eng

对于 Linux/macOS:

source activate gpt-eng

确保您位于项目目录中,其中包含 requirements.txt 文件。要进入项目目录,请使用 cd 命令。

要安装先决条件,请使用以下命令:

pip install -r requirements.txt

设置 OpenAI API 密钥

在 OpenAI 的网站上注册一个帐户以获取 API 密钥。获取 API 密钥后,将其设置为环境变量:

对于 Windows(命令提示符):

set OPENAI_API_KEY=<your_api_key>

对于 Windows (PowerShell):

$env:OPENAI_API_KEY="<your_api_key>"

对于 Linux/macOS:

export OPENAI_API_KEY=<your_api_key>

可以使用:

您现在已经成功配置了使用 GPT Engineer 的环境。您可以通过执行所需的脚本或将代码合并到您的应用程序中来开始使用该工具。

运行 GPT Engineer 的步骤

请按照以下步骤按照提供的说明运行GPT Engineer :

新建一个空文件夹:

在您想要的位置创建一个新文件夹。这可以手动或通过命令行完成。例如,要在当前目录中创建一个名为“my-new-project”的新文件夹,请键入:

mkdir my-new-project

复制示例文件(可选):

从示例项目结构开始,将“示例”文件夹的内容复制到新创建的文件夹中。要复制文件和文件夹,请使用以下命令:

cp -r example/* my-new-project/

填写主要提示:

打开文本编辑器并导航到main_prompt“my-new-project”文件夹中的“”文件。用您选择的代码生成提示替换当前内容。确保您的提示正确指定了必要的功能或代码结构。

运行 GPT 工程师脚本:

导航到 GPT Engineer 根目录(包含“main.py”的文件夹)。

要运行 GPT Engineer 并根据您的主提示生成代码,请输入以下命令:

python main.py my-new-project

此命令告诉 GPT Engineer 处理“my-new-project”文件夹中的主要提示并创建代码。

处理主提示

这里有一些细节需要澄清:

Summary of areas that need clarification:

1. Details about the snake game (rules, features, etc.)

2. Specifics about the MVC components (Model, View, Controller)

3. How to handle keyboard control in Python

4. File organization and structure

Clarifying question:

Could you please provide more details about the snake game, such as the rules, features, and any additional requirements
(answer in text, or "q" to move on)

实施贪吃蛇规则:

The Snake game is a famous arcade-style game that an engineer can construct by following these rules:

Grid of the Game:

The game takes place on a two-dimensional grid or screen that has been divided into cells.
The grid's size can be predefined or customizable depending on the game's settings.
Snake Motion:

On the grid, the snake is represented as a series of connected segments or blocks.
The snake begins with a single segment and goes in a single direction.
The player can control the direction by utilizing keyboard inputs (e.g., arrow keys).
The snake advances in the direction it is now facing, one cell at a time.
Food items include:

Food items are put on the grid at random.
The goal of the game is for the snake to devour the food items in order to grow longer.
When the snake's head collides with a food item, it consumes it and grows longer.
Snake Development:

The snake grows longer by adding a new segment to its body as it consumes food.
The newly acquired segment is attached to the snake's tail.
Detection of Collisions:

To determine the game's outcome, the game should detect collisions between the snake and various items.
Self-Collision: The game is over if the snake's head collides with any section of its own body.
Wall Collision: If the snake's head collides with the grid's boundaries, the game is over.
Food Collision: When the snake's head collides with a food item, it consumes the food, grows longer, and its score rises.
Game Over:

When the game ends due to collision with the snake's body or walls, a Game Over condition is triggered.
The final score is displayed, indicating the number of food items consumed.
The player has the option to play again or quit the game.

这些规则是开发贪吃蛇游戏的基础。工程师可以使用这些原则来构建游戏逻辑并实现蛇移动、碰撞检测、食物生成、分数跟踪和游戏结束情况所需的功能。

输出

game-snake-e1686905085860

它们还可以包括阶段、速度变化和图形界面等元素,以改善游戏体验。

GPT工程师的特点

  • Identification:可以通过编辑identity文件夹中的文件来指定AI代理的身份。这使用户能够根据自己的要求定制 AI 代理。例如,用户可以指定 AI 代理的姓名、性别和性格品质。
  • 记忆:人工智能代理可以通过改变身份和进化main_prompt. 因此,人工智能代理可以随着时间的推移学习和发展。
  • 通信历史: steps.py中每一步与GPT4的通信历史都会保存在logs文件夹中。这使用户能够监控 AI 代理的进度并解决问题。Scripts/rerun_edited_message_logs.py 可用于重做通信历史记录。

我认为这些都是很棒的用户功能。它们允许用户自定义 AI 代理、跟踪其进度并尝试不同的方法。这将使 AI 代理对更广泛的人更有用和有效。

另请阅读:您可能还会发现我们关于 基本提示工程指南的指南很有用

结论

总之,GPT Engineer 代表了下一代人工智能驱动的开发工具。凭借其根据提示生成整个代码库的能力及其灵活和适应性强的特性,它简化了代码生成和定制的过程。从高级提示到无缝的人机交互,GPT Engineer 使开发人员能够有效地构建和扩展他们的项目,从而在人工智能驱动的软件开发领域开辟了新的可能性。请随时在下面的评论部分分享您的想法和反馈。

原创文章,作者:网贝WebBay,如若转载,请注明出处:https://www.webbay.cn/gpt-engineer-the-next-generation-of-ai-powered-development

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

error: Content is protected !!