Skip to content

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

Merged
qin-ctx merged 1 commit intovolcengine:mainfrom
chenxiaofei-cxf:feat/openai-rerank-provider
Mar 20, 2026
Merged

feat(rerank): add OpenAI-compatible rerank provider#785
qin-ctx merged 1 commit intovolcengine:mainfrom
chenxiaofei-cxf:feat/openai-rerank-provider

Conversation

@chenxiaofei-cxf
Copy link
Copy Markdown
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 371ebec to bd8b77c Compare March 19, 2026 23:37
"model_version": "251028",
"threshold": 0.1
},
"rerank_openai_example": {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this example with "rerank_openai_example" key doesn't look right to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This follows the existing convention in the file — embedding_ollama_example uses the same *_example key pattern. Happy to change it if there's a preferred alternative, but it seemed consistent with what's already there.

@ZaynJarvis
Copy link
Copy Markdown
Collaborator

others seems ok as long as it's tested @qin-ctx

@qin-ctx qin-ctx merged commit 44d9542 into volcengine:main Mar 20, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 20, 2026
zeattacker pushed a commit to zeattacker/OpenViking that referenced this pull request Mar 20, 2026
- 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>
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.

3 participants