GenerativeAI
GenerativeAI copied to clipboard
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'
- Error:
- Diagnosis: I checked the type. It shows:
type(agent_res["message"])asollama._types.Message- I checked its attributes using
agent_res["message"].__dir__()and noticed that it includesdict
- I checked its attributes using
- Fix: I added
dict()so the modified code looks as:if "tool_calls" in agent_res["message"].dict().keys():- That started working fine.