L9: Building LLM prompts with variables

Hi Support Team,

I’m trying to run the following code from the course:

from helper_functions import print_llm_response

print_llm_response("What is artificial intelligence?")

However, the import is not recognised in my Jupyter Notebook. I have also tried online Python compilers and encountered the same issue. Could you provide a working example with the setup instructions?

Are you trying to run this on your own local platform?

The best idea is to execute the course notebooks on the course website. It is not easy to run them in another environment: you would need to download all the files associated with the assignment and then install the correct versions of all the required packages. That is not a simple thing to do and there are no official instructions for how to get that to work.

You have tagged this thread with both “coursera-platform” and “dl-ai-learning-platform”, so I’m not sure which platform you are using. Here are some instructions for how to download the files for the assignment on the Coursera platform. There are no instructions about installing the necessary software packages, but here is a thread that will at least give you a sense of what is involved.

Hi TMosh, yes, I’m trying to run the code outside the course platform, using Jupyter Notebook and an online Python compiler. I couldn’t find an option to practise or run the code on the course website. Could you please point me to the course’s practice environment?

Hi Paul, thank you for explaining. I’m taking the course on DeepLearning.AI, not Coursera—sorry for the confusion with the tags.

I couldn’t find the notebooks or an option to run and practise the code on the course website, so I tried Jupyter Notebook and an external online Python compiler. Could you please explain where to access the interactive course notebooks on DeepLearning.AI? I’d prefer to practise there with the required files and packages already available.

tried running the following code directly in the course portal:

print_llm_response("What is the capital of France?")

However, I receive this error:

NameError: name 'print_llm_response' is not defined

This is in AI Python for Beginners → Module 1 → Running Your First Program (Lesson_4).

When you open the notebook, you have to run all of the cells starting from the first one at the top of the notebook.

At the top of your image, where you see the set of square brackets with no number inside of them, that means you haven’t run the code in that cell.

It’s good to see that you figured out how to run the notebooks on the course website and Tom has explained what went wrong in the particular error that you showed. Note that this is a beginner course and they do step you through how everything works, but you need to make sure that you’re not being in too much of a hurry and bouncing around through the material. E.g. there was an item titled Running Your First Program earlier in this first week. Did you skip that one on the first pass?

Scroll up to the beginning prompt for your section and make sure you clicked in the field: from helper_functions import * (and then hit Shift + Enter).