Adding v1 of project

This commit is contained in:
Alec Dilanchian committed 2022-11-16 19:24:16 -05:00
commit e588cbf2ef
12 files changed
+9316

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import { Configuration, OpenAIApi } from 'openai';
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const generateAction = async (req, res) => {
const completion = await openai.createCompletion({
model: 'text-davinci-002',
prompt: req.body.input,
temperature: 0.7,
});
const choice = completion.data.choices.pop();
res.status(200).json({ choice });
};
export default generateAction;