Hi @KarlD,
Throughout all of the assignments, it has been instructed clearly to only change/write code where you are expected to.
You have changed/modified several code cells in your notebook in ways you were not supposed to. This not only causes issues within the assignment, but will fail the grader as well, because even if you get “All tests passed” message, you implementation is not as expected.
For example:
In exercise 1, you were provided this:
### START CODE HERE ###
# Use 'read_candy_data' to read the file `candy_data.csv`
candy_data = # Add your code here
# Display the contents loaded into the `candy_data` variable
display_table(candy_data)
### END CODE HERE ###
And this is what you implemented (I’m leaving comments where you wrote solution code):
### START CODE HERE ###
# Import using the format "from file_name import all (*)"
### YOU WROTE YOUR IMPORT STATEMENT HERE AGAIN
# Use the read_candy_data function to read the file candy_data.csv
candy_data = # YOUR SOLUTION CODE
### END CODE HERE ###
Do you see the difference ? You removed the entire display_table
function for one.
In exercise 2, you were provided:
### START CODE HERE ###
# Use 'get_popularity_scores' and pass in the lst `candy_data`
popularity_scores = # Add your code here
# Print the `popularity_scores` list
print_scores(popularity_scores)
### END CODE HERE ###
And this is what you implemented (I’m leaving comments where you wrote solution code):
# Use the get_popularity_scores function with the candy_data
popularity_scores = # YOUR SOLUTION CODE
You again removed the entire print_scores
function.
There are several other places where you made changes in the notebook as well, where you were not expected to.
As for your issue of this thread, exercise 5:
This is what you were provided:
### START CODE HERE ###
def get_llm_response(prompt):
completion = client.chat.completions.create(
model='gpt-4o-mini',
messages=[
{
"role": "system",
"content": "You are an AI assistant.", # <-- You have to make change here
},
{"role": "user", "content": prompt},
],
temperature=0.0, # <-- You have to make change here
)
response = completion.choices[0].message.content
return response
### END CODE HERE ###
The code clearly mentioned the only two places you were expected to make change. And this is what you implemented:
### START CODE HERE ###
# Import the client from ex5_helper_functions
from ex5_helper_functions import client
# Define the get_llm_response function
def get_llm_response(prompt, temperature=0.7, content="You talk like a connoisseur."):
completion = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": content},
{"role": "user", "content": prompt},
],
temperature=temperature,
)
response = completion.choices[0].message.content
return response
# Example usage
top_candies = ["Twix", "M&M's", "Snickers"]
descriptions = []
for candy in top_candies:
prompt = f"Describe {candy} in a short, catchy two-sentence description."
description = get_llm_response(prompt)
descriptions.append(description)
# Print the descriptions
for candy, description in zip(top_candies, descriptions):
print(f"{candy}: {description}")
### END CODE HERE ###
You not only changed the code of the cell, you added additional code, which is why you were getting the error.
Next steps for you:
I have added a fresh copy of the assignment in your workspace C1M4_Assignment.ipynb
, please use this file to attempt the assignment again. Follow the instructions and only make changes where you are expected to.
Your previous notebook has been renamed as previous_C1M4_Assignment.ipynb
, which can be found in your workspace as well. Do not copy paste solution from here for the reasons I mentioned above. You can use it to reference your previous solutions.
I understand one can be curious to try out different things, play around with the code and all, which you are welcome to do. But do these things after you have received your grade so that it doesn’t cause any inconveniences for you.
Best,
Mubsi