Repository navigation
gen-ai mock server: serve Cohere v2 rerank - #245
Open
Krishnachaitanyakc wants to merge 2 commits into
Open
Krishnachaitanyakc wants to merge 2 commits into
Krishnachaitanyakc wants to merge 2 commits into
Conversation
Pull request dashboard statusWaiting on reviewers · refreshed 2026-10-17 01:48 UTC Review the latest changes. Also blocked by: Merge conflicts. Status above doesn't look right?
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The endpoint must distinguish top_n: 0 from an omitted value.
Review effort: Balanced
Findings: None
What changed in this PR
Adds deterministic Cohere v2 rerank support to the GenAI mock server.
Changes:
- Implements
POST /v2/rerank. - Adds deterministic ranking and
top_ntests. - Documents the endpoint.
| File | Description |
|---|---|
tools/gen-ai/mock-server/tests/test_mock_server.py |
Tests determinism and ranking behavior. |
tools/gen-ai/mock-server/src/genai_mock_server/cohere.py |
Implements reranking; explicit top_n: 0 is not honored. |
tools/gen-ai/mock-server/README.md |
Documents rerank support. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This comment has been minimized.
This comment has been minimized.
Add POST /v2/rerank to the Cohere mock. It returns the SDK's V2RerankResponse shape, ranking the request's documents in order and trimming to top_n, so the same request always gets the same bytes.
An explicit top_n of 0 fell through to len(documents) and returned every document. Only a missing or null top_n now means all of them.
Krishnachaitanyakc
force-pushed
the
cohere-rerank-mock
branch
from
October 2, 2026 04:52
7980999 to
8d848c5
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
POST /v2/rerankto the Cohere mock. It returns the SDK'sV2RerankResponseshape, ranking the request's documents in order and trimming totop_n, so the same request always gets the same bytes.semantic-conventions-genai needs it for the Cohere and LiteLLM reference scenarios demonstrating a proposed
rerankoperation (open-telemetry/semantic-conventions-genai#253). LiteLLM's Cohere provider posts to the same route. Today both get a 404 from the mock.