Error for code in 'Playing with the AI code' module present in the AI training course

Hello Sir/Ma’am

I keep on getting this error for my code that I have edited according to the video given in the module mentioned above. Please look into this matter. PFA the code (2 screenshots) and the error message (1 screenshot) which is shared in the replies for this topic (as new users aren’t able to put more than one image in their post)

Thank you and kindly provide a solution for the stated problem.

Screenshot 3 :point_up_2:t2:

Screenshot 2 :point_up_2:t2:

Screenshot 1 :point_up_2:t2:

Hi @nandita_sharma

Please make sure that you have installed the boltiotai library and you are using the API key generated from the bolt trainings website.

Kindly follow these steps correctly.

  1. Generate API Key from course.boltiot.com/ApiUsage
  2. Copy and paste the API Key in the “Secrets” tab in Repl.it
  3. Install the Boltiotai library. Got to to Shell tab in repl and paste this command: pip install boltiotai
  4. Import this statement in the first line of your code: from boltiotai install openai
  5. Run the code.

If you have followed all the steps correctly, your code should run and give you the expected output. If you still face any issues, please feel free to get back to us.

Thank you for replying. I have tried using the solution but I’m afraid that I am receiving an error again. Also, to inform, I am using the API key provided by the website and I have installed the boltoitai library.

PFA the error message below:-

I think that the error might be related to the AttributeError: 'OpenAI' object has no attribute 'ChatCompletion' message being given. Also please check the code I have sent before just in case there is an error in it. Kindly guide me about the steps to be taken now.

Thank you!

hello, the error is occuring in the code, despite installing the boltiotai library because unlike older openai library, boltiotai does not have ChatCompletion attribute… this can be easily fixed by changing it to openai.chat.completions.create

so your line of code should be as follows:

response = openai.chat.completions.create(

this shall fix the error , hope this helps! Happy coding!

1 Like

Hello Nandita,

Though you have imported the boltiotai library, still there are some changes you need to make in your code. The way of calling methods have also changed , rather than using openai.ChatCompletion.create which is a standard way of calling a method using OpenAI API, for the boltiotai library you must do so like this:
openai.chat.completions.create.

I hope this will resolve the error in the code. Also, the working code is provided by the company for each project. You can watch it for later reference.

Hi @nandita_sharma

Please share your Repl to support@boltiot.com so that we can debug the issue. To share the Repl , click on invite option on the top right corner and enter the email id: support@boltiot.com

Also, thank you to @sneharsh.kerkar for helping me out.

@yogeshrane.contact, @nimesh.nimi2106, and thank you all for your help! My code has ran in the intended way. All your help was useful and this was a great learning opportunity for me. Once again thank you all! :grin:

3 Likes