Skip to content

feat(rerank): add OpenAI-compatible rerank provider#785

Open
chenxiaofei-cxf wants to merge 1 commit intovolcengine:mainfrom
chenxiaofei-cxf:feat/openai-rerank-provider
Open

feat(rerank): add OpenAI-compatible rerank provider#785
chenxiaofei-cxf wants to merge 1 commit intovolcengine:mainfrom
chenxiaofei-cxf:feat/openai-rerank-provider

Conversation

@chenxiaofei-cxf
Copy link
Contributor

Summary

  • Add OpenAIRerankClient using the standard flat request/response format ({"query": ..., "documents": [...]} / {"results": [{index, relevance_score}]}) — compatible with DashScope's compatible-api endpoint and other OpenAI/Cohere-style rerank APIs
  • Fix silent data corruption: add index bounds-checking so an out-of-bounds or missing index field returns None with a warning instead of corrupting the scores array
  • Add provider allow-list validation in RerankConfig ("vikingdb" or "openai") — unknown providers raise ValueError at config parse time
  • Remove unnecessary getattr() in RerankClient.from_config() since RerankConfig.provider always has a default
  • Update example config to use DashScope's compatible-api/v1/reranks endpoint

Test plan

  • pytest tests/misc/test_rerank_openai.py -v — 24 tests, all pass (success, out-of-order, empty docs, bad format, length mismatch, out-of-bounds index, missing index, HTTP error, request shape, config factory, provider validation)
  • pytest tests/retrieve/test_hierarchical_retriever_rerank.py -v — 6 tests, all pass (backward compat)

🤖 Generated with Claude Code

- Add OpenAIRerankClient using standard flat request/response format
  compatible with DashScope compatible-api and other OpenAI/Cohere-style
  rerank APIs (no input/output wrappers)
- Fix silent data corruption: add index bounds-checking so out-of-bounds
  or missing index returns None with a warning
- Add provider allow-list validation in RerankConfig ('vikingdb'|'openai')
- Remove unnecessary getattr() in RerankClient.from_config()
- Update ov.conf.example: keep vikingdb (doubao) as primary rerank config,
  add rerank_openai_example section for DashScope qwen3-rerank
- Update docs (en/zh): add OpenAI-compatible provider example alongside
  existing volcengine example in configuration guide and schema
- Add 24 tests covering success, edge cases, and factory dispatch

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@chenxiaofei-cxf chenxiaofei-cxf force-pushed the feat/openai-rerank-provider branch from 8700c28 to 371ebec Compare March 19, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant