Skip to content

gen-ai mock server: serve Cohere v2 rerank - #245

Open
Krishnachaitanyakc wants to merge 2 commits into
open-telemetry:mainfrom
Krishnachaitanyakc:cohere-rerank-mock
Open

Krishnachaitanyakc wants to merge 2 commits into
open-telemetry:mainfrom
Krishnachaitanyakc:cohere-rerank-mock

Conversation

@Krishnachaitanyakc

Copy link
Copy Markdown
Member

Adds 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.

semantic-conventions-genai needs it for the Cohere and LiteLLM reference scenarios demonstrating a proposed rerank operation (open-telemetry/semantic-conventions-genai#253). LiteLLM's Cohere provider posts to the same route. Today both get a 404 from the mock.

@Krishnachaitanyakc
Krishnachaitanyakc requested a review from a team as a code owner September 23, 2026 22:10
Copilot AI balanced review requested due to automatic review settings September 23, 2026 22:10
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-10-17 01:48 UTC

Review the latest changes.

Also blocked by: Merge conflicts.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_n tests.
  • 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.

@opentelemetry-pr-dashboard

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.

This branch has not been deployed

No deployments
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.

2 participants