Documentation
¶
Index ¶
- type CohereModel
- type CohereRerankingFunction
- func (c CohereRerankingFunction) ID() string
- func (c CohereRerankingFunction) Rerank(ctx context.Context, query string, results []rerankings.Result) (map[string][]rerankings.RankedResult, error)
- func (c CohereRerankingFunction) RerankResults(ctx context.Context, queryResults *chromago.QueryResults) (*rerankings.RerankedChromaResults, error)
- type Option
- func WithAPIKey(apiKey string) Option
- func WithBaseURL(baseURL string) Option
- func WithDefaultModel(model ccommons.CohereModel) Option
- func WithEnvAPIKey() Option
- func WithMaxChunksPerDoc(maxChunks int) Option
- func WithRerankFields(fields []string) Option
- func WithRetryStrategy(retryStrategy httpc.RetryStrategy) Option
- func WithReturnDocuments() Option
- func WithTopN(topN int) Option
- type RerankRequest
- type RerankResponse
- type RerankResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CohereModel ¶
type CohereModel = ccommons.CohereModel
const ( DefaultRerankingEndpoint = "rerank" ModelRerankEnglishV30 CohereModel = "rerank-english-v3.0" DefaultModel CohereModel = ModelRerankEnglishV30 ModelRerankMultilingualV30 CohereModel = "rerank-multilingual-v3.0" ModelRerankEnglishV20 CohereModel = "rerank-english-v2.0" ModelRerankMultilingualV20 CohereModel = "rerank-multilingual-v2.0" )
type CohereRerankingFunction ¶
type CohereRerankingFunction struct { ccommons.CohereClient TopN int RerankFields []string ReturnDocuments bool MaxChunksPerDoc int RerankEndpoint string }
func NewCohereRerankingFunction ¶
func NewCohereRerankingFunction(opts ...Option) (*CohereRerankingFunction, error)
func (CohereRerankingFunction) ID ¶
func (c CohereRerankingFunction) ID() string
ID returns the of the reranking function. We use `cohere-` prefix with the default model
func (CohereRerankingFunction) Rerank ¶
func (c CohereRerankingFunction) Rerank(ctx context.Context, query string, results []rerankings.Result) (map[string][]rerankings.RankedResult, error)
func (CohereRerankingFunction) RerankResults ¶
func (c CohereRerankingFunction) RerankResults(ctx context.Context, queryResults *chromago.QueryResults) (*rerankings.RerankedChromaResults, error)
type Option ¶
type Option func(p *CohereRerankingFunction) ccommons.Option
func WithAPIKey ¶
func WithBaseURL ¶
func WithDefaultModel ¶
func WithDefaultModel(model ccommons.CohereModel) Option
func WithEnvAPIKey ¶
func WithEnvAPIKey() Option
WithEnvAPIKey configures the client to use the COHERE_API_KEY environment variable as the API key
func WithMaxChunksPerDoc ¶
func WithRerankFields ¶
WithRerankFields configures the client to use the specified fields for reranking if the documents are in JSON format
func WithRetryStrategy ¶
func WithRetryStrategy(retryStrategy httpc.RetryStrategy) Option
WithRetryStrategy configures the client to use the specified retry strategy
func WithReturnDocuments ¶
func WithReturnDocuments() Option
WithReturnDocuments configures the client to return the original documents in the response
type RerankRequest ¶
type RerankRequest struct { Model string `json:"model"` Query string `json:"query"` Documents []any `json:"documents"` TopN int `json:"top_n,omitempty"` RerankFields []string `json:"rerank_fields,omitempty"` ReturnDocuments bool `json:"return_documents,omitempty"` MaxChunksPerDoc int `json:"max_chunks_per_doc,omitempty"` }
type RerankResponse ¶
type RerankResponse struct { ID string `json:"id"` Results []RerankResult `json:"results"` Meta map[string]any `json:"meta"` }
type RerankResult ¶
Click to show internal directories.
Click to hide internal directories.