Documentation
¶
Overview ¶
Package cohere provides a Cohere provider implementation.
Index ¶
- type ChatOptions
- type CohereEmbeddingModel
- func (m *CohereEmbeddingModel) Dimensions() int
- func (m *CohereEmbeddingModel) Embed(ctx context.Context, opts model.EmbedCallOptions) (*model.EmbedResult, error)
- func (m *CohereEmbeddingModel) ID() string
- func (m *CohereEmbeddingModel) MaxEmbeddingsPerCall() int
- func (m *CohereEmbeddingModel) Provider() string
- type CohereModel
- type CohereRerankingModel
- type EmbeddingOptions
- type Options
- type Provider
- func (p *Provider) EmbeddingModel(modelID string) model.EmbeddingModel
- func (p *Provider) EmbeddingModels() []string
- func (p *Provider) ID() string
- func (p *Provider) ImageModel(modelID string) model.ImageModel
- func (p *Provider) LanguageModel(modelID string) model.LanguageModel
- func (p *Provider) Model(modelID string) stream.Model
- func (p *Provider) Models() []string
- func (p *Provider) RerankingModel(modelID string) model.RerankingModel
- func (p *Provider) RerankingModels() []string
- func (p *Provider) SpeechModel(modelID string) model.SpeechModel
- func (p *Provider) TranscriptionModel(modelID string) model.TranscriptionModel
- type ThinkingConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatOptions ¶
type ChatOptions struct {
// Thinking configures reasoning features.
// See: https://docs.cohere.com/reference/chat#request.body.thinking
Thinking *ThinkingConfig `json:"thinking,omitempty"`
}
ChatOptions contains provider-specific options for the Cohere API. These options match ai-sdk's CohereChatModelOptions schema. See: ai-sdk/packages/cohere/src/cohere-chat-options.ts
type CohereEmbeddingModel ¶
type CohereEmbeddingModel struct {
// contains filtered or unexported fields
}
CohereEmbeddingModel implements the EmbeddingModel interface for Cohere.
func (*CohereEmbeddingModel) Dimensions ¶
func (m *CohereEmbeddingModel) Dimensions() int
Dimensions returns the default embedding dimensions.
func (*CohereEmbeddingModel) Embed ¶
func (m *CohereEmbeddingModel) Embed(ctx context.Context, opts model.EmbedCallOptions) (*model.EmbedResult, error)
Embed generates embeddings for the provided texts.
func (*CohereEmbeddingModel) ID ¶
func (m *CohereEmbeddingModel) ID() string
ID returns the model identifier.
func (*CohereEmbeddingModel) MaxEmbeddingsPerCall ¶
func (m *CohereEmbeddingModel) MaxEmbeddingsPerCall() int
MaxEmbeddingsPerCall returns the maximum number of texts that can be embedded in a single call.
func (*CohereEmbeddingModel) Provider ¶
func (m *CohereEmbeddingModel) Provider() string
Provider returns "cohere".
type CohereModel ¶
type CohereModel struct {
// contains filtered or unexported fields
}
CohereModel represents a Cohere model.
func (*CohereModel) Stream ¶
func (m *CohereModel) Stream(ctx context.Context, options *stream.CallOptions) (<-chan stream.Event, error)
Stream sends a streaming request to Cohere.
type CohereRerankingModel ¶
type CohereRerankingModel struct {
// contains filtered or unexported fields
}
CohereRerankingModel implements the RerankingModel interface for Cohere.
func (*CohereRerankingModel) ID ¶
func (m *CohereRerankingModel) ID() string
ID returns the model identifier.
func (*CohereRerankingModel) MaxDocumentsPerCall ¶
func (m *CohereRerankingModel) MaxDocumentsPerCall() int
MaxDocumentsPerCall returns the maximum number of documents that can be reranked in a single call.
func (*CohereRerankingModel) Provider ¶
func (m *CohereRerankingModel) Provider() string
Provider returns "cohere".
func (*CohereRerankingModel) Rerank ¶
func (m *CohereRerankingModel) Rerank(ctx context.Context, opts model.RerankCallOptions) (*model.RerankResult, error)
Rerank reranks documents based on their relevance to a query.
type EmbeddingOptions ¶
type EmbeddingOptions struct {
// InputType overrides the default "search_document". Values:
// "search_document", "search_query", "classification", "clustering".
InputType string `json:"inputType,omitempty"`
// OutputDimension selects the embedding dimensionality. Only the
// embed-v4 family supports this; Cohere accepts 256, 512, 1024,
// 1536 (ai-sdk #0df64d6).
OutputDimension int `json:"outputDimension,omitempty"`
}
EmbeddingOptions contains provider-specific options for Cohere's Embed API (ai-sdk CohereEmbeddingOptions).
type Options ¶
type Options struct {
// APIKey is the Cohere API key.
APIKey string
// BaseURL overrides the default API endpoint.
BaseURL string
// Headers are additional HTTP headers to send.
Headers map[string]string
}
Options contains configuration for the Cohere provider.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements the Cohere provider.
func (*Provider) EmbeddingModel ¶
func (p *Provider) EmbeddingModel(modelID string) model.EmbeddingModel
EmbeddingModel returns an embedding model instance.
func (*Provider) EmbeddingModels ¶
EmbeddingModels returns available embedding model IDs.
func (*Provider) ImageModel ¶
func (p *Provider) ImageModel(modelID string) model.ImageModel
ImageModel returns nil as Cohere doesn't support image generation.
func (*Provider) LanguageModel ¶
func (p *Provider) LanguageModel(modelID string) model.LanguageModel
LanguageModel returns a language model instance.
func (*Provider) Models ¶
Models returns available model IDs. Mirrors ai-sdk's CohereChatModelId union in packages/cohere/src/cohere-chat-options.ts.
func (*Provider) RerankingModel ¶
func (p *Provider) RerankingModel(modelID string) model.RerankingModel
RerankingModel returns a reranking model instance.
func (*Provider) RerankingModels ¶
RerankingModels returns available reranking model IDs.
func (*Provider) SpeechModel ¶
func (p *Provider) SpeechModel(modelID string) model.SpeechModel
SpeechModel returns nil as Cohere doesn't support speech generation.
func (*Provider) TranscriptionModel ¶
func (p *Provider) TranscriptionModel(modelID string) model.TranscriptionModel
TranscriptionModel returns nil as Cohere doesn't support transcription.
type ThinkingConfig ¶
type ThinkingConfig struct {
// Type can be "enabled" or "disabled". Default is "enabled".
Type string `json:"type,omitempty"`
// TokenBudget is the maximum number of tokens the model can use for thinking.
// Must be a positive integer. The model will stop thinking if it reaches
// the budget and proceed with the response.
TokenBudget int `json:"tokenBudget,omitempty"`
}
ThinkingConfig configures Cohere's reasoning features.