一個用於運行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