Agentic Workflow Module 2, M2 Graded Lab

When I try to run my code for module graded lab. It gives me unit tests name error.

It states that, NameError: name ‘unittests’ is not defined

How can I resolve this?

This error occurs when you run code cells without running the import cell at the top first, or if the kernel restarted and cleared the loaded modules.

To resolve this, run the setup cells at the beginning of the notebook where import unittests is defined. You can also run all cells sequentially by selecting Kernel → Restart & Run All from the top menu.

Hi,

I really do not understand what input is required of me.

I put this input shown below,

START CODE HERE

[{"As an elite writer": "Write for an intelligent audience", "Obesity": prompt}]

Here is what I got below:

Failed test case: generate_draft raised LLMError: An error occurred: Error code: 400 - {'error': {'message': "Invalid value for 'content': expected a string, got null.", 'type': 'invalid_request_error', 'param': 'messages.[0].content', 'code': None}}.
Expected: no exception
Got: An error occurred: Error code: 400 - {'error': {'message': "Invalid value for 'content': expected a string, got null.", 'type': 'invalid_request_error', 'param': 'messages.[0].content', 'code': None}}

The error expected a string, got null is telling you exactly what went wrong: the prompt variable needs to be a string, but your code creates a list of dictionaries instead.

Look at the code below your ### END CODE HERE ### block:

messages=[{"role": "user", "content": prompt}]

That line already handles the message structure for the API call. So prompt just needs to be a plain string describing what you want the LLM to write.

The fix: replace your list/dict with a simple f-string that incorporates the topic variable. Something like:

prompt = f"Write an essay about {topic}"

That’s the general idea. Make your prompt more detailed to get a well-structured essay (the exercise description lists what qualities the draft should have), but the key thing is: it must be a string, and it must use the topic parameter.

Also, make sure you run cells in order from the top (Cell 1 for the client setup, Cell 2 for the import unittests) before running any test cells. That’ll fix your earlier NameError as well.

All test passed initially but final submission grading returned errors and failed tests.

Please See below and advise:

posting grade function codes is considered gross violation of code of conduct, if you are failing submission, then post screenshot of submission grader output which shows information on why you are failing the assignment. if a mentors wants to look at your codes they will ask you to send them by personal DM.

posting grade function codes is considered gross violation of code of conduct, if you are failing submission, then post screenshot of submission grader output which shows information on why you are failing the assignment. if a mentors wants to look at your codes they will ask you to send them by personal DM.

Also try the approach of saving your work by clicking on save emicon present on the left upper corner and then submit your assignment, if you are confident of your code being correct.

Apologies,

I have resolved the issue.

Thank you for letting me know.

what was issue? or how you resolved your issue @Samuel_Utere