Skip to content

Instantly share code, notes, and snippets.

@bramses
Created Aug 9, 2021
Embed
What would you like to do?
GPT-3 Twilio Codex Workflow
const workflow = async function (msg) {
// read pug and css file we want to update
let testPug = await fs.readFile('./views/test.pug', 'utf8');
let testCss = await fs.readFile('./public/stylesheets/test.css', 'utf8');
let isCSS = false;
// if message includes the paint emoji, change the CSS file
if (msg.includes('🎨')) {
isCSS = true;
msg = msg.replace('🎨', '');
}
else if (msg.includes('🐶')) {
isCSS = false;
msg = msg.replace('🐶', '');
}
// generate a codex response from a command and rewrite the file with our changes
if (!isCSS) {
const tr = await gptCall(testPug, msg, 'pug');
testPug += "\n" + tr.code.split('\n').map(line => ` ${line}`).join('\n');
await fs.writeFile('./views/test.pug', testPug, 'utf8');
} else {
const tr = await gptCall(testCss, msg, 'css');
testCss += "\n" + tr.code.trim();
await fs.writeFile('./public/stylesheets/test.css', testCss, 'utf8');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment