add: configure open ai and get api key
This commit is contained in:
parent
85ab638bec
commit
8d6b427efd
|
@ -1 +1,23 @@
|
|||
node_modules
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
const { Configuration, OpenAIApi } = require("openai");
|
||||
const configuration = new Configuration({
|
||||
apiKey: process.env.REACT_APP_OPENAI_API_KEY,
|
||||
});
|
||||
const openai = new OpenAIApi(configuration);
|
||||
|
||||
async function CallAPI() {
|
||||
const response = await openai.createCompletion({
|
||||
model: "text-davinci-003",
|
||||
prompt: "Say this is a test",
|
||||
max_tokens: 7,
|
||||
temperature: 0,
|
||||
});
|
||||
|
||||
console.log(response.data.choices[0].text);
|
||||
}
|
||||
|
||||
CallAPI();
|
File diff suppressed because it is too large
Load Diff
|
@ -7,5 +7,12 @@
|
|||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Sushant Dhimal",
|
||||
"license": "ISC"
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.20.1",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.18.2",
|
||||
"morgan": "^1.10.0",
|
||||
"openai": "^3.1.0"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue