cohere

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyResponse = errors.New("no response")
	ErrMissingToken  = errors.New("missing the COHERE_API_KEY key, set it in the COHERE_API_KEY environment variable")

	ErrUnexpectedResponseLength = errors.New("unexpected length of response")
)

Functions

func MapError

func MapError(err error) error

MapError maps Cohere-specific errors to standardized error codes.

Types

type LLM

type LLM struct {
	CallbacksHandler callbacks.Handler
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (*LLM, error)

func (*LLM) Call

func (o *LLM) Call(ctx context.Context, prompt string, options ...llms.CallOption) (string, error)

func (*LLM) GenerateContent

func (o *LLM) GenerateContent(ctx context.Context, messages []llms.MessageContent, options ...llms.CallOption) (*llms.ContentResponse, error)

GenerateContent implements the Model interface.

type Option

type Option func(*options)

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL passes the Cohere base url to the client. If not set, the base url is read from the COHERE_BASE_URL environment variable. If still not set in ENV VAR COHERE_BASE_URL, then the default value is https://api.cohere.ai is used.

func WithModel

func WithModel(model string) Option

WithModel passes the Cohere model to the client. If not set, the model is read from the COHERE_MODEL environment variable.

func WithToken

func WithToken(token string) Option

WithToken passes the Cohere API token to the client. If not set, the token is read from the COHERE_API_KEY environment variable.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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