OpenAI Attribute Error, 'choices' not defined, earlier it wasn't happening

Hi @cplt6.roy ,

Please make sure to add latest API key generate by you in the secrete section of the Repl.
Make sure to replace MONGO_API_KEY with OPENAI_API_KEY and Value with your API kay

If the issue still persist, please share your Repl to support@boltiot.com using the invite option of Replit.
Here is the screenshot of the how you can share the Repl::

On line 25 of your code, replace

return response.choices[0].message.content

with

return response['choices'][0]['message']['content']

Explanation: Since response is a dictionary with keys of string data type(choices, message, content) you need to use square brackets in order to access keys of string data types.
Hopefully this helps!