当你尝试使用下列语句
response["choices"][0]["message"]["content"]
获取请求openai
接口的response
中的content
时,会报错
TypeError: 'ChatCompletion' object is not subscriptable
因为ChatCompletion对象的正确访问如下:
response.choices[0].message.content
测试后,可以正常打印response
中的输出