INNER CODE UNIT · JavaScript
conversation
waylaidwanderer/node-chatgpt-api · bin/cli.js:103
async function conversation() {
console.log('Type "!" to access the command menu.');
const prompt = inquirer.prompt([
{
type: 'autocomplete',
name: 'message',
message: 'Write a message:',
searchText: '',
emptyText: '',
suggestOnly: true,
source: () => Promise.resolve([]),
},
]);
// hiding the ugly autocomplete hint
prompt.ui.activePrompt.firstRender = false;
// The below is a hack to allow selecting items from the autocomplete menu while also being able to submit messages.
// This basically simulates a hybrid between having `suggestOnly: false` and `suggestOnly: true`.
await new Promise(resolve => setTimeout(resolve, 0));