AttributeError: messsage

When I ran the exmaple locally on my laptop


I got the error

Explore the ‘response’ object you are getting. May be the response you are getting is not what your code is expecting? post here that ‘response’ variable and lets explore it.

Thanks, I just updated the orignial post. Basically I pasted the screen shot of every line of my code

@Xiang_Yang , URGENTLY inactivate your api key from OPEN AI. You should never expose your API KEY in a public area. Create a new one.

Next: Please print(response) to see what is the content of this variable.

Deleted, thanks for the reminding.
I think the error happens when I try to run response = get_completion(prompt)

so if I try print(response), it says “response is not defined”

I think it is the openai library having some problem here

KeyError Traceback (most recent call last)
~\anaconda3\lib\site-packages\openai\ in getattr(self, k)
58 try:
—> 59 return self[k]
60 except KeyError as err:

KeyError: ‘messsage’

LoL I used “Chatgpt” to help me find the problem

There you go!!! You’re getting the fruits of the course now :slight_smile: