mirror of
https://github.com/ollama/ollama-python.git
synced 2026-07-21 09:05:23 -04:00
tool calls integration broken when empty #117
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @aksep on GitHub (Jul 22, 2024).
With ollama-python 0.3.0 and the latest ollama server, I'm getting systematically an exception raised, even with the basic chat example provided (e.g.
examples/chat/main.py).Code to reproduce
Error message
Possible fix
Changing ollama/_client.py (around line 241) to remove
or []fixes it in my tests. I haven't checked the other occurrences of calls passing tools, but I guess they would fail too.@darth-kcaj commented on GitHub (Jul 22, 2024):
+1 I am observing this bug as well
@dancininmyheart commented on GitHub (Jul 23, 2024):
I meet same problem.Then,I change ollama to 0.2.1. it is ok.
@anthonywu commented on GitHub (Jul 29, 2024):
I think this is due to using an older model without tool calling support. Updating to
llama3.1should work. #237 fixes the doc and should be the resolution.@aksep commented on GitHub (Jul 31, 2024):
@anthonywu: I don't think it should fail with this specific error if no tools have been passed as argument, regardless whether the model supports them or not. There may also be reasons to want to use models that don't support tools.
Quite possible that the actual bug is in the upstream server that should treat an empty list as no tools. I would guess replacing [] with None works if the json field is then omitted altogether in the server request.
@anthonywu commented on GitHub (Jul 31, 2024):
Unable to reproduce your exception. I think this problem might go away if you
ollama pull llama3:latestandgit pull origin mainon this repo and maybe re-dopip install .in your venv if it was not ainstall -einstall.then running your snippet as is, no modifications, returns a valid response json
FWIW I ran this on macOS 14.5 M1, but IMO your problem is unlikely to be a machine/os specific issue.
@aksep commented on GitHub (Aug 1, 2024):
Yup, it doesn't happen anymore even though I haven't really updated anything since I opened this issue.
I'm still on ollama-python 0.3.0, ollama 0.2.7 (docker), and llama3 365c0bd3c000. The ollama host has been rebooted a couple of times since but it's running the same image.
Funny thing is, if I pass on a tool args, it (correctly) fails with the exception, as I would expect with this version of llama3.
Weird. Thanks for checking though!