hi have written a code like this
const Configuration=new Configuration({apikey:my-api-key }); const openai= new OpenAIApi(Configuration); export async function sendMsgToOpenAI(message){ const res=await openai.createCompletion({ model:'text-davinci-003', prompt:message, tempreture:0.7, max_tokens:256, top_p:1, frequency_penalty:0, presense_penalty:0 }); return res.data.choices[0].text; }``` `but in my console window i am getting error message like this,` ``` GET http://localhost:5173/src/openai.jsx net::ERR_ABORTED 500 (Internal Server Error) and on web page error message is like this [plugin:vite:react-babel] C:\Users\ishti\OneDrive\Attachments\React.js\my-react-app\src\openai.jsx: Identifier 'Configuration' has already been declared. (3:6) 6 | C:/Users/ishti/OneDrive/Attachments/React.js/my-react-app/src/openai.jsx:3:6 1 | 2 | const{Configuration,OpenAIApi}= require ('openai'); 3 | const Configuration=new Configuration({apikey:my-api-key | 4 | });```
`i tried to change the name of file from openai.jsx to openai.js and from [const,require] to [import ,from]but it doesn’t work .i have installed openai by writing npm i openai .`
You should immediately revoke the leaked OpenAI API key.
Please take a look at How do I format my posts using Markdown or HTML?
Remove your API Key
@SyndRain The question has a public version history. Removing the key from the question text is not helping much, the OP must also revoke it on their own. Editing that for them could result in them assuming this has solved the problem.
@SyndRain Ah thanks for the resource, saving that one 👍🏻
Show 1 more comment