一个用于运行GPT命令的命令行工具。该工具支持及时批次,及时链接和Chatgpt插件。
使用此工具
您将需要创建一个OpenAI API密钥。如果您有帐户,则可以在此处创建密钥
https://platform.openai.com/account/api-keys
不要与他人共享您的API密钥,也不要将其暴露在浏览器或其他客户端代码中。如果有人使用您的钥匙,您将产生任何费用。不要将密钥检查到任何公共存储库中。
创建一个包含API密钥的文件(下面的一个不是真实的)。在我们的示例中。我们将文件命名为API_KEY并添加密钥。
sk-gKtTxOumv4orO6cfWlh0ZK
确保已安装了飞镖。在下面的链接中遵循说明。
https://dart.dev/get-dart
安装后,您可以使用以下命令安装GPT程序
Dart Pub全球激活GPT
以下是支持的用例
运行生成项目命令
air genp
您首先需要选择原型
? Project Archetype ›
❯ Prompt
Chain
Batch
Image
ChatGPT Plugin
输入项目名称和项目verseverion
✔ Project Archetype · Prompt
✔ Project Name: · myproject
✔ Project Version: · 1.0
根据项目,您可能需要输入API密钥。您可以跳过,使用现有密钥文件或创建新的密钥文件
? Import Key ›
❯ Skip
Use Existing OpenAI API Key File
Create New OpenAI API Key File
以下选项允许我们直接输入API键。它将将密钥保存到文件中。如果您在复制和粘贴密钥时遇到麻烦,只需输入几个字符,然后再编辑文件即可。
✔ Import Key · Create New OpenAI API Key File
? API Key: › sk-gKtTxOumv4orO6cfWlh0ZK
Chatgpt插件项目允许您快速对ChatGpt插件进行原型制作。具体来说,它允许您模拟对Chatgpt的响应。该项目基于QuickStart项目:https://github.com/openai/plugins-quickstart
您的项目文件看起来像
---
projectName : plugin-quickstart
projectVersion : ' 1.0 '
projectType : plugin
defaultConfig :
properties :
port : 5003
nameForHuman : TODO Plugin (no auth)
nameForModel : todo
descriptionForHuman : Plugin for managing a TODO list, you can add, remove and view your TODOs.
mockedRequests :
- path : " /todos/global "
method : get
mockedResponse : todos-global.json
- path : " /todos/user "
method : get
mockedResponse : todos-global.json
pluginServers :
- serverId : todo-mike
flavor : mike
# mocked requests
mockedRequests :
- path : " /todos/mike "
method : get
mockedResponse : todos.json # returns the content of this file
# Adds a different user for testing
- serverId : todo-kaleb
flavor : kaleb
mockedRequests :
- path : " /todos/kaleb "
method : get
mockedResponse : todos.json
properties :
showHttpHeaders : true # Show http headers in logs除非该插件专门覆盖该属性,否则将在DefaultConfig节点中的任何配置应用于每个插件。
下面给出了样本模拟响应( Todos.json )。这将在致电/todos /mike的电话中返回
{
"todos" : [
" Clean out a septic tank " ,
" Repair a broken sewer pipe " ,
" Collect roadkill for disposal " ,
" Assist in bee hive relocation " ,
" Service a grease trap at a restaurant "
]
}启动插件服务器的模拟实例
air plugin
或启动特定服务器添加ServerId选项
air plugin --serverId todo-mike
有关创建和使用Chatgpt-Plugin的更多信息
如果您选择创建图像项目,将要求您提供描述。不用担心,您可以在生成项目后以后更改它。
? Image Description: › A goldfish with big eyes
您的项目文件看起来像
projectName : image-2
projectVersion : 2.0
apiKeyFile : api_key
blocks :
- blockId : image-block-1
pluginName : ImageGptPlugin
executions :
# First Image
- id : img-1
sizes :
- 256
- 256
- 1024
prompt : image.prompt
properties :
imageDescription : A goldfish with big eyes您提示文件将是
Generate a picture of a ${imageDescription}
有关图像的更多信息

以下要求执行批处理数据多少次。如果选择5次,它将运行所有批次数据调用5次。
? Number of Times to Run The Block: › 5
您将看到一个项目文件如下
---
projectName : mybatch
projectVersion : 1.0
apiKeyFile : api_key
blocks :
- blockId : batch-1
pluginName : BatchGptPlugin
blockRuns : 5
configuration :
requestParams :
model : gpt-3.5-turbo
temperature : 0.7
top_p : 1
max_tokens : 500
executions :
- id : batch-1
dataFile : batch-data.json
prompt : batch.prompt提示是一个简单的Hello World提示
Write me a paragraph about the world I live in
World: ```${my_world}```
批处理数据包含批处理数据。
{
"my_world" : [
" Hello World, I live in a magical place with magical creatures " ,
" Hello World, I live in a futuristic Utopia " ,
" Hello World, I live in a futuristic Dystopia "
]
}用自己的数据修改这两个文件。有关批次的更多信息
以下要求有多少次运行及时请求。如果您选择5次,它将运行所有提示请求5次。
? Number of Times to Run The Block: › 5
接下来选择输出格式。您只是想要直接的文本响应,还是希望以JSON格式进行。
? Response Format ›
JSON
❯ TEXT
如果您选择JSON,您将被问到是否要启用修复JSON响应。这将试图解析AI助手可能会添加的任何外部文本。
? Attempt to FIX JSON Responses? (y/n) › no
项目文件看起来像
---
projectName : prompt-1
projectVersion : 1.0
apiKeyFile : api_key
blocks :
- blockId : single-1
pluginName : ExperimentGptPlugin
blockRuns : 5
configuration :
requestParams :
model : gpt-3.5-turbo
temperature : 1.2
top_p : 1
max_tokens : 500
executions :
- id : exp-1
responseFormat : json
fixJson : false
promptChain :
- prompt-json.prompt
properties :
character : Commander in Starfleet
mainCharacterName : ' '
- blockId : report-1
pluginName : ReportingGptPlugin
executions :
- id : report-1
blockIds :
- single-1该文件包括OpenAI请求的一些默认值。更改它们以满足您的需求。默认情况下,它还添加了报告插件,该插件生成了用户/助手响应的HTML输出。
提示 - json.prompt看起来如下。请注意输出指定如何使用JSON。根据您的需求修改提示和属性。
Write me a story about ${character}. The main character is ${mainCharacterName}.
If no main character is given, choose one. Write one sentence only.
The response should be in JSON using the following structure:
Only use these fields. {"mainCharacterName": "", "story": ""}
有关提示的更多信息
选择链项目原型。然后浏览选项。
? Number of Times to Run The Block: › 1
? Attempt to FIX JSON Responses? (y/n) › yes
? Number of Times to Run The Prompt Chain: › 2
生成的project.yaml文件。
---
projectName : " chain-project "
projectVersion : " 1.0 "
apiKeyFile : " api_key "
blocks :
# Block demonstrates the use of importing properties
- blockId : chain-1
pluginName : ExperimentGptPlugin
blockRuns : 1 # Number of Stories
configuration :
requestParams :
model : gpt-3.5-turbo
temperature : 1.2
top_p : 1
max_tokens : 500
executions :
- id : exp-1-import
chainRuns : 2 # Number of times to run the promptChain
promptChain :
- story.prompt
- user-action.prompt # Simulates user input
excludesMessageHistory :
- user-action.prompt
fixJson : true
responseFormat : json
# Import properties from a properties file
import :
propertiesFile : properties.json # predefined values
properties :
planet : 1 # Earth
action : 3 # Lands on the planet
- blockId : report-1
pluginName : ReportingGptPlugin
executions :
- id : report-1
blockIds :
- chain-1上述项目中的属性字段。yaml文件指向属性中的索引。JSON文件在下面。该文件允许您轻松更改测试输入。
{
"planet" : [
" Earth " ,
" Venus " ,
" Jupiter "
],
"action" : [
" Blows up the planet " ,
" Observes the planet From Orbit " ,
" Lands on the planet " ,
" Zips around the planet and hopes no one notices "
]
}该工具将在下面的故事提示中代替地球“地球”和行动“地球上”。请注意,AI将产生角色的名字和故事的第一段。
The response will be in JSON Format.
Captain ${captainsName} is near ${planet}. .
The last part of the story is: ${story}
Then the captain ${action}
Tell me a story about what happens next.
Be very descriptive. Write two sentences only.
Give me the captains name, if I haven't given it.
RESPONSE
The response must only be in JSON using the following structure.
Only use these fields. {"captainsName": "${captainsName}", "story": ""}
现在,该工具将将返回的队长的名称和故事从第一个提示传递到用户action.prompt 。我们将获得角色采取的动作。
Give me an action for ${captainsName} for the following story:
${story}
The response must be in JSON using the following structure.
Only use these fields. {"action": ""}
现在,我们将再次进行故事。再次提出,但是这次我们将同时拥有队长的名字和他采取的下一个动作。
以下是实际运行中的样本输出
As Captain John lands on the planet, he feels the trembling beneath his feet and sees the vibrant green flora around him.
He plants the Earth's flag to claim its new discovery and soon finds a thriving alien civilization welcoming him with open arms.
[user action "plants the flag to claim the new discovery"]
As Captain John plants the Earth's flag on the newfound planet, he is approached by the leaders of the alien civilization
who speak his language and reveal that they have known about Earth for centuries. They invite him to partake in a feast in
his honor, where he learns about their advanced technology and way of life.
请注意,链条运行与输出中的段落数量相同。如果我们想要另一个段落,我们将把链条设置为3。如果我们将封锁设置为5,我们将产生5个不同的故事。
有关链条的更多信息
要生成HTML报告,请添加ReportingGptPlugin作为最后一个区块。在BlockID下,将要添加到生成的报告中的任何先前的块ID。
---
projectName : experiment-reporting
projectVersion : ' 1.7 '
apiKeyFile : " ../../api_key "
blocks :
- blockId : chain-1
pluginName : ExperimentGptPlugin
blockRuns : 1
...
# Generate HTML Report
- blockId : report-1
pluginName : ReportingGptPlugin
executions :
- id : report-execution
blockIds :
- chain-1 该报告将显示已配置的块执行的整个聊天。

有关报告的更多信息
空气 - 螺旋
A command line tool for running GPT commands
Usage: air <command> [arguments]
Global options:
-h, --help Print this usage information.
Available commands:
clean Cleans project's output directory
count Returns the number of OpenApiCalls that would be made
genp Generates a new project
plugin Runs local version of ChatGPT Plugin
run Runs a project's blocks
Run "air help <command>" for more information about a command.
要清洁项目,请运行以下内容
空气清洁
这将删除项目的输出目录。
如果您错误地配置它,则使用工具的OpenAI呼叫可能会很昂贵。要确定项目将创建多少个OpenAI调用,请运行以下命令
空气数
或用于特定块的计数
空气计数-B Myblockid
它将输出
Project: product-summary-2.8
Total OpenAPI Calls would be 12
如果您想知道您的项目正在触发OpenAI的成本之前,请使用Dryrun标志。
空气运行 - 二重
Executing Block
Running Project: image-generation-2.3
BlockId: image-1, PluginName: ImageGptPlugin
----------
Starting Block Run: 1
Starting execution: 1 - Requires 1 calls to OpenAI
POST to https://api.openai.com/v1/images/generations
{"prompt":"Generate a picture of a Unicorn with a gold horn and wings","n":1,"size":"256x256","response_format":"url"}
Finished execution: 1
Starting execution: 2 - Requires 2 calls to OpenAI
POST to https://api.openai.com/v1/images/generations
{"prompt":"Generate a picture of a fish with giant eyes","n":1,"size":"256x256","response_format":"b64_json"}
POST to https://api.openai.com/v1/images/generations
{"prompt":"Generate a picture of a fish with giant eyes","n":1,"size":"512x512","response_format":"b64_json"}
Finished execution: 2
--------
Finished running project: 0 seconds