Skip to content

Rerank hardcodes api_version, so amazon.rerank-v1:0 can never be called #190

Description

@hilariie

Rerank takes any modelID but always sends a cohereRerankRequest, which always carries api_version: 2 (rerank.go:44-49, :138-143). The Amazon rerank schema rejects that key, so every call fails:

ValidationException: Malformed input request: extraneous key [api_version] is not permitted, please reformat your input and try again.

Repro (needs a region that offers the model, e.g. us-west-2; it is not in us-east-1):

resp, err := bedrock.Rerank(ctx, g, "amazon.rerank-v1:0", &ai.RerankerRequest{
	Query:     ai.DocumentFromText("What is the capital of France?", nil),
	Documents: []*ai.Document{ai.DocumentFromText("Paris is the capital of France.", nil)},
})

The two families are otherwise identical: same query/documents/top_n body over InvokeModel, same {"results": [{"index", "relevance_score"}]} response, so buildRerankResponse already handles Amazon unchanged. The only incompatible field is api_version, and Cohere requires it (omitting it fails with required key [api_version] not found), while Amazon forbids it. Both errors are from live ValidationException responses in us-west-2.

If Cohere-only is deliberate, the fix is a clear error instead: reject non-Cohere IDs in Rerank rather than sending a body the service will refuse.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions