UNPKG

vue-i18n-resource-generator

Version:

A CLI tool that utilizes the OpenAI API to automatically generate static Vue I18n resources.

20 lines (15 loc) 448 B
import { CreateCompletionResponseChoicesInner } from 'openai'; import partialJSONParse from 'partial-json-parser'; import chalk from 'chalk'; export const parseCompletion = ( completion: CreateCompletionResponseChoicesInner, ): object => { const { text } = completion; if (!text) { console.log( chalk.magenta('Could not find any text within the completion.'), ); process.exit(1); } return partialJSONParse(text); };