ollama-python icon indicating copy to clipboard operation
ollama-python copied to clipboard

Tool calls are not properly returned when chat() is called with stream=True

Open ggozad opened this issue 1 year ago • 1 comments

I have been working on integrating Ollama tools with oterm. When making a call to AsyncClient.chat() with tools defined and stream=True the response gives the tools to be called and params in the content attribute of the json response. For example:

{'role': 'assistant', 'content': '{"name": "get_current_location", "parameters": {}}'}

Same call with stream=False has, as it should, an empty content and the tools inside the tool_calls attribute.

ggozad avatar Sep 12 '24 11:09 ggozad

I'm also experiencing this. And to add a bit more context, there is no information in the response chunks to indicate that a tool call was chosen

{'model': 'mistral', 'created_at': '2024-09-27T15:55:56.521147Z', 'message': {'role': 'assistant', 'content': '[{"'}, 'done': False}
{'model': 'mistral', 'created_at': '2024-09-27T15:55:56.551562Z', 'message': {'role': 'assistant', 'content': 'name'}, 'done': False}
{'model': 'mistral', 'created_at': '2024-09-27T15:55:56.583256Z', 'message': {'role': 'assistant', 'content': '":"'}, 'done': False}
...

cpsievert avatar Sep 27 '24 16:09 cpsievert

Related: https://github.com/ollama/ollama/issues/5796, "Streaming for tool calls is unsupported"

petri avatar Nov 24 '24 18:11 petri

Coming soon!!! 🥳

ParthSareen avatar Nov 26 '24 23:11 ParthSareen

Fixed! https://github.com/ollama/ollama/releases/tag/v0.4.6

ParthSareen avatar Nov 28 '24 02:11 ParthSareen