Adding css and adding prompt chainging

This commit is contained in:
Alec Dilanchian committed 2022-11-20 21:29:16 -05:00
1 parent 1f096cb1a7
commit 57054f8654
6 files changed
+242 -159

No files matched your search

+24 -4
View File
@@ -6,15 +6,35 @@ const configuration = new Configuration({
const openai = new OpenAIApi(configuration);
const basePromptPrefix =
'Help me write lyrics in the style of Drake, Canadian Rapper\n';
const finalPromptPrefix = 'Take the lyrics below and generate 5 song titles:\n';
const generateAction = async (req, res) => {
const completion = await openai.createCompletion({
// Run first prompt
const baseCompletion = await openai.createCompletion({
model: 'text-davinci-002',
prompt: req.body.input,
prompt: `${basePromptPrefix}${req.body.input}`,
temperature: 0.7,
max_tokens: 2048,
});
const choice = completion.data.choices.pop();
res.status(200).json({ choice });
const baseChoice = baseCompletion.data.choices.pop();
// Run second prompt with prefix
const finalPrompt = `${finalPromptPrefix}${req.body.input}${baseChoice.text}`;
console.log(finalPrompt);
const prefixCompletion = await openai.createCompletion({
model: 'text-davinci-002',
prompt: finalPrompt,
temperature: 0.7,
max_tokens: 2048,
});
const finalChoice = prefixCompletion.data.choices.pop();
res.status(200).json({ baseChoice, finalChoice });
};
export default generateAction;