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 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 Client ¶
type Client struct { EmbedJobs *embedjobs.Client Datasets *datasets.Client Connectors *connectors.Client Models *models.Client Finetuning *finetuningclient.Client // contains filtered or unexported fields }
func NewClient ¶
func NewClient(opts ...option.RequestOption) *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 with Streaming 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 text response to a user message. To learn how to use the Chat API with Streaming 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 embeddings. An embedding is a list of floating point numbers that captures semantic information about the text that it represents.
Embeddings can be used to create text 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](/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](/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API.
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](/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API.
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](/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API.
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.