Skip to content

feat(rerank): add litellm as rerank provider#888

Merged
qin-ctx merged 1 commit intovolcengine:mainfrom
mvanhorn:osc/874-feat-litellm-rerank-provider
Mar 23, 2026
Merged

feat(rerank): add litellm as rerank provider#888
qin-ctx merged 1 commit intovolcengine:mainfrom
mvanhorn:osc/874-feat-litellm-rerank-provider

Conversation

@mvanhorn
Copy link
Contributor

Description

Add litellm as a third rerank provider, giving users access to 20+ rerank services (Cohere, Together AI, Jina, Azure AI) through a single provider: "litellm" config. Follows the same pattern as PR #853 (litellm embedding provider).

Related Issue

Relates to #874

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • New LiteLLMRerankClient in openviking_cli/utils/rerank_litellm.py wrapping litellm.rerank()
  • RerankConfig updated to accept provider: "litellm" with validation (requires model field)
  • RerankClient.from_config() routes litellm config to the new client

Why this matters

#874 requests third-party rerank support. The current openai provider covers OpenAI-compatible APIs, but many rerank services (Cohere, Jina) use different request/response formats. litellm normalizes these differences. PR #853 just added litellm for embeddings, so this extends the same pattern to rerank.

Users with #578 also asked for extensible provider interfaces. litellm handles provider routing internally, so adding new rerank services requires zero code changes.

Usage

rerank:
  provider: litellm
  model: cohere/rerank-v3.5
  # api_key and api_base are optional - litellm reads provider-specific env vars

Verification

$ python3 -c "
from openviking_cli.utils.config.rerank_config import RerankConfig
config = RerankConfig(provider='litellm', model='cohere/rerank-v3.5')
print(f'is_available={config.is_available()}')
# -> is_available=True

from openviking_cli.utils.rerank_litellm import LiteLLMRerankClient
client = LiteLLMRerankClient.from_config(config)
print(f'client={type(client).__name__}, model={client.model_name}')
# -> client=LiteLLMRerankClient, model=cohere/rerank-v3.5

result = client.rerank_batch('test', [])
print(f'empty_docs={result}')
# -> empty_docs=[]
"

All 6 unit tests pass: client instantiation, empty docs, from_config routing, config validation (accepts with model, rejects without), factory wiring.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

This contribution was developed with AI assistance (Claude Code).

Add LiteLLMRerankClient that wraps litellm.rerank() to support 20+
rerank providers (Cohere, Together AI, Jina, Azure) through a single
configuration. Follows the pattern established by PR volcengine#853 (litellm
embedding provider).

Changes:
- New rerank_litellm.py with LiteLLMRerankClient
- RerankConfig updated to accept provider: "litellm"
- RerankClient.from_config() routes to litellm when configured

Relates to volcengine#874

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

Failed to generate code suggestions for PR

@qin-ctx qin-ctx merged commit c10f6d9 into volcengine:main Mar 23, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 23, 2026
@mvanhorn
Copy link
Contributor Author

Thanks for the review and merge, @qin-ctx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants