Adding v1 of project
This commit is contained in:
commit
e588cbf2ef
12 files changed
+9316
No files matched your search
@@ -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;
|
||||
Reference in new issue
Block a user