GPTコマンドを実行するためのコマンドラインツール。このツールは、プロンプトバッチ、プロンプトチェーン、およびChatGPTプラグインをサポートします。
このツールを使用します
OpenAI APIキーを作成する必要があります。アカウントをお持ちの場合は、ここでキーを作成できます
https://platform.openai.com/account/api-keys
APIキーを他の人と共有したり、ブラウザや他のクライアント側のコードで公開したりしないでください。誰かがあなたのキーを使用している場合、あなたは料金を負担します。公開リポジトリにキーをチェックしないでください。
APIキーを含むファイルを作成します(以下のキーはリアルではありません)。私たちの例で。ファイルAPI_KEYに名前を付けて、キーを追加します。
sk-gKtTxOumv4orO6cfWlh0ZK
DARTがインストールされていることを確認してください。以下のリンクの指示に従ってください。
https://dart.dev/get-dart
インストール後、次のコマンドでGPTプログラムをインストールできます
Dart Pub Global Activate GPT
以下はサポートされているユースケースです
Generate Projectコマンドを実行します
air genp
最初にアーキタイプを選択する必要があります
? Project Archetype ›
❯ Prompt
Chain
Batch
Image
ChatGPT Plugin
ProjectNameとProjectVersionを入力します
✔ 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への応答を模倣することができます。このプロジェクトは、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 logsDefaultConfigノードの構成は、そのプラグインが特にプロパティをオーバーライドしない限り、各プラグインサーバーに適用されます。
サンプルモックされた応答( 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}```
batch-data.jsonファイルには、バッチデータが含まれています。
{
"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 "
]
}独自のデータでこれら2つのファイルを変更します。バッチの詳細については
以下は、迅速なリクエストを実行する回数を尋ねます。 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出力を生成したレポートプラグインも追加します。
Prompt-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": ""}
このツールは、返されたキャプテンの名前とストーリーを最初のプロンプトからユーザーアクションに渡します。キャラクターがとるアクションを取り戻します。
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": ""}
今度はStory.promptを再び実行しますが、今回はキャプテンの名前と彼が取る次のアクションの両方を持っています。
フォローは、実際の実行からのサンプル出力です
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を最後のブロックとして追加します。 blocidsの下に、生成されたレポートに追加する以前のブロック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