cli-ai
Version:
A command line interface client for interacting with OpenAI's GPT3
19 lines • 853 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.get_result = void 0;
const openai_1 = require("openai");
const config_1 = require("../config");
const commander_1 = require("commander");
const openai = new openai_1.OpenAIApi(new openai_1.Configuration({ apiKey: config_1.config.openai_api_token }));
const get_result = async (prompt) => {
const response = await openai.createCompletion({
model: commander_1.program.opts().model || config_1.openai_api_options.model,
// TODO: Add support for other options
...config_1.openai_api_options,
max_tokens: Number(commander_1.program.opts().maxTokens) || config_1.openai_api_options.max_tokens,
prompt: prompt,
});
return response.data.choices[0].text;
};
exports.get_result = get_result;
//# sourceMappingURL=openai.js.map