AttributeError: 'ChatCompletionOutputToolCall' object has no attribute 'model_dump'

Hello Community. I was trying to develop an agent, which creates a comprehensive knowledge base about topic given and put the content in a Google Doc. The Agent is expected to create a Google doc with knowledge base it generated.

I am using Meta-Llama-3-8B-Instruct LLM available in HuggingFace and Composio for tools. Unfortunately, I am getting the below error

“AttributeError: ‘ChatCompletionOutputToolCall’ object has no attribute 'model_dump”’

It worked fine, when I tried to print response without giving tools parameter to agent. When I gave tools and asked Agent to create google doc, this error is displayed

Can anyone solve this issue please ? I think there is a coordination issue between HuggingFace model and tools

Attaching script for reference,

from phi.agent import Agent, RunResponse
from phi.model.huggingface import HuggingFaceChat
from composio_phidata import Action,ComposioToolSet
composio_toolset = ComposioToolSet(api_key=“—UPDATEDINTENTIONALLY—”)
tools = composio_toolset.get_tools(actions=[‘GOOGLEDOCS_CREATE_DOCUMENT’])
import os
os.environ[‘HF_TOKEN’] = “—UPDATEDINTENTIONALLY—”

professor_agent = Agent(
name = “Professor Agent”,
role = “Research and Knowledge specialist”,
model = HuggingFaceChat(
id = “meta-llama/Meta-Llama-3-8B-Instruct”,
max_tokens = 4096
),
instructions = [
“Create a comprehensive knowledge base that covers fundamental concepts, advanced topics, and current developments of the given topic.”,
“Exlain the topic from first principles first. Include key terminology, core principles, and practical applications and make it as a detailed report that anyone who’s starting out can read and get maximum value out of it.”,
“Make sure it is formatted in a way that is easy to read and understand.”,
“Create a Google Docs document, place the knowledge base created in the document with nice formatting”
],
tools = tools,
markdown= True,
debug_mode=True
)

from phi.utils.pprint import pprint_run_response
response : RunResponse = professor_agent.run("The topic is ‘Machine Learning’ ")
pprint_run_response(response)

Hi @karthik_rao_4572
Thank you for reaching out and using Phidata! I’ve tagged the relevant engineers to assist you with your query. We aim to respond within 48 hours.
If this is urgent, please feel free to let us know, and we’ll do our best to prioritize it.
Thanks for your patience!

1 Like

@karthik_rao_4572 can you help me with the version of phidata, composio, and hugging face you are running on your system?

Hi @manthanguptaa , I am using packages with following versions

phidata - 2.7.3
huggingface-hub - 0.27.1
composio - 0.1.1
composio_phidata - 0.6.9

Hi @Monali @manthanguptaa. Any Update on the issue?

@karthik_rao_4572 I tried this piece of code that worked for me. Can you also try it? I made a couple of changes like using Exa instead of Composio toolkit. Let me know if you want to stick to using composio and we can debug it!

P.S I am on the latest version of Phidata which might also be an issue in your case. I recommend updating phidata using pip install -U phidata

import os
from phi.agent import Agent, RunResponse
from phi.model.huggingface import HuggingFaceChat
from phi.tools.exa import ExaTools

professor_agent = Agent(
    name = "Professor Agent",
    model = HuggingFaceChat(id = "meta-llama/Meta-Llama-3-8B-Instruct", max_tokens = 4096),
    instructions = [
    "Create a comprehensive knowledge base that covers fundamental concepts, advanced topics, and current developments of the given topic.",
    "Explain the topic from first principles first. Include key terminology, core principles, and practical applications and make it as a detailed report that anyone who’s starting out can read and get maximum value out of it.",
    "Make sure it is formatted in a way that is easy to read and understand.",
    "Create a Google Docs document, place the knowledge base created in the document with nice formatting"
    ],
    tools = [ExaTools(api_key=os.getenv("EXA_API_KEY"))],
    markdown= True,
    debug_mode=True
)

from phi.utils.pprint import pprint_run_response
response : RunResponse = professor_agent.run("The topic is ‘Machine Learning’ ")
pprint_run_response(response)

@karthik_rao_4572
I notice your version of phidata is relatively outdated. I can recommend updating to the latest version and checking out @manthanguptaa’s code snippet.

@karthik_rao_4572 the issue here is an older version of openai. Please run pip install -U openai