cohere

package
v0.10.3-0...-96d0e78 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CohereClient

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

func NewCohereClient

func NewCohereClient(apiKey string) (*CohereClient, error)

func (*CohereClient) Embedding

func (c *CohereClient) Embedding(url string, modelName string, texts []string, inputType string, outputType string, truncate string, timeoutSec int64) (*EmbeddingResponse, error)

func (*CohereClient) Rerank

func (c *CohereClient) Rerank(url string, modelName string, query string, texts []string, params map[string]any, timeoutSec int64) (*RerankResponse, error)

type EmbeddingRequest

type EmbeddingRequest struct {
	// ID of the model to use.
	Model string `json:"model"`

	Texts []string `json:"texts"`

	InputType string `json:"input_type,omitempty"`

	EmbeddingTypes []string `json:"embedding_types"`

	// Allowed values: NONE,START, END (default)
	// Passing START will discard the start of the input.
	// END will discard the end of the input. In both cases, input is discarded until the remaining input is
	// exactly the maximum input token length for the model.
	// If NONE is selected, when the input exceeds the maximum input token length an error will be returned.
	Truncate string `json:"truncate,omitempty"`
}

type EmbeddingResponse

type EmbeddingResponse struct {
	Id         string     `json:"id"`
	Embeddings Embeddings `json:"embeddings"`
}

type Embeddings

type Embeddings struct {
	Float [][]float32 `json:"float"`
	Int8  [][]int8    `json:"int8"`
}

Currently only float32/int8 is supported

type Meta

type Meta struct {
	APIVersion struct {
		Version        string `json:"version"`
		IsExperimental bool   `json:"is_experimental"`
	} `json:"api_version"`
	BilledUnits struct {
		SearchUnits int `json:"search_units"`
	} `json:"billed_units"`
}

type RerankResponse

type RerankResponse struct {
	Results []RerankResult `json:"results"`
	Id      string         `json:"id"`
	Meta    Meta           `json:"meta"`
}

type RerankResult

type RerankResult struct {
	Index          int     `json:"index"`
	RelevanceScore float32 `json:"relevance_score"`
}

Jump to

Keyboard shortcuts

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