Skip to content

fix: add missing 'name' field to ollama._types.ListResponse.Model #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Wu2406
Copy link

@Wu2406 Wu2406 commented Aug 14, 2025

Pull Request: add missing 'name' field to ollama._types.ListResponse.Model

What this does

The REST endpoint /api/tags already returns a field called "name" for every model:

{
  "models": [
    {
      "name": "Qwen3-Embedding:0.6B",
      "model": "Qwen3-Embedding:0.6B",
      "modified_at": "...",
      ...
    }
  ]
}

But the Python client class ListResponse.Model only maps these keys:

class ListResponse(SubscriptableBaseModel):
  class Model(SubscriptableBaseModel):
    model: Optional[str] = None
    modified_at: Optional[datetime] = None
    digest: Optional[str] = None
    size: Optional[ByteSize] = None
    details: Optional[ModelDetails] = None

Because the extra name key is not listed, Pydantic discards it when the JSON is deserialized.
This PR simply adds:

  class Model(SubscriptableBaseModel):
    name: Optional[str] = None
    ...

to ListResponse.Model so the SDK keeps the same data that the server already sends.

Why it matters

Some downstream libraries (for example mem0) do:

local_models = self.client.list()["models"]
if not any(model.get("name") == self.config.model for model in local_models):
    self.client.pull(self.config.model)

Today model.get("name") always returns None, causing unnecessary pulls or runtime errors.
With this tiny change those projects work out of the box.

Backwards compatibility

  • The new field is optional and defaults to None.
  • Existing code that only uses the old fields will keep working exactly as before.

Files changed

  • ollama/_types.py – add one line inside ListResponse.Model.

Verification

from ollama import Client
client = Client()
print(client.list().models[0].dict())
# before: {'model': 'my-model', ...}   # name missing
# after : {'name': 'my-model', 'model': 'my-model', ...}

That’s all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant