cohere

package
v2.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Overview

Package cohere provides reranking via the Cohere Rerank API.

Only the rerank role is implemented. Cohere also offers chat and embedding endpoints; those would be separate providers in this package if they are ever needed, and their absence is deliberate rather than an oversight.

Index

Constants

View Source
const (
	// DefaultRerankModel is the recommended multilingual reranker.
	DefaultRerankModel = "rerank-v3.5"

	// ModelRerankV35 is Cohere's current general-purpose reranker.
	ModelRerankV35 = "rerank-v3.5"

	// ModelRerankEnglishV30 is the English-only v3 reranker.
	ModelRerankEnglishV30 = "rerank-english-v3.0"

	// ModelRerankMultilingualV30 is the multilingual v3 reranker.
	ModelRerankMultilingualV30 = "rerank-multilingual-v3.0"
)

Rerank model constants for Cohere.

Variables

This section is empty.

Functions

This section is empty.

Types

type RerankOption

type RerankOption func(*RerankProvider)

RerankOption configures the RerankProvider.

func WithAPIKey

func WithAPIKey(key string) RerankOption

WithAPIKey sets the API key explicitly.

func WithBaseURL

func WithBaseURL(url string) RerankOption

WithBaseURL sets a custom base URL.

func WithHTTPClient

func WithHTTPClient(client *http.Client) RerankOption

WithHTTPClient sets a custom HTTP client.

func WithMaxTokensPerDoc

func WithMaxTokensPerDoc(n int) RerankOption

WithMaxTokensPerDoc caps how much of each document Cohere reads.

func WithModel

func WithModel(model string) RerankOption

WithModel sets the rerank model.

type RerankProvider

type RerankProvider struct {
	*providers.BaseRerankProvider
	// contains filtered or unexported fields
}

RerankProvider implements reranking via the Cohere Rerank API.

func NewRerankProvider

func NewRerankProvider(opts ...RerankOption) (*RerankProvider, error)

NewRerankProvider creates a Cohere rerank provider.

func (*RerankProvider) Rerank

Rerank orders documents by relevance to the query.

Jump to

Keyboard shortcuts

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