Skip to content

Commit f87b5a8

Browse files
Fix rerank docstring/comment accuracy (PR review)
Two doc-accuracy fixes from the PR #205 review: - The cohere.py module docstring said ScoredDocument.document is null on every result, but the parser passes a document echo through when a response carries one (fixture 012 + unit tests). Reword to match. - The response.py comment said undeclared extras are forwarded to the wire untouched, but the mapping reserves model / query / documents / top_n. Tighten to note the provider-reserved keys.
1 parent bf64a1a commit f87b5a8

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/openarmature/retrieval/providers/cohere.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
provider appends ``/v2/rerank``), overridable for a proxy / private gateway.
1717
The ``transport`` parameter is the test seam (``httpx.MockTransport``).
1818
19-
The Cohere ``/v2/rerank`` wire has no ``return_documents`` parameter and
20-
never echoes document text, so
19+
The Cohere ``/v2/rerank`` wire has no ``return_documents`` parameter, so
2120
``RerankRuntimeConfig.return_documents`` is a silent no-op on this wire (the
22-
mapping sends no wire field for it and leaves ``ScoredDocument.document`` null
23-
on every result). ``max_tokens_per_doc`` rides the extras pass-through bag.
21+
mapping sends no wire field for it). Cohere v2 does not echo document text, so
22+
``ScoredDocument.document`` is null in practice; the parser still passes
23+
through a ``document`` echo when a response carries one (a compatible gateway
24+
or a fixture). ``max_tokens_per_doc`` rides the extras pass-through bag.
2425
"""
2526

2627
from __future__ import annotations

src/openarmature/retrieval/response.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ class RerankResponse(BaseModel):
160160

161161
# Spec §2 rerank runtime config: one declared field ``return_documents``
162162
# (boolean, default False) plus the extras pass-through bag (``extra="allow"``).
163-
# Undeclared fields supplied by callers are forwarded to the wire body
164-
# untouched by the §8 wire-format mapping.
163+
# Undeclared fields supplied by callers are forwarded to the wire body by the
164+
# §8 wire-format mapping, except for the provider-reserved keys a mapping
165+
# manages itself (e.g. the Cohere mapping owns model / query / documents /
166+
# top_n, so a caller extra cannot clobber them).
165167
class RerankRuntimeConfig(BaseModel):
166168
"""Per-call rerank request parameters."""
167169

0 commit comments

Comments
 (0)