natural language shell command

Open natural-language-shell-command in Script Kit

// Name: Natural Language Shell Command
// Description: Convert a natural language command to a shell command
// Author: Laura Okamoto
// Twitter: @laura_okamoto
import "@johnlindquist/kit";
const { Configuration, OpenAIApi } = await npm("openai");
const configuration = new Configuration({
apiKey: await env("OPENAI_API_KEY"),
});
const openAI = new OpenAIApi(configuration);
const res = await arg("Describe the shell command you want to run");
const prompt = `Use the following shell command to "${res}":`;
const completion = await openAI.createCompletion({
model: "text-davinci-003",
prompt,
temperature: 0,
max_tokens: 4069,
});
setSelectedText(completion.data.choices[0].text.trim());