Skip to content

Voyageai refactoring and multimodal capability#412

Open
fzowl wants to merge 3 commits intoredis:mainfrom
voyage-ai:voyageai_context_model_and_token_counting
Open

Voyageai refactoring and multimodal capability#412
fzowl wants to merge 3 commits intoredis:mainfrom
voyage-ai:voyageai_context_model_and_token_counting

Conversation

@fzowl
Copy link
Copy Markdown
Contributor

@fzowl fzowl commented Oct 24, 2025

Voyageai refactoring:

  • contextual model(s)
  • remove default model value
  • token counting and effective batching
  • test with new reranker, rerank-2.5 as well
  • multimodal capability (text, image, video)
  • more tests

Note

Medium Risk
Updates VoyageAI embedding behavior and public surface (new deprecations for implicit model and batch_size, plus new token-counting APIs), which could affect existing integrations and batching behavior. Most risk is functional/regression around embedding calls and new integration tests that depend on external tooling (API keys, Pillow, ffmpeg).

Overview
Improves VoyageAIVectorizer by adding local token counting (count_tokens/acount_tokens) and introducing a VOYAGE_TOTAL_TOKEN_LIMITS table to support token-aware batching.

Deprecates instantiating the vectorizer without an explicit model (now emits a DeprecationWarning and will remove the implicit default in a future major version) and deprecates passing batch_size to _embed_many/_aembed_many in favor of automatic batch sizing.

Expands integration coverage with VoyageAI-specific tests for token counting, token limit constants, and multimodal embedding flows (text, image, video, and async), including conditional skipping when ffmpeg isn’t available.

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

@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented Oct 24, 2025

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.

@bsbodden bsbodden requested review from bsbodden and Copilot October 24, 2025 15:24
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

This PR refactors the VoyageAI integration to support contextual embedding models, improve token management, and enhance testing coverage. The changes include removing the default model value (requiring explicit model specification), implementing token-aware batching, adding support for the voyage-context-3 model, and updating tests to cover the new rerank-2.5 model.

Key Changes:

  • Added token counting functionality and token-aware batching based on model-specific token limits
  • Introduced support for contextualized embedding models (voyage-context-3) with automatic API endpoint detection
  • Updated VoyageAI package dependency from 0.2.2 to 0.3.5

Reviewed Changes

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

File Description
tests/integration/test_vectorizers.py Added VoyageAI-specific tests for token counting, context models, and batching; updated model references to voyage-3.5
tests/integration/test_rerankers.py Enhanced reranker test fixture to test both rerank-lite-1 and rerank-2.5 models
redisvl/utils/vectorize/text/voyageai.py Implemented token-aware batching, context model support, removed default model value, added token limits dictionary
pyproject.toml Updated voyageai dependency version requirement from 0.2.2 to 0.3.5

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

def __init__(
self,
model: str = "voyage-large-2",
model: str,
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

Removing the default model value is a breaking API change. Existing code that instantiates VoyageAITextVectorizer without specifying a model will fail. Consider adding a deprecation warning in a previous release or documenting this as a breaking change in the release notes.

Copilot uses AI. Check for mistakes.
Comment thread redisvl/utils/vectorize/text/voyageai.py Outdated
Comment thread redisvl/utils/vectorize/text/voyageai.py Outdated
@bsbodden
Copy link
Copy Markdown
Collaborator

@fzowl There are some failures in CI: The job failed due to mypy type errors in redisvl/utils/vectorize/text/voyageai.py:

  • Line 302: "Client" has no attribute "contextualized_embed"
  • Line 385: "AsyncClient" has no attribute "contextualized_embed"

Solution:
The mypy errors are caused by missing type annotations for contextualized_embed on the Client and AsyncClient classes from the voyageai package. To resolve this:

  1. Ensure the voyageai package is up-to-date, as contextualized_embed may be a recent addition. Run:
    pip install --upgrade voyageai
    
  2. If the method exists in runtime but mypy still complains, add type ignore comments for the relevant lines:
    response = self._client.contextualized_embed(  # type: ignore[attr-defined]
        inputs=[batch],
        model=self.model,
        input_type=input_type,
        **kwargs,
    )
    and
    response = await self._aclient.contextualized_embed(  # type: ignore[attr-defined]
        inputs=[batch],
        model=self.model,
        input_type=input_type,
        **kwargs,
    )
  3. Alternatively, update your project's type stubs for voyageai or create a custom stub that includes contextualized_embed in both Client and AsyncClient.

This will resolve the mypy errors and allow the type checks to pass.

Relevant file: redisvl/utils/vectorize/text/voyageai.py (ref: 90340c52bfc47b4944b2095e4e1b492b80bf2507)

@fzowl
Copy link
Copy Markdown
Contributor Author

fzowl commented Nov 2, 2025

@bsbodden Yes, the contextualized_embed functions were introduced in the voyageai package 0.3.5 version, that's why i changed it in the pyproject.toml.

@fzowl
Copy link
Copy Markdown
Contributor Author

fzowl commented Nov 17, 2025

@bsbodden Can you please recheck this change? Is there anything else i should do?

@fzowl
Copy link
Copy Markdown
Contributor Author

fzowl commented Nov 24, 2025

@bsbodden Can you please take a look?

@fzowl fzowl changed the title Voyageai refactoring Voyageai refactoring and multimodal capability Dec 18, 2025
@fzowl fzowl force-pushed the voyageai_context_model_and_token_counting branch from f8578be to 04461cd Compare December 18, 2025 21:51
Copy link
Copy Markdown
Collaborator

@vishal-bala vishal-bala left a comment

Choose a reason for hiding this comment

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

Hey @fzowl, thanks for updating this PR to build on the latest vectorizer framework (and sorry for the delay reviewing) - this looks good to me. Since you made the changes, VoyageAI introduced their 4th generation models (voyage-4, etc.) - could you add those to your token limit mapping?

Also, could you rebase your PR off the current main branch for RedisVL? We've introduced some improvements to our CI/CD to allow our testing workflows to be runnable on PRs from forked repositories!

fzowl added 3 commits May 10, 2026 15:52
- Keep default model with DeprecationWarning when not explicitly set
- Add runtime DeprecationWarning when deprecated batch_size is passed
- Clarify count_tokens() is local/CPU-only in docstrings
@fzowl fzowl force-pushed the voyageai_context_model_and_token_counting branch from e88dcdb to 1e971a6 Compare May 10, 2026 17:43
@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented May 10, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

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 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1e971a6. Configure here.

DeprecationWarning,
stacklevel=2,
)
else:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Auto-batching never activates due to base class default

High Severity

The batch_size parameter in _embed_many and _aembed_many will never be None when called through the public embed_many/aembed_many API. The base class BaseVectorizer.embed_many declares batch_size: int = 10 and always forwards it, so the if batch_size is not None check always evaluates to True. This means the deprecation warning fires on every call (even when the user didn't pass batch_size), and the model-specific auto-determined batch size from _get_batch_size() is never used.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1e971a6. Configure here.

Returns:
bool: True if the model is a context model, False otherwise.
"""
return "context" in self.model
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unused method _is_context_model and constant VOYAGE_TOTAL_TOKEN_LIMITS

Medium Severity

_is_context_model() is defined but never called anywhere in production code — the _setup method doesn't route context models to contextualized_embed. Similarly, VOYAGE_TOTAL_TOKEN_LIMITS is defined but never referenced in production code (only in tests). The docstring advertises that "Context models automatically use contextualized_embed API," but this behavior is not implemented, making the documentation misleading.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1e971a6. Configure here.

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.

4 participants