GenerativeAI icon indicating copy to clipboard operation
GenerativeAI copied to clipboard

notebook.ipynb - error with agent_res["message"].keys()

Open ChanduTadanki opened this issue 8 months ago • 0 comments

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

ChanduTadanki avatar Mar 06 '25 17:03 ChanduTadanki