Documentation
¶
Index ¶
- func WithBaseURL(baseURL string) *core.BaseURLOption
- func WithClientName(clientName *string) *core.ClientNameOption
- func WithHTTPClient(httpClient core.HTTPClient) *core.HTTPClientOption
- func WithHTTPHeader(httpHeader http.Header) *core.HTTPHeaderOption
- func WithMaxAttempts(attempts uint) *core.MaxAttemptsOption
- func WithToken(token string) *core.TokenOption
- type AwsAccessKey
- type AwsEnvironment
- type AwsRegion
- type AwsRequestOption
- type AwsRequestOptions
- type AwsSecretKey
- type AwsSessionToken
- type Client
- func NewAwsClient(baseOpts []option.RequestOption, awsOpts []AwsRequestOption, service string) *Client
- func NewBedrockClient(baseOpts []option.RequestOption, awsOpts []AwsRequestOption) *Client
- func NewClient(opts ...option.RequestOption) *Client
- func NewSagemakerClient(baseOpts []option.RequestOption, awsOpts []AwsRequestOption) *Client
- func (c *Client) Chat(ctx context.Context, request *v2.ChatRequest, opts ...option.RequestOption) (*v2.NonStreamedChatResponse, error)
- func (c *Client) ChatStream(ctx context.Context, request *v2.ChatStreamRequest, ...) (*core.Stream[v2.StreamedChatResponse], error)
- func (c *Client) CheckApiKey(ctx context.Context, opts ...option.RequestOption) (*v2.CheckApiKeyResponse, error)
- func (c *Client) Classify(ctx context.Context, request *v2.ClassifyRequest, opts ...option.RequestOption) (*v2.ClassifyResponse, error)
- func (c *Client) Detokenize(ctx context.Context, request *v2.DetokenizeRequest, ...) (*v2.DetokenizeResponse, error)
- func (c *Client) Embed(ctx context.Context, request *v2.EmbedRequest, opts ...option.RequestOption) (*v2.EmbedResponse, error)
- func (c *Client) Generate(ctx context.Context, request *v2.GenerateRequest, opts ...option.RequestOption) (*v2.Generation, error)
- func (c *Client) GenerateStream(ctx context.Context, request *v2.GenerateStreamRequest, ...) (*core.Stream[v2.GenerateStreamedResponse], error)
- func (c *Client) Rerank(ctx context.Context, request *v2.RerankRequest, opts ...option.RequestOption) (*v2.RerankResponse, error)
- func (c *Client) Summarize(ctx context.Context, request *v2.SummarizeRequest, ...) (*v2.SummarizeResponse, error)
- func (c *Client) Tokenize(ctx context.Context, request *v2.TokenizeRequest, opts ...option.RequestOption) (*v2.TokenizeResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithBaseURL ¶
func WithBaseURL(baseURL string) *core.BaseURLOption
WithBaseURL sets the base URL, overriding the default environment, if any.
func WithClientName ¶ added in v2.5.0
func WithClientName(clientName *string) *core.ClientNameOption
WithClientName sets the clientName request header.
The name of the project that is making the request.
func WithHTTPClient ¶
func WithHTTPClient(httpClient core.HTTPClient) *core.HTTPClientOption
WithHTTPClient uses the given HTTPClient to issue the request.
func WithHTTPHeader ¶
func WithHTTPHeader(httpHeader http.Header) *core.HTTPHeaderOption
WithHTTPHeader adds the given http.Header to the request.
func WithMaxAttempts ¶ added in v2.5.2
func WithMaxAttempts(attempts uint) *core.MaxAttemptsOption
WithMaxAttempts configures the maximum number of retry attempts.
func WithToken ¶
func WithToken(token string) *core.TokenOption
WithToken sets the 'Authorization: Bearer <token>' request header.
Types ¶
type AwsAccessKey ¶ added in v2.8.5
type AwsAccessKey struct {
// contains filtered or unexported fields
}
func WithAwsAccessKey ¶ added in v2.8.5
func WithAwsAccessKey(accessKey string) *AwsAccessKey
type AwsEnvironment ¶ added in v2.8.5
type AwsEnvironment struct {
// contains filtered or unexported fields
}
AwsEnvironment implements the RequestOption interface.
type AwsRegion ¶ added in v2.8.5
type AwsRegion struct {
// contains filtered or unexported fields
}
func WithAwsRegion ¶ added in v2.8.5
type AwsRequestOption ¶ added in v2.8.5
type AwsRequestOption interface {
// contains filtered or unexported methods
}
RequestOption adapts the behavior of the client or an individual request.
type AwsRequestOptions ¶ added in v2.8.5
type AwsRequestOptions struct {
// contains filtered or unexported fields
}
type AwsSecretKey ¶ added in v2.8.5
type AwsSecretKey struct {
// contains filtered or unexported fields
}
func WithAwsSecretKey ¶ added in v2.8.5
func WithAwsSecretKey(secretKey string) *AwsSecretKey
type AwsSessionToken ¶ added in v2.8.5
type AwsSessionToken struct {
// contains filtered or unexported fields
}
func WithAwsSessionToken ¶ added in v2.8.5
func WithAwsSessionToken(sessionToken string) *AwsSessionToken
type Client ¶
type Client struct { V2 *v2v2.Client EmbedJobs *embedjobs.Client Datasets *datasets.Client Connectors *connectors.Client Models *models.Client Finetuning *finetuningclient.Client // contains filtered or unexported fields }
func NewAwsClient ¶ added in v2.8.5
func NewAwsClient(baseOpts []option.RequestOption, awsOpts []AwsRequestOption, service string) *Client
func NewBedrockClient ¶ added in v2.8.5
func NewBedrockClient(baseOpts []option.RequestOption, awsOpts []AwsRequestOption) *Client
func NewClient ¶
func NewClient(opts ...option.RequestOption) *Client
func NewSagemakerClient ¶ added in v2.8.5
func NewSagemakerClient(baseOpts []option.RequestOption, awsOpts []AwsRequestOption) *Client
func (*Client) Chat ¶
func (c *Client) Chat( ctx context.Context, request *v2.ChatRequest, opts ...option.RequestOption, ) (*v2.NonStreamedChatResponse, error)
Generates a text response to a user message. To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api).
func (*Client) ChatStream ¶
func (c *Client) ChatStream( ctx context.Context, request *v2.ChatStreamRequest, opts ...option.RequestOption, ) (*core.Stream[v2.StreamedChatResponse], error)
Generates a streamed text response to a user message.
To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api).
func (*Client) CheckApiKey ¶ added in v2.7.4
func (c *Client) CheckApiKey( ctx context.Context, opts ...option.RequestOption, ) (*v2.CheckApiKeyResponse, error)
Checks that the api key in the Authorization header is valid and active
func (*Client) Classify ¶
func (c *Client) Classify( ctx context.Context, request *v2.ClassifyRequest, opts ...option.RequestOption, ) (*v2.ClassifyResponse, error)
This endpoint makes a prediction about which label fits the specified text inputs best. To make a prediction, Classify uses the provided `examples` of text + label pairs as a reference. Note: [Fine-tuned models](https://docs.cohere.com/docs/classify-fine-tuning) trained on classification examples don't require the `examples` parameter to be passed in explicitly.
func (*Client) Detokenize ¶
func (c *Client) Detokenize( ctx context.Context, request *v2.DetokenizeRequest, opts ...option.RequestOption, ) (*v2.DetokenizeResponse, error)
This endpoint takes tokens using byte-pair encoding and returns their text representation. To learn more about tokenization and byte pair encoding, see the tokens page.
func (*Client) Embed ¶
func (c *Client) Embed( ctx context.Context, request *v2.EmbedRequest, opts ...option.RequestOption, ) (*v2.EmbedResponse, error)
This endpoint returns text and image embeddings. An embedding is a list of floating point numbers that captures semantic information about the content that it represents.
Embeddings can be used to create classifiers as well as empower semantic search. To learn more about embeddings, see the embedding page.
If you want to learn more how to use the embedding model, have a look at the [Semantic Search Guide](https://docs.cohere.com/docs/semantic-search).
func (*Client) Generate ¶
func (c *Client) Generate( ctx context.Context, request *v2.GenerateRequest, opts ...option.RequestOption, ) (*v2.Generation, error)
<Warning> This API is marked as "Legacy" and is no longer maintained. Follow the [migration guide](https://docs.cohere.com/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API. </Warning> Generates realistic text conditioned on a given input.
func (*Client) GenerateStream ¶ added in v2.5.0
func (c *Client) GenerateStream( ctx context.Context, request *v2.GenerateStreamRequest, opts ...option.RequestOption, ) (*core.Stream[v2.GenerateStreamedResponse], error)
<Warning> This API is marked as "Legacy" and is no longer maintained. Follow the [migration guide](https://docs.cohere.com/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API. </Warning> Generates realistic text conditioned on a given input.
func (*Client) Rerank ¶
func (c *Client) Rerank( ctx context.Context, request *v2.RerankRequest, opts ...option.RequestOption, ) (*v2.RerankResponse, error)
This endpoint takes in a query and a list of texts and produces an ordered array with each text assigned a relevance score.
func (*Client) Summarize ¶
func (c *Client) Summarize( ctx context.Context, request *v2.SummarizeRequest, opts ...option.RequestOption, ) (*v2.SummarizeResponse, error)
<Warning> This API is marked as "Legacy" and is no longer maintained. Follow the [migration guide](https://docs.cohere.com/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API. </Warning> Generates a summary in English for a given text.
func (*Client) Tokenize ¶
func (c *Client) Tokenize( ctx context.Context, request *v2.TokenizeRequest, opts ...option.RequestOption, ) (*v2.TokenizeResponse, error)
This endpoint splits input text into smaller units called tokens using byte-pair encoding (BPE). To learn more about tokenization and byte pair encoding, see the tokens page.