Documentation
¶
Index ¶
Constants ¶
View Source
const ( // BaseURL is Cohere HTTP API base URL. BaseURL = "https://api.cohere.ai" // EmbedAPIVersion is the latest stable embedding API version. EmbedAPIVersion = "v1" )
Variables ¶
This section is empty.
Functions ¶
func NewEmbedder ¶
func NewEmbedder(opts ...Option) embeddings.Embedder[*EmbeddingRequest]
NewEmbedder creates a client that implements embeddings.Embedder
Types ¶
type APIError ¶
type APIError struct {
Message string `json:"message"`
}
APIError is Cohere API error.
type APIVersion ¶
type APIVersion struct {
Version string `json:"version"`
}
APIVersion stores metadata API version.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is Cohere HTTP API client.
type EmbedddingResponse ¶
type EmbedddingResponse struct { Embeddings [][]float64 `json:"embeddings"` Meta *Meta `json:"meta,omitempty"` }
EmbedddingResponse received from API.
func (*EmbedddingResponse) ToEmbeddings ¶
func (e *EmbedddingResponse) ToEmbeddings() ([]*embeddings.Embedding, error)
ToEmbeddings converts the API response, into a slice of embeddings and returns it.
type EmbeddingRequest ¶
type EmbeddingRequest struct { Texts []string `json:"texts"` Model Model `json:"model,omitempty"` InputType InputType `json:"input_type"` Truncate Truncate `json:"truncate,omitempty"` }
EmbeddingRequest sent to API endpoint.
type Meta ¶
type Meta struct {
APIVersion *APIVersion `json:"api_version,omitempty"`
}
Meta stores API response metadata.
type Model ¶
type Model string
Model is an embedding model.
const ( EnglishV3 Model = "embed-english-v3.0" MultiLingV3 Model = "embed-multilingual-v3.0" EnglishLightV3 Model = "embed-english-light-v3.0" MultiLingLightV3 Model = "embed-multilingual-light-v3.0" EnglishV2 Model = "embed-english-v2.0" EnglishLightV2 Model = "embed-english-light-v2.0" MultiLingV2 Model = "embed-multilingual-v2.0" )
type Option ¶
type Option func(*Options)
Option is functional option.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client.
Click to show internal directories.
Click to hide internal directories.