Skip to content

feat: add Ollama text vectorizer#617

Open
s-agbede wants to merge 2 commits into
redis:mainfrom
s-agbede:feat/add-ollamatextvectorizer
Open

feat: add Ollama text vectorizer#617
s-agbede wants to merge 2 commits into
redis:mainfrom
s-agbede:feat/add-ollamatextvectorizer

Conversation

@s-agbede
Copy link
Copy Markdown

@s-agbede s-agbede commented May 20, 2026

Summary

Adds OllamaTextVectorizer support for local Ollama embedding models.

This PR includes Ollama optional dependency wiring, a sync/async OllamaTextVectorizer implementation, vectorizer registry/from-dict support for type: "ollama", mocked unit tests, and opt-in real Ollama integration tests guarded by REDISVL_TEST_OLLAMA=1.

Usage

from redisvl.utils.vectorize import OllamaTextVectorizer

vectorizer = OllamaTextVectorizer(model="nomic-embed-text")
embedding = vectorizer.embed("hello world")

To run the real Ollama integration tests locally:

ollama pull nomic-embed-text
REDISVL_TEST_OLLAMA=1 uv run pytest tests/integration/test_ollama_vectorizer_integration.py

Testing:

uv run pytest tests/unit/test_ollama_vectorizer.py tests/integration/test_ollama_vectorizer_integration.py -q
REDISVL_TEST_OLLAMA=1 uv run pytest tests/integration/test_ollama_vectorizer_integration.py -q
uv run black --check ./redisvl ./tests
uv run isort ./redisvl ./tests --check-only --profile black
uv lock --check
uv run mypy redisvl
make test

Full repo test result:
image


Note

Medium Risk
Adds a new embedding provider integration that makes network calls to a locally running Ollama daemon and introduces a new optional dependency; main risk is runtime failures/misconfiguration (host/model availability) rather than changes to existing providers.

Overview
Adds Ollama embedding support via a new OllamaTextVectorizer with sync/async embed/embed_many implementations, retries, and automatic dimension detection against the local Ollama embedding API.

Wires ollama into the public vectorizer surface (Vectorizers.ollama, vectorizer_from_dict, and __all__) and introduces an ollama optional extra (also included in all) plus lockfile updates. Adds mocked unit tests and opt-in integration tests gated by REDISVL_TEST_OLLAMA=1.

Reviewed by Cursor Bugbot for commit 33127cd. Bugbot is set up for automated code reviews on this repo. Configure here.

@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented May 20, 2026

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

@nkanu17
Copy link
Copy Markdown
Collaborator

nkanu17 commented May 20, 2026

Yess!! Let's go! Ollama finally

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit e70f8fa. Configure here.

Comment thread redisvl/utils/vectorize/text/ollama.py
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an Ollama-backed text embedding provider to RedisVL’s vectorizer system, enabling local embedding generation via an Ollama daemon while fitting into the existing vectorizer registry/from-dict plumbing and test suite.

Changes:

  • Introduces OllamaTextVectorizer with sync/async embedding APIs and automatic dimension discovery.
  • Wires type: "ollama" into the Vectorizers enum and vectorizer_from_dict, and exports the new vectorizer from redisvl.utils.vectorize.
  • Adds an ollama optional extra (also included in all), updates uv.lock, and adds mocked unit tests plus opt-in integration tests gated by REDISVL_TEST_OLLAMA=1.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
redisvl/utils/vectorize/text/ollama.py New Ollama vectorizer implementation (sync/async) and model-dimension initialization.
redisvl/utils/vectorize/base.py Adds ollama to the Vectorizers enum.
redisvl/utils/vectorize/__init__.py Exposes OllamaTextVectorizer and adds type: "ollama" support in vectorizer_from_dict.
pyproject.toml Adds ollama optional extra and includes it in all.
uv.lock Locks the new ollama dependency and updates extras metadata.
tests/unit/test_ollama_vectorizer.py Mocked unit tests for init, sync/async embedding, and registry/from-dict integration.
tests/integration/test_ollama_vectorizer_integration.py Opt-in real Ollama integration tests gated by env var.
Comments suppressed due to low confidence (1)

redisvl/utils/vectorize/text/ollama.py:298

  • Same validation issue as _embed_many: the error message iterates contents to compute element types even when contents is not a list. Passing a non-iterable will raise during message formatting and obscure the actual input-type error; guard before iterating or simplify the message for non-list inputs.
        if not isinstance(contents, list) or not all(
            isinstance(c, str) for c in contents
        ):
            raise TypeError(
                f"Input contents must be a list of strings to embed, got {type(contents)} with elements of types {[type(c) for c in contents]}"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread redisvl/utils/vectorize/text/ollama.py Outdated
Comment thread redisvl/utils/vectorize/text/ollama.py
Comment thread redisvl/utils/vectorize/text/ollama.py Outdated
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.

3 participants