cohere

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 9 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"`

	Client        *http.Client
	DefaultModel  CohereModel `validate:"required"`
	RetryStrategy httpc.RetryStrategy
	// contains filtered or unexported fields
}

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 WithAPIVersion

func WithAPIVersion(version APIVersion) Option

func WithBaseURL

func WithBaseURL(baseURL string) Option

func WithDefaultModel

func WithDefaultModel(model CohereModel) 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 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