Skip to content

Check /reranker top_n at the REST level #7212

@mkhludnev

Description

@mkhludnev

Is your feature request related to a problem? Please describe.
While working on #7189, #6700 esp. #7199, I realized that there's no constraint check for top_n parameter at the REST level.

Describe the solution you'd like

Providing https://api.jina.ai/redoc#tag/rerank/operation/rank_v1_rerank_post and https://jina.ai/reranker/ as a spec

  • top_n<=0 - respond with 422, see below
  • top_n>=len(documents) or top_n is absent ;-( although I've got 500 from JINA API when omit it) - just ignore it, respond with score desc docs
  • 0<top_n<len(documents) - crop score desc docs
"detail": "[] Validation error: 'body -> jina-reranker-v3 -> top_n' Input should be greater than or equal to 1. Field errors: : Invalid value",
  "errors": [
    {
      "field": "body -> jina-reranker-v3 -> top_n",
      "message": "Input should be greater than or equal to 1",
      "type": "greater_than_equal",
      "input": "0"
    }
  ]

I suppose preliminary check will simplify backends, reducing a need in constraint check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions