Skip to content

Conversation

@joonsoome
Copy link
Owner

…d top_n/top_k; docs

Fixes a 422 on /api/v1/rerank/ when clients (e.g., OpenWebUI) send {query, documents:[...]} instead of {passages:[...]}. Adds input normalization in models so both styles are accepted without breaking existing clients.

Changes:

  • app/models/requests.py: Add model-level pre-validation to map documents -> passages and top_n -> top_k; support documents as list[str] or list[{text:...}]. Keeps existing validation and behavior intact.
  • app/models/cohere_models.py: Normalize Cohere request payloads to accept string or object documents (text/content/body/value) and map top_k -> top_n. No router changes required.
  • README.md: Document that native /api/v1/rerank/ now accepts {documents: [...]} and {top_n} as aliases for {passages} and {top_k}.

Notes:

  • Backward compatible: clients using passages/top_k remain unaffected.
  • Cohere endpoints (/v1/rerank, /v2/rerank) already used documents; normalization now also accepts object documents and top_k alias.
  • Tests: Provided diagnosis and suggestions to harden tests/test_cohere_api.py (readiness polling, httpx, timeouts), but no test code changes included in this commit.

…d top_n/top_k; docs

Fixes a 422 on /api/v1/rerank/ when clients (e.g., OpenWebUI) send {query, documents:[...]} instead of {passages:[...]}. Adds input normalization in models so both styles are accepted without breaking existing clients.

Changes:
- app/models/requests.py: Add model-level pre-validation to map documents -> passages and top_n -> top_k; support documents as list[str] or list[{text:...}]. Keeps existing validation and behavior intact.
- app/models/cohere_models.py: Normalize Cohere request payloads to accept string or object documents (text/content/body/value) and map top_k -> top_n. No router changes required.
- README.md: Document that native /api/v1/rerank/ now accepts {documents: [...]} and {top_n} as aliases for {passages} and {top_k}.

Notes:
- Backward compatible: clients using passages/top_k remain unaffected.
- Cohere endpoints (/v1/rerank, /v2/rerank) already used documents; normalization now also accepts object documents and top_k alias.
- Tests: Provided diagnosis and suggestions to harden tests/test_cohere_api.py (readiness polling, httpx, timeouts), but no test code changes included in this commit.
@joonsoome joonsoome linked an issue Oct 24, 2025 that may be closed by this pull request
@joonsoome joonsoome merged commit 8a75b11 into main Oct 24, 2025
1 check failed
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.

Reranker: 422 Unprocessable Content

2 participants