I expected my code gives output, but didn't get the error

Hi @shikharana3535

There are a few changes that you need to make in the code.

  • In the latest OpenAI package the response.choices object type is changed . Kindly make the following changes in your code.
response = openai.chat.completions.create


return response.choices[0].message.content
  • Please set your OpenAI API key correctly in the secrets section On Repl.it.
  • Last, make sure that the logic and indentation of the code is correct.

These changes should solve your problem. Alternatively you could also share us the entire code soo that we can debug it give a better solution.

If you still face any issues please feel free to get back to us.