cohere

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIKeyEnv                    = "COHERE_API_KEY"
	DefaultBaseURL               = "https://api.cohere.ai"
	APIVersionV1      APIVersion = "v1"
	DefaultAPIVersion            = APIVersionV1
	ClientName                   = "chroma-go-client"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIVersion

type APIVersion string

type CohereClient

type CohereClient struct {
	BaseURL       string            `validate:"required"`
	APIVersion    APIVersion        `validate:"required"`
	APIKey        embeddings.Secret `json:"-" validate:"required"`
	APIKeyEnvVar  string            `json:"-"`
	Client        *http.Client
	DefaultModel  embeddings.EmbeddingModel `validate:"required"`
	RetryStrategy httpc.RetryStrategy
	Insecure      bool
}

CohereClient is a common struct for various Cohere integrations - Embeddings, Rerank etc.

func NewCohereClient

func NewCohereClient(opts ...Option) (*CohereClient, error)

func (*CohereClient) DoRequest

func (c *CohereClient) DoRequest(req *http.Request) (*http.Response, error)

func (*CohereClient) GetAPIEndpoint

func (c *CohereClient) GetAPIEndpoint(endpoint string) string

func (*CohereClient) GetRequest

func (c *CohereClient) GetRequest(ctx context.Context, method string, endpoint string, content string) (*http.Request, error)

TODO GetRequest is misleading, it should be renamed to GetHTTPRequest

type CohereModel

type CohereModel string // generic type for Cohere models

func (CohereModel) String

func (m CohereModel) String() string

type Option

type Option func(p *CohereClient) error

func NoOp

func NoOp() Option

func WithAPIKey

func WithAPIKey(apiKey string) Option

func WithAPIKeyFromEnvVar added in v0.3.0

func WithAPIKeyFromEnvVar(envVar string) Option

WithAPIKeyFromEnvVar sets the API key for the client from a specified environment variable

func WithAPIVersion

func WithAPIVersion(version APIVersion) Option

func WithBaseURL

func WithBaseURL(baseURL string) Option

func WithDefaultModel

func WithDefaultModel(model embeddings.EmbeddingModel) Option

WithDefaultModel sets the default model for the Cohere client

func WithEnvAPIKey

func WithEnvAPIKey() Option

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets the HTTP client for the Cohere client

func WithInsecure added in v0.3.0

func WithInsecure() Option

WithInsecure allows the client to connect to HTTP endpoints without TLS. This should only be used for local development or testing.

func WithRetryStrategy

func WithRetryStrategy(retryStrategy httpc.RetryStrategy) Option

WithRetryStrategy sets the retry strategy for the Cohere client

Jump to

Keyboard shortcuts

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