cohere

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package cohere provides a Cohere provider implementation.

Index

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

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) ID

func (m *CohereModel) ID() string

ID returns the model ID.

func (*CohereModel) Provider

func (m *CohereModel) Provider() string

Provider returns "cohere".

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

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 New

func New(opts Options) *Provider

New creates a new Cohere provider.

func (*Provider) EmbeddingModel

func (p *Provider) EmbeddingModel(modelID string) model.EmbeddingModel

EmbeddingModel returns an embedding model instance.

func (*Provider) EmbeddingModels

func (p *Provider) EmbeddingModels() []string

EmbeddingModels returns available embedding model IDs.

func (*Provider) ID

func (p *Provider) ID() string

ID returns "cohere".

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) Model

func (p *Provider) Model(modelID string) stream.Model

Model returns a language model instance.

func (*Provider) Models

func (p *Provider) Models() []string

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

func (p *Provider) RerankingModels() []string

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.

Jump to

Keyboard shortcuts

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