M2 Graded Lab question

For the M2 Graded lab - I am getting this error for exercise 3: Failed test case: revise_draft raised AttributeError: ‘NoneType’ object has no attribute ‘choices’.
Expected:
no exception,
but got:
‘NoneType’ object has no attribute ‘choices’.

However, when I print the response, I see the choices attribute

Response: ChatCompletion(id=‘chatcmpl-EXmjZdadkz2ZenK9biYfu4MNdoCn0’, choices=[Choice(finish_reason=‘stop’, index=0, logprobs=None, message=ChatCompletionMessage(content=‘To provide a meaningful improvement to your essay, please include both the original draft and the reflection feedback. This will allow me to assist you in enhancing your essay effectively based on the feedback given.’, refusal=None, role=‘assistant’, annotations=[], audio=None, function_call=None, tool_calls=None))], created=1791720865, model=‘gpt-4o-2024-08-06’, object=‘chat.completion’, service_tier=‘default’, system_fingerprint=‘fp_2a68371a58’, usage=CompletionUsage(completion_tokens=38, prompt_tokens=85, total_tokens=123, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=0, audio_tokens=0, reasoning_tokens=0, rejected_prediction_tokens=0), prompt_tokens_details=PromptTokensDetails(audio_tokens=0, cached_tokens=0)))

What is the reason for the error in the assignement?

Hi Yasamin_Nouri,

I can see two potential reasons why you may get this error.

If you look at the content of the choices attribute, you can see that the original draft and reflection feedback were not sent to the model. So you may have to check your passing of the respective arguments in the prompt you feed the model.

Another possibility is that you did not save your notebook before submitting.

I hope this helps.

Perhaps the expected return is return response, not return response.choices[0].message.content. Since your printed response contains the choices attribute, please check that the function returns the same response object correctly and that no execution path returns None.