This seems to be an issue with the Crawl4ai tool rather than the model. I tested both the models against a few other tools and it’s working fine. Can you try using some other tool if it’s to test Ollama? Else you can try using other tools for web scraping like firecrawl
from phi.agent import Agent
from phi.model.ollama import Ollama
from phi.tools.firecrawl import FirecrawlTools
agent = Agent(
model=Ollama(id=“llama3.2:latest”),
tools=[FirecrawlTools(api_key=‘*****’,scrape=False, crawl=True)],
show_tool_calls=True
)
agent.print_response(“Tell me about https://github.com/phidatahq/phidata.”, markdown=True)
Traceback (most recent call last):
File “/Users/cindy/Documents/AI/jiaoxing/jiaoxing/admin/webstie.py”, line 11, in
agent.print_response(“Tell me about https://github.com/phidatahq/phidata.”, markdown=True)
File “/Users/cindy/Documents/AI/jiaoxing/jiaoxing/.venv/lib/python3.11/site-packages/phi/agent/agent.py”, line 2698, in print_response
run_response = self.run(message=message, messages=messages, stream=False, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/cindy/Documents/AI/jiaoxing/jiaoxing/.venv/lib/python3.11/site-packages/phi/agent/agent.py”, line 1884, in run
return next(resp)
^^^^^^^^^^
File “/Users/cindy/Documents/AI/jiaoxing/jiaoxing/.venv/lib/python3.11/site-packages/phi/agent/agent.py”, line 1660, in _run
model_response = self.model.response(messages=messages_for_model)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/cindy/Documents/AI/jiaoxing/jiaoxing/.venv/lib/python3.11/site-packages/phi/model/ollama/chat.py”, line 423, in response
response: Mapping[str, Any] = self.invoke(messages=messages)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/cindy/Documents/AI/jiaoxing/jiaoxing/.venv/lib/python3.11/site-packages/phi/model/ollama/chat.py”, line 192, in invoke
return self.get_client().chat(
^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/cindy/Documents/AI/jiaoxing/jiaoxing/.venv/lib/python3.11/site-packages/ollama/_client.py”, line 236, in chat
return self._request_stream(
^^^^^^^^^^^^^^^^^^^^^
File “/Users/cindy/Documents/AI/jiaoxing/jiaoxing/.venv/lib/python3.11/site-packages/ollama/_client.py”, line 99, in _request_stream
return self._stream(*args, **kwargs) if stream else self._request(*args, **kwargs).json()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/cindy/Documents/AI/jiaoxing/jiaoxing/.venv/lib/python3.11/site-packages/ollama/_client.py”, line 75, in _request
raise ResponseError(e.response.text, e.response.status_code) from None
ollama._types.ResponseError: json: cannot unmarshal array into Go struct field .tools.function.parameters.properties.type of type string
any updates on the issue as i am getting the same error but for tools like DuckDuckGo() and YFinance. although these agents work alright when they are not in a team(i.e. when a single agent is run) but when in a team this error occurs:
ollama._types.ResponseError: json: cannot unmarshal array into Go struct field .tools.function.parameters.properties.type of type string
Hi @ansh363
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 24 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!
Hi @Hi @ manthanguptaa
I’m facing the same issue when I try to use ollama in team creation context.
hn_team = Agent(
name="Hackernews Team",
team=[hn_researcher, web_searcher, article_reader],
model=Ollama(id="llama3.2"),
instructions=[
"First, search hackernews for what the user is asking about.",
"Then, ask the article reader to read the links for the stories to get more information.",
"Important: you must provide the article reader with the links to read.",
"Then, ask the web searcher to search for each story to get more information.",
"Finally, provide a thoughtful and engaging summary.",
],
show_tool_calls=True,
markdown=True,
)
hn_team.print_response("Write an article about the top 2 stories on hackernews", stream=True)
return error below:
ollama._types.ResponseError: json: cannot unmarshal array into Go struct field .tools.function.parameters.properties.type of type string
Hi @vincevegafr
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 24 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!
Many thanks for the update!
The update version works perfectly and solve my problem.
I added an additionnal line model=OllamaTools(id="llama3.1"), in declaration block agent_team to not refer to openai but to ollama.
Thank you again for your great job