recalling tool_call_id as id is an error as id is global variable in the chatcompletionmessage, check the section just before grade function code cell. recall it as per the instruction mentions
every call has an attribute called id, hint it is part of the tool_call_id name
I don’t understand why the recall of tool_call_id as “id” is an error. It’s a global variable in chatcompletionmessage, but why is that an error?
I don’t understand the instruction or the hint either. In the instructions, tool_name is defined in the for loop. In the exercise, there is no definition for tool_call_id in the for loop. Do I need to write a new for loop outside of the new_msg syntax?
Note that you are looping over msg.tool_calls. You will need the loop variable to access the id of the current tool call.
The issue with the final_text variable looks like a bug in the provided code (not in your code). If the LLM does not call a tool and it does not return any text, the final_text variable gets assigned None and the grader produces a ‘Failed test case’. I get this ‘Failed test case’ when I set msg.tool_calls to None in the provided code. I will make an issue of this on the course github.
This bug should not often have an effect as it depends on the call to the LLM which usually succeeds. So if you get the error message again and again you may have to check your code. If you cannot find a solution, you can send me your code with a direct message. Otherwise, I would suggest just to continue finishing the lab and see if any issue comes up when you submit.
Posting here for visibility in case other learners face similar issues.
The main issue here was that messages was being hardcoded when creating the chat with the LLM. This resulted in the messages the LLM received not getting updated in each iteration, so the LLM pretty much always lost all the info from the previous step and decided to keep going which made the final_text variable to never be assigned.
We’ll make some changes to handle this more gracefully in the future but in the meantime please avoid hardcoding stuff and try to use the provided variables whenever possible.