notebook.ipynb - error with agent_res["message"].keys()
- I got an error with the code line
if "tool_calls" in agent_res["message"].keys():
- Error:
'Message' object has no attribute 'keys'
- Diagnosis: I checked the type. It shows:
type(agent_res["message"]) as ollama._types.Message
- I checked its attributes using
agent_res["message"].__dir__() and noticed that it includes dict
- Fix: I added
dict() so the modified code looks as: if "tool_calls" in agent_res["message"].dict().keys():
- That started working fine.