You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use the LiteLLM (LLM?) with Ollama support like this:
fromgoogle.adk.agentsimportAgentfromgoogle.adk.models.lite_llmimportLiteLlmMODEL="qwen2.5"defget_weather(city: str) ->str:
"""Retrieves the current weather report for a specified city. Args: city (str): The name of the city (e.g., "New York", "London", "Tokyo"). Returns: str: A report on the current weather in the specified city. """returnf"It is always sunny in {city}!"root_agent=Agent(
name="weather_reporter",
model=LiteLlm(model=f"ollama_chat/{MODEL}"),
instruction="You are a helpful assistant. You always answer weather questions.",
description="A helpful assistant that provides weather information.",
tools=[get_weather],
)
When I send a message to the agent I get a response, but when tool call is required (see the screenshot) I got:
litellm.exceptions.APIConnectionError: litellm.APIConnectionError: Ollama_chatException - {"error":"json: cannot unmarshal array into Go struct field ChatRequest.messages.content of type string"}
Tried also with Llama3.2, Gemma3, DeepSeekR1-14B - they can't even respond to a normal message.
@codefromthecrypt you saved my day, I was struggling with the adk web not working at all. When I said hi, it tried to call tools, then called in an infinite loop, that was so strange.
With your changes, it's fine now, it answers correcly when not about weather, and calls the tool when needed.
Thank you !
Activity
codefromthecrypt commentedon Apr 11, 2025
FWIW you can get it to work by using the LiteLlm openai variant until there's an openai one (#27)
Then, use the normal openai ENV like this:
fesnault commentedon Apr 11, 2025
@codefromthecrypt you saved my day, I was struggling with the adk web not working at all. When I said hi, it tried to call tools, then called in an infinite loop, that was so strange.
With your changes, it's fine now, it answers correcly when not about weather, and calls the tool when needed.
Thank you !
curiousily commentedon Apr 11, 2025
@codefromthecrypt thank you! Thank worked (better). I gave you a shout-out in the video: https://www.youtube.com/watch?v=RgLSTGFjpqI
hangfei commentedon Apr 12, 2025
@polong-lin please consider incorporate the Oallma setup in our next doc release. Thanks.
Fix empty list in content on tool calls causing ollama parse error
selcukgun commentedon Apr 12, 2025
@curiousily You can go back to using ollama_chat provider once the fix above is merged.
Using ollama_chat provider:
export OLLAMA_API_BASE="http://localhost:11434" && adk webOr you can continue using openai provider name with
OPENAI_API_BASEoverride.You can peek into the request sent by litellm to ollama server by adding the followings in your agent.py
payload looks same for both methods. only routes seem different;
/api/chatvs/v1(which seems to have circumvented to parsing issue).Fix empty list in content on tool calls causing ollama parse error
Fix empty list in content on tool calls causing ollama parse error (#102
hangfei commentedon Apr 13, 2025
the change is merged but it's not released to PyPI yet. For now, you could build a local wheel to unblock yourself.
curiousily commentedon Apr 13, 2025
Thank you everyone! Will test once there is a PyPI release.
boyangsvl commentedon Apr 19, 2025
mark as closed as it's fixed in v0.2
codefromthecrypt commentedon Apr 24, 2025
thanks for sorting this and @curiousily thanks for the shout out. humbled!
Fix empty list in content on tool calls causing ollama parse error (g…
Enable different connection modes to ollama for multi-modal or contex…
marreapato commentedon Dec 16, 2025
I am still getting this issue on adk 0.3.0. Would anyone know why?