Una herramienta de línea de comandos para ejecutar comandos GPT. Esta herramienta es compatible con complementos con lotes de inmediato, cadena de inmediato y chatgpt.
Use esta herramienta para
Deberá crear una tecla API de OpenAI. Si tiene una cuenta, puede crear una clave aquí
https://platform.openai.com/account/api-keys
No comparta su clave API con otros, ni la exponga en el navegador u otro código del lado del cliente. Incurrirá en cualquier cargo si alguien usa su clave. No revise su clave en ningún repositorio público.
Cree un archivo que contenga su clave API (la siguiente no es real). En nuestro ejemplo. Nombramos el archivo API_KEY y agregamos la clave.
sk-gKtTxOumv4orO6cfWlh0ZK
Asegúrese de que haya instalado Dart. Siga las instrucciones, en el siguiente enlace.
https://dart.dev/get-dart
Después de la instalación, puede instalar el programa GPT con el siguiente comando
dart pub global activar gpt
Los siguientes son los casos de uso admitidos
Ejecutar el comando Generar Project
air genp
Primero deberá seleccionar el arquetipo
? Project Archetype ›
❯ Prompt
Chain
Batch
Image
ChatGPT Plugin
Ingrese el nombre de proyecto y el Proyecto Versión
✔ Project Archetype · Prompt
✔ Project Name: · myproject
✔ Project Version: · 1.0
Dependiendo del proyecto, es posible que deba ingresar su clave API. Puede omitir, usar un archivo de clave existente o crear un nuevo archivo de claves
? Import Key ›
❯ Skip
Use Existing OpenAI API Key File
Create New OpenAI API Key File
La siguiente opción nos permite ingresar la clave API directamente. Guardará la clave en un archivo. Si tiene problemas para copiar y pegar la clave, solo ingrese algunos caracteres y luego edite el archivo después.
✔ Import Key · Create New OpenAI API Key File
? API Key: › sk-gKtTxOumv4orO6cfWlh0ZK
El proyecto ChatGPT Plugin le permite hacer prototipos rápidos de un complemento CHATGPT. Específicamente, le permite burlarse de las respuestas a ChatGPT. El proyecto se basa en el proyecto QuickStart en: https://github.com/openai/plugins-quickstart
Su archivo de proyecto se verá como
---
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 logsCualquier configuración en el nodo DefaultConfig se aplicará a cada pluginserver a menos que ese complemento anule específicamente la propiedad.
A continuación se proporciona una respuesta simulada de muestra ( Todos.json ). Esto se devolverá en una llamada a /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 "
]
}Para iniciar una instancia burlada del servidor de complementos
air plugin
o para iniciar un servidor específico, agregue la opción ServerId
air plugin --serverId todo-mike
Para obtener más información sobre la creación y el uso de un chatgpt-plugin
Si eligió crear un proyecto de imagen, se le pedirá una descripción. No se preocupe, puede cambiarlo más tarde después de generar el proyecto.
? Image Description: › A goldfish with big eyes
Su archivo de proyecto se verá como
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 eyesSu archivo de inmediato será
Generate a picture of a ${imageDescription}
Para más información sobre imágenes

A continuación se pregunta cuántas veces ejecutar los datos de lotes. Si elige 5 veces, ejecutará todas las llamadas de datos por lotes 5 veces cada una.
? Number of Times to Run The Block: › 5
Verá un archivo de proyecto como el siguiente
---
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.promptEl aviso es un simple aviso de hola mundo de hola
Write me a paragraph about the world I live in
World: ```${my_world}```
El archivo Batch-Data.json contiene los datos de lotes.
{
"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 "
]
}Modifique estos dos archivos con sus propios datos. Para más información sobre lotes
A continuación se pregunta cuántas veces ejecutar la solicitud rápida. Si elige 5 veces, ejecutará toda la solicitud de inmediato 5 veces.
? Number of Times to Run The Block: › 5
A continuación, elija el formato de salida. ¿Solo quieres una respuesta de texto directo, o la quieres en formato JSON?
? Response Format ›
JSON
❯ TEXT
Si elige JSON, se le preguntará si desea habilitar la reparación de la respuesta JSON. Esto intentará analizar cualquier texto extraño que pueda agregar el asistente de IA.
? Attempt to FIX JSON Responses? (y/n) › no
El archivo del proyecto se verá como
---
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-1El archivo incluye algunos valores predeterminados para las solicitudes de OpenAI. Cambiarlos para satisfacer sus necesidades. Por defecto, también agrega el complemento de informes que generó la salida HTML de la respuesta de usuario/asistente.
El pront-json.prompt se parece a lo siguiente. Tenga en cuenta cómo se especifica la salida para usar JSON. Modifique el mensaje y las propiedades a sus necesidades.
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": ""}
Para más información sobre las indicaciones
Elija el arquetipo del proyecto de cadena . Luego pase por las opciones.
? 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
El archivo Generado 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-1Los campos de propiedades en el archivo de archivo del proyecto anterior.yaml al índice dentro del archivo Properties.json están a continuación. Este archivo le permite cambiar fácilmente la entrada de prueba.
{
"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 "
]
}La herramienta sustituirá al planeta "Tierra" y la acción "aterriza en el planeta" en la historia indicada a continuación. Observe que la IA generará el nombre del personaje y el primer párrafo de la historia.
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": ""}
La herramienta ahora pasará el nombre del Capitán devuelto y la historia del primer mensaje a la acción de usuario . Recibiremos una acción que toma el personaje.
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": ""}
Ahora ejecutaremos la historia. Prompt de nuevo, pero esta vez tendremos tanto el nombre del capitán como la próxima acción que toma.
El siguiente es la salida de muestra de una ejecución real
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.
Observe que la ejecución de la cadena es la misma que el número de párrafos que tenemos en la salida. Si quisiéramos otro párrafo, establecíamos amaneceres en 3. Si hubiéramos establecido blockruns a 5, habríamos generado 5 historias diferentes.
Para más información sobre las cadenas
Para generar un informe HTML, agregue el informe de PPTPLUGIN como el último bloque. Bajo los blockids, agregue cualquier ID de bloque anterior que desee agregar al informe generado.
---
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 El informe mostrará todo el chat para las ejecuciones de bloque configuradas.

Para más información sobre informes
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.
Para limpiar un proyecto, ejecute lo siguiente
Aire limpio
Esto elimina el directorio de salida para el proyecto.
Ejecución de llamadas Operai con una herramienta puede ser costoso si lo configura mal. Para determinar cuántas llamadas de Operai creará un proyecto, ejecute el siguiente comando
conteo aéreo
o para el recuento de un bloque específico
conteo aéreo -B myblockid
Saldrá
Project: product-summary-2.8
Total OpenAPI Calls would be 12
Si desea saber que su proyecto está haciendo antes de incurrir en costos para OpenAi, use la bandera Dryrun.
Air Run -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