mirror of
https://github.com/ollama/ollama-python.git
synced 2026-07-21 09:05:23 -04:00
ollama-python does not expose the name field returned by /api/tags
#291
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 @Wu2406 on GitHub (Aug 13, 2025).
Environment
Background
I downloaded a GGUF file locally and created a model with a custom
Modelfile:After running:
the CLI confirms the model is correctly registered:
The REST endpoint
/api/tagsreturns the expected JSON, including thenamefield:Problem
When I use the official
ollama-pythonclient:the returned objects do not contain the
nameattribute, only:This breaks downstream libraries (e.g. mem0) that rely on:
Because
model.get("model")isNone, the condition always evaluates toTrue, leading to unnecessary pulls or runtime errors.Question
Is this discrepancy intentional, or am I missing a configuration step when importing a local GGUF?
Could the
ollama-pythonSDK expose the samenamefield that the REST API already provides?Thank you for your time and for maintaining this great project!
@Wu2406 commented on GitHub (Aug 13, 2025):
Follow-up:
namefield missing fromollama._types.ListResponse.Modelinollama-pythonRoot-cause investigation
After opening the issue I did a quick local audit and can confirm the mismatch is inside the SDK itself, not in Ollama’s REST layer.
The HTTP endpoint
/api/tagsdoes returnHowever, the
ListResponsetype defined insite-packages/ollama/_types.py(line 463) only maps the following fields:In
_client.py,list()callsThe JSON is deserialized into the
Modelsub-class above, so any extra keys (likename) are silently dropped by Pydantic.Minimal repro
Proposed fix
Add a single optional field to
ListResponse.Model:This is a non-breaking change (defaults to
None) and restores 1-to-1 compatibility with the REST API.Pull request
Based on the findings above, I've implemented this code change and verified its functionality. I've also submitted a pull request. Whenever you have a moment, I would be grateful if you could kindly take a look.
Here is my pull request link: https://github.com/ollama/ollama-python/pull/563
@ParthSareen commented on GitHub (Sep 18, 2025):
nameis set to be deprecated@Wu2406 commented on GitHub (Sep 18, 2025):
If the 'name' field is set to be deprecated, should we use the 'Model' field instead? Are these two fields the same?