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 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.
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 ¶
func (p *RerankProvider) Rerank( ctx context.Context, req providers.RerankRequest, ) (providers.RerankResponse, error)
Rerank orders documents by relevance to the query.
Click to show internal directories.
Click to hide internal directories.