rerank

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package rerank adapts the app.RerankProvider port to a Cohere-style rerank HTTP API (POST /rerank with {model, query, documents, top_n} → {results: [{index, relevance_score}]}), the de-facto standard that Cohere, Jina, Voyage, and others conform to. It is a separate provider from the OpenAI-compatible embed/chat endpoint, reusing only the shared httpjson transport (auth, retry).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reranker

type Reranker struct {
	// contains filtered or unexported fields
}

Reranker calls a Cohere-style /rerank endpoint.

func NewReranker

func NewReranker(baseURL, apiKey, model string, auth httpjson.Auth, httpClient *http.Client) (*Reranker, error)

NewReranker constructs a Reranker. baseURL and model are required (an unconfigured rerank provider is a usage error the caller surfaces). auth selects the API-key scheme; a nil httpClient uses http.DefaultClient.

func (*Reranker) Rerank

func (r *Reranker) Rerank(ctx context.Context, query string, documents []string, topN int) ([]app.RankResult, error)

Rerank scores documents against query via the /rerank endpoint and returns the results best-first as the provider ordered them. topN is forwarded when set; the Reranker use case still owns final ordering/truncation. Empty documents makes no request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL