Un outil de ligne de commande pour exécuter les commandes GPT. Cet outil prend en charge les plugins de lots invite, de capture invite et de chatpt.
Utilisez cet outil pour
Vous devrez créer une clé API OpenAI. Si vous avez un compte, vous pouvez créer une clé ici
https://platform.openai.com/account/api- keys
Ne partagez pas votre clé API avec d'autres, ou ne l'exposez pas dans le navigateur ou un autre code côté client. Vous encourez des frais si quelqu'un utilise votre clé. Ne vérifiez pas votre clé dans un référentiel public.
Créez un fichier qui contient votre clé API (celle ci-dessous n'est pas réelle). Dans notre exemple. Nous nommons le fichier api_key et ajoutons la clé.
sk-gKtTxOumv4orO6cfWlh0ZK
Assurez-vous que vous avez installé Dart. Suivez les instructions, dans le lien ci-dessous.
https://dart.dev/get-dart
Après l'installation, vous pouvez installer le programme GPT avec la commande suivante
Dart Pub Global Activate GPT
Voici les cas d'utilisation pris en charge
Exécutez la commande de projet Générer
air genp
Vous devrez d'abord sélectionner l'archétype
? Project Archetype ›
❯ Prompt
Chain
Batch
Image
ChatGPT Plugin
Entrez le nom de projet et ProjectVersion
✔ Project Archetype · Prompt
✔ Project Name: · myproject
✔ Project Version: · 1.0
Selon le projet, vous devrez peut-être saisir votre clé API. Vous pouvez sauter, utiliser un fichier clé existant ou créer un nouveau fichier clé
? Import Key ›
❯ Skip
Use Existing OpenAI API Key File
Create New OpenAI API Key File
L'option suivante nous permet d'entrer directement la touche API. Il enregistrera la clé dans un fichier. Si vous avez du mal à copier et à coller la clé, entrez simplement quelques caractères, puis modifiez le fichier par la suite.
✔ Import Key · Create New OpenAI API Key File
? API Key: › sk-gKtTxOumv4orO6cfWlh0ZK
Le projet de plugin ChatGPT vous permet de faire un prototypage rapide d'un plugin ChatGpt. Plus précisément, il vous permet de vous moquer des réponses à Chatgpt. Le projet est basé sur le projet QuickStart à: https://github.com/openai/plugins-quickstart
Votre fichier de projet ressemblera à
---
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 logsToute configuration dans le nœud defaultConfig sera appliquée à chaque Pluginserver, sauf si ce plugin remplace spécifiquement la propriété.
Un échantillon de réponse moquée ( Todos.json ) est donné ci-dessous. Ce sera retourné sur un appel à / 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 "
]
}Pour démarrer une instance moquette du serveur de plugin
air plugin
ou pour démarrer un serveur spécifique, ajoutez l'option ServerId
air plugin --serverId todo-mike
Pour plus d'informations sur la création et l'utilisation d'un Chatgpt-Plugin
Si vous avez choisi de créer un projet d'image, il vous sera demandé une description. Ne vous inquiétez pas, vous pouvez le changer plus tard après avoir généré le projet.
? Image Description: › A goldfish with big eyes
Votre fichier de projet ressemblera à
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 eyesVotre fichier invite sera
Generate a picture of a ${imageDescription}
Pour plus d'informations sur les images

Ce qui suit demande combien de fois pour exécuter les données par lots. Si vous choisissez 5 fois, il exécutera toutes les appels de données par lots 5 fois chacun.
? Number of Times to Run The Block: › 5
Vous verrez un fichier de projet comme celui qui suit
---
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.promptL'invite est une simple invite de Hello World
Write me a paragraph about the world I live in
World: ```${my_world}```
Le fichier Batch-data.json contient les données par lots.
{
"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 "
]
}Modifiez ces deux fichiers avec vos propres données. Pour plus d'informations sur les lots
Ce qui suit demande combien de fois pour exécuter la demande rapide. Si vous choisissez 5 fois, il exécutera toutes les demandes d'invite 5 fois.
? Number of Times to Run The Block: › 5
Choisissez ensuite le format de sortie. Voulez-vous simplement une réponse en texte droit, ou le voulez-vous au format JSON.
? Response Format ›
JSON
❯ TEXT
Si vous choisissez JSON, il vous sera demandé si vous souhaitez activer la réparation de la réponse JSON. Cela tentera d'analyser tout texte étranger que l'assistant AI peut ajouter.
? Attempt to FIX JSON Responses? (y/n) › no
Le fichier de projet ressemblera à
---
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-1Le fichier inclut certaines valeurs par défaut pour les demandes OpenAI. Changez-les pour répondre à vos besoins. Par défaut, il ajoute également le plugin de rapport qui a généré une sortie HTML de la réponse utilisateur / assistant.
Le prompt-json.prompt ressemble à ce qui suit. Notez comment la sortie spécifie pour utiliser JSON. Modifiez l'invite et les propriétés de vos besoins.
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": ""}
Pour plus d'informations sur les invites
Choisissez l'archétype du projet de chaîne . Ensuite, passez par les options.
? 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
Le fichier project.yaml généré.
---
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-1Les champs de propriétés dans le fichier project.yaml ci-dessus vers l'index dans le fichier Properties.json sont ci-dessous. Ce fichier vous permet de modifier facilement l'entrée de test.
{
"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 "
]
}L'outil remplacera la planète "Terre" et l'action "atterrira sur la planète" dans l'invite de l'histoire ci-dessous. Notez que l'IA générera le nom du personnage et le premier paragraphe de l'histoire.
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": ""}
L'outil passera désormais le nom du capitaine retourné et l'histoire de la première invite dans l' action utilisateur.prompt . Nous récupérerons une action que le personnage entreprend.
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": ""}
Maintenant, nous allons exécuter l' histoire. Prompt à nouveau, mais cette fois, nous aurons à la fois le nom du capitaine et la prochaine action qu'il entreprend.
Le suivant est l'échantillon de sortie d'une exécution réelle
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.
Remarquez que la chaîne est la même que le nombre de paragraphes que nous avons dans la sortie. Si nous voulions un autre paragraphe, nous définissons Chainruns à 3. Si nous avions réglé des blockruns à 5, nous aurions généré 5 histoires différentes.
Pour plus d'informations sur les chaînes
Pour générer un rapport HTML, ajoutez le reportagegptplugin comme dernier bloc. Sous les blocs, ajoutez tout ID de bloc précédent que vous souhaitez ajouter au rapport généré.
---
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 Le rapport affichera l'intégralité du chat pour les exécutions de blocs configurés.

Pour plus d'informations sur les rapports
Air - help
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.
Pour nettoyer un projet, exécutez ce qui suit
nettoyer à l'air
Cela supprime le répertoire de sortie du projet.
L'exécution d'appels ouverts avec un outil peut être coûteux si vous le configurez mal. Pour déterminer le nombre d'appels OpenAI un projet créera, exécutez la commande suivante
nombre d'air
ou pour le compte d'un bloc spécifique
Count d'air -B Myblockid
Il sortira
Project: product-summary-2.8
Total OpenAPI Calls would be 12
Si vous voulez savoir que votre projet se déroule avant de contracter des coûts pour OpenAI, utilisez le drapeau Dryrun.
Air Run - Stryrun
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