I am also stuck in the same place in this L7 “Evaluation” lesson – and I think I am almost at a solution, but a bit tripped up on where to put the utils and json docs.
To note: I setup a Jupyter notebook with Anaconda and have been going through the exercises using that. I am able to run this through the course notebook, but wanted to do it in my own.
This is what I’ve done so far…After going around in circles to import initially to import a utils module, I thought I was able to do this correctly – or at least I was able to run “import utils” and install what seemed to be a standard utils module for python. This got me mostly through L7 because it could at least now run the import
The process stumbles on this line that is right at the end of Step 1, not being able to find: utils.find_category_and_product_only
I downloaded the utils.py file from the course itself (hadn’t even thought to do that before reading this thread - thank you!). I have been able to download it and I thought I had placed it in the same location that the former utils.py had been located, but apparently note. Now I get this message which seems to point to issues in the file (?)
FileNotFoundError Traceback (most recent call last)
Cell In[42], line 76
73 return neg_str, all_messages
75 user_input = “tell me about the smartx pro phone and the fotosnap camera, the dslr one. Also what tell me about your tvs”
—> 76 response,_ = process_user_message(user_input,)
77 print(response)
Cell In[42], line 14, in process_user_message(user_input, all_messages, debug)
10 return “Sorry, we cannot process this request.”
12 if debug: print(“Step 1: Input passed moderation check.”)
—> 14 category_and_product_response = utils.find_category_and_product_only(user_input, utils.get_products_and_category())
15 #print(print(category_and_product_response)
16 # Step 2: Extract the list of products
17 category_and_product_list = utils.read_string_to_list(category_and_product_response)
File ~/utils.py:171, in get_products_and_category()
167 def get_products_and_category():
168 “”"
169 Used in L5
170 “”"
→ 171 products = get_products()
172 products_by_category = defaultdict(list)
173 for product_name, product_info in products.items():
File ~/utils.py:181, in get_products()
180 def get_products():
→ 181 with open(products_file, ‘r’) as file:
182 products = json.load(file)
183 return products
FileNotFoundError: [Errno 2] No such file or directory: 'products.json
I am aware there’s a json file - where does that need to get copied to? And I thought that I had copied the utils.py file to the right location (
/Users/name/anaconda3/lib/python3.10/site-packages/utils/init.py)
Thanks in advance for your help.
Kim