api

package module
v2.12.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 8 Imported by: 38

README

Cohere Go Library

fern shield go shield

The Cohere Go library provides convenient access to the Cohere API from Go.

Requirements

This module requires Go version >= 1.18.

Installation

Run the following command to use the Cohere Go library in your module:

go get github.com/cohere-ai/cohere-go/v2

Usage

import cohereclient "github.com/cohere-ai/cohere-go/v2/client"

client := cohereclient.NewClient(cohereclient.WithToken("<YOUR_AUTH_TOKEN>"))

Chat

import (
  cohere       "github.com/cohere-ai/cohere-go/v2"
  cohereclient "github.com/cohere-ai/cohere-go/v2/client"
)

client := cohereclient.NewClient(cohereclient.WithToken("<YOUR_AUTH_TOKEN>"))
response, err := client.Chat(
  context.TODO(),
  &cohere.ChatRequest{
    Message: "How is the weather today?",
  },
)

Timeouts

Setting a timeout for each individual request is as simple as using the standard context library. Setting a one second timeout for an individual API call looks like the following:

ctx, cancel := context.WithTimeout(context.TODO(), time.Second)
defer cancel()

response, err := client.Chat(
  context.TODO(),
  &cohere.ChatRequest{
    Message: "How is the weather today?",
  },
)

Client Options

A variety of client options are included to adapt the behavior of the library, which includes configuring authorization tokens to be sent on every request, or providing your own instrumented *http.Client. Both of these options are shown below:

client := cohereclient.NewClient(
  cohereclient.WithToken("<YOUR_AUTH_TOKEN>"),
  cohereclient.WithHTTPClient(
    &http.Client{
      Timeout: 5 * time.Second,
    },
  ),
)

Providing your own *http.Client is recommended. Otherwise, the http.DefaultClient will be used, and your client will wait indefinitely for a response (unless the per-request, context-based timeout is used).

Errors

Structured error types are returned from API calls that return non-success status codes. For example, you can check if the error was due to a bad request (i.e. status code 400) with the following:

response, err := client.Generate(
  context.TODO(),
  &cohere.GenerateRequest{
    Prompt: "invalid prompt",
  },
)
if err != nil {
  if badRequestErr, ok := err.(*cohere.BadRequestError);
    // Do something with the bad request ...
  }
  return err
}

These errors are also compatible with the errors.Is and errors.As APIs, so you can access the error like so:

response, err := client.Generate(
  context.TODO(),
  &cohere.GenerateRequest{
    Prompt: "invalid prompt",
  },
)
if err != nil {
  var badRequestErr *cohere.BadRequestError
  if errors.As(err, badRequestErr) {
    // Do something with the bad request ...
  }
  return err
}

If you'd like to wrap the errors with additional information and still retain the ability to access the type with errors.Is and errors.As, you can use the %w directive:

response, err := client.Generate(
  context.TODO(),
  &cohere.GenerateRequest{
    Prompt: "invalid prompt",
  },
)
if err != nil {
  return fmt.Errorf("failed to generate response: %w", err)
}

Streaming

Calling any of Cohere's streaming APIs is easy. Simply create a new stream type and read each message returned from the server until it's done:

stream, err := client.ChatStream(
  context.TODO(),
  &cohere.ChatStreamRequest{
    Message: "Please write a short story about the weather today.",
  },
)
if err != nil {
  return nil, err
}

// Make sure to close the stream when you're done reading.
// This is easily handled with defer.
defer stream.Close()

for {
  message, err := stream.Recv()
  if errors.Is(err, io.EOF) {
    // An io.EOF error means the server is done sending messages
    // and should be treated as a success.
    break
  }
  if err != nil {
    // The stream has encountered a non-recoverable error. Propagate the
    // error by simply returning the error like usual.
    return nil, err
  }
  // Do something with the message!
}

In summary, callers of the stream API use stream.Recv() to receive a new message from the stream. The stream is complete when the io.EOF error is returned, and if a non-io.EOF error is returned, it should be treated just like any other non-nil error.

Beta Status

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning the package version to a specific version. This way, you can install the same version each time without breaking changes.

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Environments = struct {
	Production string
}{
	Production: "https://api.cohere.com",
}

Environments defines all of the API environments. These values can be used with the WithBaseURL RequestOption to override the client's default environment, if any.

Functions

func Bool

func Bool(b bool) *bool

Bool returns a pointer to the given bool value.

func Byte

func Byte(b byte) *byte

Byte returns a pointer to the given byte value.

func Complex128

func Complex128(c complex128) *complex128

Complex128 returns a pointer to the given complex128 value.

func Complex64

func Complex64(c complex64) *complex64

Complex64 returns a pointer to the given complex64 value.

func Float32

func Float32(f float32) *float32

Float32 returns a pointer to the given float32 value.

func Float64

func Float64(f float64) *float64

Float64 returns a pointer to the given float64 value.

func Int

func Int(i int) *int

Int returns a pointer to the given int value.

func Int16

func Int16(i int16) *int16

Int16 returns a pointer to the given int16 value.

func Int32

func Int32(i int32) *int32

Int32 returns a pointer to the given int32 value.

func Int64

func Int64(i int64) *int64

Int64 returns a pointer to the given int64 value.

func Int8

func Int8(i int8) *int8

Int8 returns a pointer to the given int8 value.

func MustParseDate added in v2.6.0

func MustParseDate(date string) time.Time

MustParseDate attempts to parse the given string as a date time.Time, and panics upon failure.

func MustParseDateTime added in v2.6.0

func MustParseDateTime(datetime string) time.Time

MustParseDateTime attempts to parse the given string as a datetime time.Time, and panics upon failure.

func Rune

func Rune(r rune) *rune

Rune returns a pointer to the given rune value.

func String

func String(s string) *string

String returns a pointer to the given string value.

func Time

func Time(t time.Time) *time.Time

Time returns a pointer to the given time.Time value.

func UUID added in v2.6.0

func UUID(u uuid.UUID) *uuid.UUID

UUID returns a pointer to the given uuid.UUID value.

func Uint

func Uint(u uint) *uint

Uint returns a pointer to the given uint value.

func Uint16

func Uint16(u uint16) *uint16

Uint16 returns a pointer to the given uint16 value.

func Uint32

func Uint32(u uint32) *uint32

Uint32 returns a pointer to the given uint32 value.

func Uint64

func Uint64(u uint64) *uint64

Uint64 returns a pointer to the given uint64 value.

func Uint8

func Uint8(u uint8) *uint8

Uint8 returns a pointer to the given uint8 value.

func Uintptr

func Uintptr(u uintptr) *uintptr

Uintptr returns a pointer to the given uintptr value.

Types

type ApiMeta

type ApiMeta struct {
	ApiVersion  *ApiMetaApiVersion  `json:"api_version,omitempty" url:"api_version,omitempty"`
	BilledUnits *ApiMetaBilledUnits `json:"billed_units,omitempty" url:"billed_units,omitempty"`
	Tokens      *ApiMetaTokens      `json:"tokens,omitempty" url:"tokens,omitempty"`
	Warnings    []string            `json:"warnings,omitempty" url:"warnings,omitempty"`
	// contains filtered or unexported fields
}

func (*ApiMeta) GetApiVersion added in v2.12.4

func (a *ApiMeta) GetApiVersion() *ApiMetaApiVersion

func (*ApiMeta) GetBilledUnits added in v2.12.4

func (a *ApiMeta) GetBilledUnits() *ApiMetaBilledUnits

func (*ApiMeta) GetExtraProperties added in v2.8.2

func (a *ApiMeta) GetExtraProperties() map[string]interface{}

func (*ApiMeta) GetTokens added in v2.12.4

func (a *ApiMeta) GetTokens() *ApiMetaTokens

func (*ApiMeta) GetWarnings added in v2.12.4

func (a *ApiMeta) GetWarnings() []string

func (*ApiMeta) String

func (a *ApiMeta) String() string

func (*ApiMeta) UnmarshalJSON

func (a *ApiMeta) UnmarshalJSON(data []byte) error

type ApiMetaApiVersion

type ApiMetaApiVersion struct {
	Version        string `json:"version" url:"version"`
	IsDeprecated   *bool  `json:"is_deprecated,omitempty" url:"is_deprecated,omitempty"`
	IsExperimental *bool  `json:"is_experimental,omitempty" url:"is_experimental,omitempty"`
	// contains filtered or unexported fields
}

func (*ApiMetaApiVersion) GetExtraProperties added in v2.8.2

func (a *ApiMetaApiVersion) GetExtraProperties() map[string]interface{}

func (*ApiMetaApiVersion) GetIsDeprecated added in v2.12.4

func (a *ApiMetaApiVersion) GetIsDeprecated() *bool

func (*ApiMetaApiVersion) GetIsExperimental added in v2.12.4

func (a *ApiMetaApiVersion) GetIsExperimental() *bool

func (*ApiMetaApiVersion) GetVersion added in v2.12.4

func (a *ApiMetaApiVersion) GetVersion() string

func (*ApiMetaApiVersion) String

func (a *ApiMetaApiVersion) String() string

func (*ApiMetaApiVersion) UnmarshalJSON

func (a *ApiMetaApiVersion) UnmarshalJSON(data []byte) error

type ApiMetaBilledUnits added in v2.5.0

type ApiMetaBilledUnits struct {
	// The number of billed images.
	Images *float64 `json:"images,omitempty" url:"images,omitempty"`
	// The number of billed input tokens.
	InputTokens *float64 `json:"input_tokens,omitempty" url:"input_tokens,omitempty"`
	// The number of billed output tokens.
	OutputTokens *float64 `json:"output_tokens,omitempty" url:"output_tokens,omitempty"`
	// The number of billed search units.
	SearchUnits *float64 `json:"search_units,omitempty" url:"search_units,omitempty"`
	// The number of billed classifications units.
	Classifications *float64 `json:"classifications,omitempty" url:"classifications,omitempty"`
	// contains filtered or unexported fields
}

func (*ApiMetaBilledUnits) GetClassifications added in v2.12.4

func (a *ApiMetaBilledUnits) GetClassifications() *float64

func (*ApiMetaBilledUnits) GetExtraProperties added in v2.8.2

func (a *ApiMetaBilledUnits) GetExtraProperties() map[string]interface{}

func (*ApiMetaBilledUnits) GetImages added in v2.12.4

func (a *ApiMetaBilledUnits) GetImages() *float64

func (*ApiMetaBilledUnits) GetInputTokens added in v2.12.4

func (a *ApiMetaBilledUnits) GetInputTokens() *float64

func (*ApiMetaBilledUnits) GetOutputTokens added in v2.12.4

func (a *ApiMetaBilledUnits) GetOutputTokens() *float64

func (*ApiMetaBilledUnits) GetSearchUnits added in v2.12.4

func (a *ApiMetaBilledUnits) GetSearchUnits() *float64

func (*ApiMetaBilledUnits) String added in v2.5.0

func (a *ApiMetaBilledUnits) String() string

func (*ApiMetaBilledUnits) UnmarshalJSON added in v2.5.0

func (a *ApiMetaBilledUnits) UnmarshalJSON(data []byte) error

type ApiMetaTokens added in v2.7.3

type ApiMetaTokens struct {
	// The number of tokens used as input to the model.
	InputTokens *float64 `json:"input_tokens,omitempty" url:"input_tokens,omitempty"`
	// The number of tokens produced by the model.
	OutputTokens *float64 `json:"output_tokens,omitempty" url:"output_tokens,omitempty"`
	// contains filtered or unexported fields
}

func (*ApiMetaTokens) GetExtraProperties added in v2.8.2

func (a *ApiMetaTokens) GetExtraProperties() map[string]interface{}

func (*ApiMetaTokens) GetInputTokens added in v2.12.4

func (a *ApiMetaTokens) GetInputTokens() *float64

func (*ApiMetaTokens) GetOutputTokens added in v2.12.4

func (a *ApiMetaTokens) GetOutputTokens() *float64

func (*ApiMetaTokens) String added in v2.7.3

func (a *ApiMetaTokens) String() string

func (*ApiMetaTokens) UnmarshalJSON added in v2.7.3

func (a *ApiMetaTokens) UnmarshalJSON(data []byte) error

type AssistantMessage added in v2.12.0

type AssistantMessage struct {
	ToolCalls []*ToolCallV2 `json:"tool_calls,omitempty" url:"tool_calls,omitempty"`
	// A chain-of-thought style reflection and plan that the model generates when working with Tools.
	ToolPlan  *string                  `json:"tool_plan,omitempty" url:"tool_plan,omitempty"`
	Content   *AssistantMessageContent `json:"content,omitempty" url:"content,omitempty"`
	Citations []*Citation              `json:"citations,omitempty" url:"citations,omitempty"`
	// contains filtered or unexported fields
}

A message from the assistant role can contain text and tool call information.

func (*AssistantMessage) GetCitations added in v2.12.4

func (a *AssistantMessage) GetCitations() []*Citation

func (*AssistantMessage) GetContent added in v2.12.4

func (a *AssistantMessage) GetContent() *AssistantMessageContent

func (*AssistantMessage) GetExtraProperties added in v2.12.0

func (a *AssistantMessage) GetExtraProperties() map[string]interface{}

func (*AssistantMessage) GetToolCalls added in v2.12.4

func (a *AssistantMessage) GetToolCalls() []*ToolCallV2

func (*AssistantMessage) GetToolPlan added in v2.12.4

func (a *AssistantMessage) GetToolPlan() *string

func (*AssistantMessage) String added in v2.12.0

func (a *AssistantMessage) String() string

func (*AssistantMessage) UnmarshalJSON added in v2.12.0

func (a *AssistantMessage) UnmarshalJSON(data []byte) error

type AssistantMessageContent added in v2.12.0

type AssistantMessageContent struct {
	String                          string
	AssistantMessageContentItemList []*AssistantMessageContentItem
	// contains filtered or unexported fields
}

func (*AssistantMessageContent) Accept added in v2.12.0

func (*AssistantMessageContent) GetAssistantMessageContentItemList added in v2.12.4

func (a *AssistantMessageContent) GetAssistantMessageContentItemList() []*AssistantMessageContentItem

func (*AssistantMessageContent) GetString added in v2.12.4

func (a *AssistantMessageContent) GetString() string

func (AssistantMessageContent) MarshalJSON added in v2.12.0

func (a AssistantMessageContent) MarshalJSON() ([]byte, error)

func (*AssistantMessageContent) UnmarshalJSON added in v2.12.0

func (a *AssistantMessageContent) UnmarshalJSON(data []byte) error

type AssistantMessageContentItem added in v2.12.0

type AssistantMessageContentItem struct {
	Type string
	Text *TextContent
}

func (*AssistantMessageContentItem) Accept added in v2.12.0

func (*AssistantMessageContentItem) GetText added in v2.12.4

func (*AssistantMessageContentItem) GetType added in v2.12.4

func (a *AssistantMessageContentItem) GetType() string

func (AssistantMessageContentItem) MarshalJSON added in v2.12.0

func (a AssistantMessageContentItem) MarshalJSON() ([]byte, error)

func (*AssistantMessageContentItem) UnmarshalJSON added in v2.12.0

func (a *AssistantMessageContentItem) UnmarshalJSON(data []byte) error

type AssistantMessageContentItemVisitor added in v2.12.0

type AssistantMessageContentItemVisitor interface {
	VisitText(*TextContent) error
}

type AssistantMessageContentVisitor added in v2.12.0

type AssistantMessageContentVisitor interface {
	VisitString(string) error
	VisitAssistantMessageContentItemList([]*AssistantMessageContentItem) error
}

type AssistantMessageResponse added in v2.12.0

type AssistantMessageResponse struct {
	ToolCalls []*ToolCallV2 `json:"tool_calls,omitempty" url:"tool_calls,omitempty"`
	// A chain-of-thought style reflection and plan that the model generates when working with Tools.
	ToolPlan  *string                                `json:"tool_plan,omitempty" url:"tool_plan,omitempty"`
	Content   []*AssistantMessageResponseContentItem `json:"content,omitempty" url:"content,omitempty"`
	Citations []*Citation                            `json:"citations,omitempty" url:"citations,omitempty"`
	// contains filtered or unexported fields
}

A message from the assistant role can contain text and tool call information.

func (*AssistantMessageResponse) GetCitations added in v2.12.4

func (a *AssistantMessageResponse) GetCitations() []*Citation

func (*AssistantMessageResponse) GetContent added in v2.12.4

func (*AssistantMessageResponse) GetExtraProperties added in v2.12.0

func (a *AssistantMessageResponse) GetExtraProperties() map[string]interface{}

func (*AssistantMessageResponse) GetToolCalls added in v2.12.4

func (a *AssistantMessageResponse) GetToolCalls() []*ToolCallV2

func (*AssistantMessageResponse) GetToolPlan added in v2.12.4

func (a *AssistantMessageResponse) GetToolPlan() *string

func (*AssistantMessageResponse) MarshalJSON added in v2.12.0

func (a *AssistantMessageResponse) MarshalJSON() ([]byte, error)

func (*AssistantMessageResponse) Role added in v2.12.0

func (a *AssistantMessageResponse) Role() string

func (*AssistantMessageResponse) String added in v2.12.0

func (a *AssistantMessageResponse) String() string

func (*AssistantMessageResponse) UnmarshalJSON added in v2.12.0

func (a *AssistantMessageResponse) UnmarshalJSON(data []byte) error

type AssistantMessageResponseContentItem added in v2.12.0

type AssistantMessageResponseContentItem struct {
	Type string
	Text *TextContent
}

func (*AssistantMessageResponseContentItem) Accept added in v2.12.0

func (*AssistantMessageResponseContentItem) GetText added in v2.12.4

func (*AssistantMessageResponseContentItem) GetType added in v2.12.4

func (AssistantMessageResponseContentItem) MarshalJSON added in v2.12.0

func (a AssistantMessageResponseContentItem) MarshalJSON() ([]byte, error)

func (*AssistantMessageResponseContentItem) UnmarshalJSON added in v2.12.0

func (a *AssistantMessageResponseContentItem) UnmarshalJSON(data []byte) error

type AssistantMessageResponseContentItemVisitor added in v2.12.0

type AssistantMessageResponseContentItemVisitor interface {
	VisitText(*TextContent) error
}

type AuthTokenType added in v2.5.0

type AuthTokenType string

The token_type specifies the way the token is passed in the Authorization header. Valid values are "bearer", "basic", and "noscheme".

const (
	AuthTokenTypeBearer   AuthTokenType = "bearer"
	AuthTokenTypeBasic    AuthTokenType = "basic"
	AuthTokenTypeNoscheme AuthTokenType = "noscheme"
)

func NewAuthTokenTypeFromString added in v2.5.0

func NewAuthTokenTypeFromString(s string) (AuthTokenType, error)

func (AuthTokenType) Ptr added in v2.5.0

func (a AuthTokenType) Ptr() *AuthTokenType

type BadRequestError

type BadRequestError struct {
	*core.APIError
	Body interface{}
}

This error is returned when the request is not well formed. This could be because:

  • JSON is invalid
  • The request is missing required fields
  • The request contains an invalid combination of fields

func (*BadRequestError) MarshalJSON

func (b *BadRequestError) MarshalJSON() ([]byte, error)

func (*BadRequestError) UnmarshalJSON

func (b *BadRequestError) UnmarshalJSON(data []byte) error

func (*BadRequestError) Unwrap

func (b *BadRequestError) Unwrap() error

type ChatCitation

type ChatCitation struct {
	// The index of text that the citation starts at, counting from zero. For example, a generation of `Hello, world!` with a citation on `world` would have a start value of `7`. This is because the citation starts at `w`, which is the seventh character.
	Start int `json:"start" url:"start"`
	// The index of text that the citation ends after, counting from zero. For example, a generation of `Hello, world!` with a citation on `world` would have an end value of `11`. This is because the citation ends after `d`, which is the eleventh character.
	End int `json:"end" url:"end"`
	// The text of the citation. For example, a generation of `Hello, world!` with a citation of `world` would have a text value of `world`.
	Text string `json:"text" url:"text"`
	// Identifiers of documents cited by this section of the generated reply.
	DocumentIds []string `json:"document_ids,omitempty" url:"document_ids,omitempty"`
	// contains filtered or unexported fields
}

A section of the generated reply which cites external knowledge.

func (*ChatCitation) GetDocumentIds added in v2.12.4

func (c *ChatCitation) GetDocumentIds() []string

func (*ChatCitation) GetEnd added in v2.12.4

func (c *ChatCitation) GetEnd() int

func (*ChatCitation) GetExtraProperties added in v2.8.2

func (c *ChatCitation) GetExtraProperties() map[string]interface{}

func (*ChatCitation) GetStart added in v2.12.4

func (c *ChatCitation) GetStart() int

func (*ChatCitation) GetText added in v2.12.4

func (c *ChatCitation) GetText() string

func (*ChatCitation) String

func (c *ChatCitation) String() string

func (*ChatCitation) UnmarshalJSON

func (c *ChatCitation) UnmarshalJSON(data []byte) error

type ChatCitationGenerationEvent

type ChatCitationGenerationEvent struct {
	// Citations for the generated reply.
	Citations []*ChatCitation `json:"citations,omitempty" url:"citations,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatCitationGenerationEvent) GetCitations added in v2.12.4

func (c *ChatCitationGenerationEvent) GetCitations() []*ChatCitation

func (*ChatCitationGenerationEvent) GetExtraProperties added in v2.8.2

func (c *ChatCitationGenerationEvent) GetExtraProperties() map[string]interface{}

func (*ChatCitationGenerationEvent) String

func (c *ChatCitationGenerationEvent) String() string

func (*ChatCitationGenerationEvent) UnmarshalJSON

func (c *ChatCitationGenerationEvent) UnmarshalJSON(data []byte) error

type ChatConnector

type ChatConnector struct {
	// The identifier of the connector.
	Id string `json:"id" url:"id"`
	// When specified, this user access token will be passed to the connector in the Authorization header instead of the Cohere generated one.
	UserAccessToken *string `json:"user_access_token,omitempty" url:"user_access_token,omitempty"`
	// Defaults to `false`.
	//
	// When `true`, the request will continue if this connector returned an error.
	ContinueOnFailure *bool `json:"continue_on_failure,omitempty" url:"continue_on_failure,omitempty"`
	// Provides the connector with different settings at request time. The key/value pairs of this object are specific to each connector.
	//
	// For example, the connector `web-search` supports the `site` option, which limits search results to the specified domain.
	Options map[string]interface{} `json:"options,omitempty" url:"options,omitempty"`
	// contains filtered or unexported fields
}

The connector used for fetching documents.

func (*ChatConnector) GetContinueOnFailure added in v2.12.4

func (c *ChatConnector) GetContinueOnFailure() *bool

func (*ChatConnector) GetExtraProperties added in v2.8.2

func (c *ChatConnector) GetExtraProperties() map[string]interface{}

func (*ChatConnector) GetId added in v2.12.4

func (c *ChatConnector) GetId() string

func (*ChatConnector) GetOptions added in v2.12.4

func (c *ChatConnector) GetOptions() map[string]interface{}

func (*ChatConnector) GetUserAccessToken added in v2.12.4

func (c *ChatConnector) GetUserAccessToken() *string

func (*ChatConnector) String

func (c *ChatConnector) String() string

func (*ChatConnector) UnmarshalJSON

func (c *ChatConnector) UnmarshalJSON(data []byte) error

type ChatContentDeltaEvent added in v2.12.0

type ChatContentDeltaEvent struct {
	Index    *int                        `json:"index,omitempty" url:"index,omitempty"`
	Delta    *ChatContentDeltaEventDelta `json:"delta,omitempty" url:"delta,omitempty"`
	Logprobs *LogprobItem                `json:"logprobs,omitempty" url:"logprobs,omitempty"`
	// contains filtered or unexported fields
}

A streamed delta event which contains a delta of chat text content.

func (*ChatContentDeltaEvent) GetDelta added in v2.12.4

func (*ChatContentDeltaEvent) GetExtraProperties added in v2.12.0

func (c *ChatContentDeltaEvent) GetExtraProperties() map[string]interface{}

func (*ChatContentDeltaEvent) GetIndex added in v2.12.4

func (c *ChatContentDeltaEvent) GetIndex() *int

func (*ChatContentDeltaEvent) GetLogprobs added in v2.12.4

func (c *ChatContentDeltaEvent) GetLogprobs() *LogprobItem

func (*ChatContentDeltaEvent) String added in v2.12.0

func (c *ChatContentDeltaEvent) String() string

func (*ChatContentDeltaEvent) UnmarshalJSON added in v2.12.0

func (c *ChatContentDeltaEvent) UnmarshalJSON(data []byte) error

type ChatContentDeltaEventDelta added in v2.12.0

type ChatContentDeltaEventDelta struct {
	Message *ChatContentDeltaEventDeltaMessage `json:"message,omitempty" url:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatContentDeltaEventDelta) GetExtraProperties added in v2.12.0

func (c *ChatContentDeltaEventDelta) GetExtraProperties() map[string]interface{}

func (*ChatContentDeltaEventDelta) GetMessage added in v2.12.4

func (*ChatContentDeltaEventDelta) String added in v2.12.0

func (c *ChatContentDeltaEventDelta) String() string

func (*ChatContentDeltaEventDelta) UnmarshalJSON added in v2.12.0

func (c *ChatContentDeltaEventDelta) UnmarshalJSON(data []byte) error

type ChatContentDeltaEventDeltaMessage added in v2.12.0

type ChatContentDeltaEventDeltaMessage struct {
	Content *ChatContentDeltaEventDeltaMessageContent `json:"content,omitempty" url:"content,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatContentDeltaEventDeltaMessage) GetContent added in v2.12.4

func (*ChatContentDeltaEventDeltaMessage) GetExtraProperties added in v2.12.0

func (c *ChatContentDeltaEventDeltaMessage) GetExtraProperties() map[string]interface{}

func (*ChatContentDeltaEventDeltaMessage) String added in v2.12.0

func (*ChatContentDeltaEventDeltaMessage) UnmarshalJSON added in v2.12.0

func (c *ChatContentDeltaEventDeltaMessage) UnmarshalJSON(data []byte) error

type ChatContentDeltaEventDeltaMessageContent added in v2.12.0

type ChatContentDeltaEventDeltaMessageContent struct {
	Text *string `json:"text,omitempty" url:"text,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatContentDeltaEventDeltaMessageContent) GetExtraProperties added in v2.12.0

func (c *ChatContentDeltaEventDeltaMessageContent) GetExtraProperties() map[string]interface{}

func (*ChatContentDeltaEventDeltaMessageContent) GetText added in v2.12.4

func (*ChatContentDeltaEventDeltaMessageContent) String added in v2.12.0

func (*ChatContentDeltaEventDeltaMessageContent) UnmarshalJSON added in v2.12.0

func (c *ChatContentDeltaEventDeltaMessageContent) UnmarshalJSON(data []byte) error

type ChatContentEndEvent added in v2.12.0

type ChatContentEndEvent struct {
	Index *int `json:"index,omitempty" url:"index,omitempty"`
	// contains filtered or unexported fields
}

A streamed delta event which signifies that the content block has ended.

func (*ChatContentEndEvent) GetExtraProperties added in v2.12.0

func (c *ChatContentEndEvent) GetExtraProperties() map[string]interface{}

func (*ChatContentEndEvent) GetIndex added in v2.12.4

func (c *ChatContentEndEvent) GetIndex() *int

func (*ChatContentEndEvent) String added in v2.12.0

func (c *ChatContentEndEvent) String() string

func (*ChatContentEndEvent) UnmarshalJSON added in v2.12.0

func (c *ChatContentEndEvent) UnmarshalJSON(data []byte) error

type ChatContentStartEvent added in v2.12.0

type ChatContentStartEvent struct {
	Index *int                        `json:"index,omitempty" url:"index,omitempty"`
	Delta *ChatContentStartEventDelta `json:"delta,omitempty" url:"delta,omitempty"`
	// contains filtered or unexported fields
}

A streamed delta event which signifies that a new content block has started.

func (*ChatContentStartEvent) GetDelta added in v2.12.4

func (*ChatContentStartEvent) GetExtraProperties added in v2.12.0

func (c *ChatContentStartEvent) GetExtraProperties() map[string]interface{}

func (*ChatContentStartEvent) GetIndex added in v2.12.4

func (c *ChatContentStartEvent) GetIndex() *int

func (*ChatContentStartEvent) String added in v2.12.0

func (c *ChatContentStartEvent) String() string

func (*ChatContentStartEvent) UnmarshalJSON added in v2.12.0

func (c *ChatContentStartEvent) UnmarshalJSON(data []byte) error

type ChatContentStartEventDelta added in v2.12.0

type ChatContentStartEventDelta struct {
	Message *ChatContentStartEventDeltaMessage `json:"message,omitempty" url:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatContentStartEventDelta) GetExtraProperties added in v2.12.0

func (c *ChatContentStartEventDelta) GetExtraProperties() map[string]interface{}

func (*ChatContentStartEventDelta) GetMessage added in v2.12.4

func (*ChatContentStartEventDelta) String added in v2.12.0

func (c *ChatContentStartEventDelta) String() string

func (*ChatContentStartEventDelta) UnmarshalJSON added in v2.12.0

func (c *ChatContentStartEventDelta) UnmarshalJSON(data []byte) error

type ChatContentStartEventDeltaMessage added in v2.12.0

type ChatContentStartEventDeltaMessage struct {
	Content *ChatContentStartEventDeltaMessageContent `json:"content,omitempty" url:"content,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatContentStartEventDeltaMessage) GetContent added in v2.12.4

func (*ChatContentStartEventDeltaMessage) GetExtraProperties added in v2.12.0

func (c *ChatContentStartEventDeltaMessage) GetExtraProperties() map[string]interface{}

func (*ChatContentStartEventDeltaMessage) String added in v2.12.0

func (*ChatContentStartEventDeltaMessage) UnmarshalJSON added in v2.12.0

func (c *ChatContentStartEventDeltaMessage) UnmarshalJSON(data []byte) error

type ChatContentStartEventDeltaMessageContent added in v2.12.0

type ChatContentStartEventDeltaMessageContent struct {
	Text *string `json:"text,omitempty" url:"text,omitempty"`
	Type *string `json:"type,omitempty" url:"type,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatContentStartEventDeltaMessageContent) GetExtraProperties added in v2.12.0

func (c *ChatContentStartEventDeltaMessageContent) GetExtraProperties() map[string]interface{}

func (*ChatContentStartEventDeltaMessageContent) GetText added in v2.12.4

func (*ChatContentStartEventDeltaMessageContent) String added in v2.12.0

func (*ChatContentStartEventDeltaMessageContent) UnmarshalJSON added in v2.12.0

func (c *ChatContentStartEventDeltaMessageContent) UnmarshalJSON(data []byte) error

type ChatDataMetrics added in v2.6.0

type ChatDataMetrics struct {
	// The sum of all turns of valid train examples.
	NumTrainTurns *int64 `json:"num_train_turns,omitempty" url:"num_train_turns,omitempty"`
	// The sum of all turns of valid eval examples.
	NumEvalTurns *int64 `json:"num_eval_turns,omitempty" url:"num_eval_turns,omitempty"`
	// The preamble of this dataset.
	Preamble *string `json:"preamble,omitempty" url:"preamble,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatDataMetrics) GetExtraProperties added in v2.8.2

func (c *ChatDataMetrics) GetExtraProperties() map[string]interface{}

func (*ChatDataMetrics) GetNumEvalTurns added in v2.12.4

func (c *ChatDataMetrics) GetNumEvalTurns() *int64

func (*ChatDataMetrics) GetNumTrainTurns added in v2.12.4

func (c *ChatDataMetrics) GetNumTrainTurns() *int64

func (*ChatDataMetrics) GetPreamble added in v2.12.4

func (c *ChatDataMetrics) GetPreamble() *string

func (*ChatDataMetrics) String added in v2.6.0

func (c *ChatDataMetrics) String() string

func (*ChatDataMetrics) UnmarshalJSON added in v2.6.0

func (c *ChatDataMetrics) UnmarshalJSON(data []byte) error

type ChatDebugEvent added in v2.12.1

type ChatDebugEvent struct {
	Prompt *string `json:"prompt,omitempty" url:"prompt,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatDebugEvent) GetExtraProperties added in v2.12.1

func (c *ChatDebugEvent) GetExtraProperties() map[string]interface{}

func (*ChatDebugEvent) GetPrompt added in v2.12.4

func (c *ChatDebugEvent) GetPrompt() *string

func (*ChatDebugEvent) String added in v2.12.1

func (c *ChatDebugEvent) String() string

func (*ChatDebugEvent) UnmarshalJSON added in v2.12.1

func (c *ChatDebugEvent) UnmarshalJSON(data []byte) error

type ChatDocument

type ChatDocument = map[string]string

Relevant information that could be used by the model to generate a more accurate reply. The contents of each document are generally short (under 300 words), and are passed in the form of a dictionary of strings. Some suggested keys are "text", "author", "date". Both the key name and the value will be passed to the model.

type ChatFinishReason added in v2.12.0

type ChatFinishReason string

The reason a chat request has finished.

- **complete**: The model finished sending a complete message. - **max_tokens**: The number of generated tokens exceeded the model's context length or the value specified via the `max_tokens` parameter. - **stop_sequence**: One of the provided `stop_sequence` entries was reached in the model's generation. - **tool_call**: The model generated a Tool Call and is expecting a Tool Message in return - **error**: The generation failed due to an internal error

const (
	ChatFinishReasonComplete     ChatFinishReason = "COMPLETE"
	ChatFinishReasonStopSequence ChatFinishReason = "STOP_SEQUENCE"
	ChatFinishReasonMaxTokens    ChatFinishReason = "MAX_TOKENS"
	ChatFinishReasonToolCall     ChatFinishReason = "TOOL_CALL"
	ChatFinishReasonError        ChatFinishReason = "ERROR"
)

func NewChatFinishReasonFromString added in v2.12.0

func NewChatFinishReasonFromString(s string) (ChatFinishReason, error)

func (ChatFinishReason) Ptr added in v2.12.0

type ChatMessage

type ChatMessage struct {
	// Contents of the chat message.
	Message   string      `json:"message" url:"message"`
	ToolCalls []*ToolCall `json:"tool_calls,omitempty" url:"tool_calls,omitempty"`
	// contains filtered or unexported fields
}

Represents a single message in the chat history, excluding the current user turn. It has two properties: `role` and `message`. The `role` identifies the sender (`CHATBOT`, `SYSTEM`, or `USER`), while the `message` contains the text content.

The chat_history parameter should not be used for `SYSTEM` messages in most cases. Instead, to add a `SYSTEM` role message at the beginning of a conversation, the `preamble` parameter should be used.

func (*ChatMessage) GetExtraProperties added in v2.8.2

func (c *ChatMessage) GetExtraProperties() map[string]interface{}

func (*ChatMessage) GetMessage added in v2.12.4

func (c *ChatMessage) GetMessage() string

func (*ChatMessage) GetToolCalls added in v2.12.4

func (c *ChatMessage) GetToolCalls() []*ToolCall

func (*ChatMessage) String

func (c *ChatMessage) String() string

func (*ChatMessage) UnmarshalJSON

func (c *ChatMessage) UnmarshalJSON(data []byte) error

type ChatMessageEndEvent added in v2.12.0

type ChatMessageEndEvent struct {
	Id    *string                   `json:"id,omitempty" url:"id,omitempty"`
	Delta *ChatMessageEndEventDelta `json:"delta,omitempty" url:"delta,omitempty"`
	// contains filtered or unexported fields
}

A streamed event which signifies that the chat message has ended.

func (*ChatMessageEndEvent) GetDelta added in v2.12.4

func (*ChatMessageEndEvent) GetExtraProperties added in v2.12.0

func (c *ChatMessageEndEvent) GetExtraProperties() map[string]interface{}

func (*ChatMessageEndEvent) GetId added in v2.12.4

func (c *ChatMessageEndEvent) GetId() *string

func (*ChatMessageEndEvent) String added in v2.12.0

func (c *ChatMessageEndEvent) String() string

func (*ChatMessageEndEvent) UnmarshalJSON added in v2.12.0

func (c *ChatMessageEndEvent) UnmarshalJSON(data []byte) error

type ChatMessageEndEventDelta added in v2.12.0

type ChatMessageEndEventDelta struct {
	FinishReason *ChatFinishReason `json:"finish_reason,omitempty" url:"finish_reason,omitempty"`
	Usage        *Usage            `json:"usage,omitempty" url:"usage,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatMessageEndEventDelta) GetExtraProperties added in v2.12.0

func (c *ChatMessageEndEventDelta) GetExtraProperties() map[string]interface{}

func (*ChatMessageEndEventDelta) GetFinishReason added in v2.12.4

func (c *ChatMessageEndEventDelta) GetFinishReason() *ChatFinishReason

func (*ChatMessageEndEventDelta) GetUsage added in v2.12.4

func (c *ChatMessageEndEventDelta) GetUsage() *Usage

func (*ChatMessageEndEventDelta) String added in v2.12.0

func (c *ChatMessageEndEventDelta) String() string

func (*ChatMessageEndEventDelta) UnmarshalJSON added in v2.12.0

func (c *ChatMessageEndEventDelta) UnmarshalJSON(data []byte) error

type ChatMessageStartEvent added in v2.12.0

type ChatMessageStartEvent struct {
	// Unique identifier for the generated reply.
	Id    *string                     `json:"id,omitempty" url:"id,omitempty"`
	Delta *ChatMessageStartEventDelta `json:"delta,omitempty" url:"delta,omitempty"`
	// contains filtered or unexported fields
}

A streamed event which signifies that a stream has started.

func (*ChatMessageStartEvent) GetDelta added in v2.12.4

func (*ChatMessageStartEvent) GetExtraProperties added in v2.12.0

func (c *ChatMessageStartEvent) GetExtraProperties() map[string]interface{}

func (*ChatMessageStartEvent) GetId added in v2.12.4

func (c *ChatMessageStartEvent) GetId() *string

func (*ChatMessageStartEvent) String added in v2.12.0

func (c *ChatMessageStartEvent) String() string

func (*ChatMessageStartEvent) UnmarshalJSON added in v2.12.0

func (c *ChatMessageStartEvent) UnmarshalJSON(data []byte) error

type ChatMessageStartEventDelta added in v2.12.0

type ChatMessageStartEventDelta struct {
	Message *ChatMessageStartEventDeltaMessage `json:"message,omitempty" url:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatMessageStartEventDelta) GetExtraProperties added in v2.12.0

func (c *ChatMessageStartEventDelta) GetExtraProperties() map[string]interface{}

func (*ChatMessageStartEventDelta) GetMessage added in v2.12.4

func (*ChatMessageStartEventDelta) String added in v2.12.0

func (c *ChatMessageStartEventDelta) String() string

func (*ChatMessageStartEventDelta) UnmarshalJSON added in v2.12.0

func (c *ChatMessageStartEventDelta) UnmarshalJSON(data []byte) error

type ChatMessageStartEventDeltaMessage added in v2.12.0

type ChatMessageStartEventDeltaMessage struct {
	// The role of the message.
	Role *string `json:"role,omitempty" url:"role,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatMessageStartEventDeltaMessage) GetExtraProperties added in v2.12.0

func (c *ChatMessageStartEventDeltaMessage) GetExtraProperties() map[string]interface{}

func (*ChatMessageStartEventDeltaMessage) String added in v2.12.0

func (*ChatMessageStartEventDeltaMessage) UnmarshalJSON added in v2.12.0

func (c *ChatMessageStartEventDeltaMessage) UnmarshalJSON(data []byte) error

type ChatMessageV2 added in v2.12.0

type ChatMessageV2 struct {
	Role      string
	User      *UserMessage
	Assistant *AssistantMessage
	System    *SystemMessage
	Tool      *ToolMessageV2
}

Represents a single message in the chat history from a given role.

func (*ChatMessageV2) Accept added in v2.12.0

func (c *ChatMessageV2) Accept(visitor ChatMessageV2Visitor) error

func (*ChatMessageV2) GetAssistant added in v2.12.4

func (c *ChatMessageV2) GetAssistant() *AssistantMessage

func (*ChatMessageV2) GetRole added in v2.12.4

func (c *ChatMessageV2) GetRole() string

func (*ChatMessageV2) GetSystem added in v2.12.4

func (c *ChatMessageV2) GetSystem() *SystemMessage

func (*ChatMessageV2) GetTool added in v2.12.4

func (c *ChatMessageV2) GetTool() *ToolMessageV2

func (*ChatMessageV2) GetUser added in v2.12.4

func (c *ChatMessageV2) GetUser() *UserMessage

func (ChatMessageV2) MarshalJSON added in v2.12.0

func (c ChatMessageV2) MarshalJSON() ([]byte, error)

func (*ChatMessageV2) UnmarshalJSON added in v2.12.0

func (c *ChatMessageV2) UnmarshalJSON(data []byte) error

type ChatMessageV2Visitor added in v2.12.0

type ChatMessageV2Visitor interface {
	VisitUser(*UserMessage) error
	VisitAssistant(*AssistantMessage) error
	VisitSystem(*SystemMessage) error
	VisitTool(*ToolMessageV2) error
}

type ChatMessages added in v2.12.0

type ChatMessages = []*ChatMessageV2

A list of chat messages in chronological order, representing a conversation between the user and the model.

Messages can be from `User`, `Assistant`, `Tool` and `System` roles. Learn more about messages and roles in [the Chat API guide](https://docs.cohere.com/v2/docs/chat-api).

type ChatRequest

type ChatRequest struct {
	// Pass text/event-stream to receive the streamed response as server-sent events. The default is `\n` delimited events.
	Accepts *string `json:"-" url:"-"`
	// Text input for the model to respond to.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Message string `json:"message" url:"-"`
	// Defaults to `command-r-plus-08-2024`.
	//
	// The name of a compatible [Cohere model](https://docs.cohere.com/docs/models) or the ID of a [fine-tuned](https://docs.cohere.com/docs/chat-fine-tuning) model.
	//
	// Compatible Deployments: Cohere Platform, Private Deployments
	Model *string `json:"model,omitempty" url:"-"`
	// Defaults to `false`.
	//
	// When `true`, the response will be a JSON stream of events. The final event will contain the complete response, and will have an `event_type` of `"stream-end"`.
	//
	// Streaming is beneficial for user interfaces that render the contents of the response piece by piece, as it gets generated.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	//
	// When specified, the default Cohere preamble will be replaced with the provided one. Preambles are a part of the prompt used to adjust the model's overall behavior and conversation style, and use the `SYSTEM` role.
	//
	// The `SYSTEM` role is also used for the contents of the optional `chat_history=` parameter. When used with the `chat_history=` parameter it adds content throughout a conversation. Conversely, when used with the `preamble=` parameter it adds content at the start of the conversation only.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Preamble *string `json:"preamble,omitempty" url:"-"`
	// A list of previous messages between the user and the model, giving the model conversational context for responding to the user's `message`.
	//
	// Each item represents a single message in the chat history, excluding the current user turn. It has two properties: `role` and `message`. The `role` identifies the sender (`CHATBOT`, `SYSTEM`, or `USER`), while the `message` contains the text content.
	//
	// The chat_history parameter should not be used for `SYSTEM` messages in most cases. Instead, to add a `SYSTEM` role message at the beginning of a conversation, the `preamble` parameter should be used.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	ChatHistory []*Message `json:"chat_history,omitempty" url:"-"`
	// An alternative to `chat_history`.
	//
	// Providing a `conversation_id` creates or resumes a persisted conversation with the specified ID. The ID can be any non empty string.
	//
	// Compatible Deployments: Cohere Platform
	ConversationId *string `json:"conversation_id,omitempty" url:"-"`
	// Defaults to `AUTO` when `connectors` are specified and `OFF` in all other cases.
	//
	// Dictates how the prompt will be constructed.
	//
	// With `prompt_truncation` set to "AUTO", some elements from `chat_history` and `documents` will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be changed and ranked by relevance.
	//
	// With `prompt_truncation` set to "AUTO_PRESERVE_ORDER", some elements from `chat_history` and `documents` will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be preserved as they are inputted into the API.
	//
	// With `prompt_truncation` set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a `TooManyTokens` error will be returned.
	//
	// Compatible Deployments:
	//   - AUTO: Cohere Platform Only
	//   - AUTO_PRESERVE_ORDER: Azure, AWS Sagemaker/Bedrock, Private Deployments
	PromptTruncation *ChatRequestPromptTruncation `json:"prompt_truncation,omitempty" url:"-"`
	// Accepts `{"id": "web-search"}`, and/or the `"id"` for a custom [connector](https://docs.cohere.com/docs/connectors), if you've [created](https://docs.cohere.com/v1/docs/creating-and-deploying-a-connector) one.
	//
	// When specified, the model's reply will be enriched with information found by querying each of the connectors (RAG).
	//
	// Compatible Deployments: Cohere Platform
	Connectors []*ChatConnector `json:"connectors,omitempty" url:"-"`
	// Defaults to `false`.
	//
	// When `true`, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's `message` will be generated.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	SearchQueriesOnly *bool `json:"search_queries_only,omitempty" url:"-"`
	// A list of relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary.
	//
	// Example:
	// “`
	// [
	//
	//	{ "title": "Tall penguins", "text": "Emperor penguins are the tallest." },
	//	{ "title": "Penguin habitats", "text": "Emperor penguins only live in Antarctica." },
	//
	// ]
	// “`
	//
	// Keys and values from each document will be serialized to a string and passed to the model. The resulting generation will include citations that reference some of these documents.
	//
	// Some suggested keys are "text", "author", and "date". For better generation quality, it is recommended to keep the total word count of the strings in the dictionary to under 300 words.
	//
	// An `id` field (string) can be optionally supplied to identify the document in the citations. This field will not be passed to the model.
	//
	// An `_excludes` field (array of strings) can be optionally supplied to omit some key-value pairs from being shown to the model. The omitted fields will still show up in the citation object. The "_excludes" field will not be passed to the model.
	//
	// See ['Document Mode'](https://docs.cohere.com/docs/retrieval-augmented-generation-rag#document-mode) in the guide for more information.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Documents []ChatDocument `json:"documents,omitempty" url:"-"`
	// Defaults to `"accurate"`.
	//
	// Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want `"accurate"` results, `"fast"` results or no results.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	CitationQuality *ChatRequestCitationQuality `json:"citation_quality,omitempty" url:"-"`
	// Defaults to `0.3`.
	//
	// A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations.
	//
	// Randomness can be further maximized by increasing the  value of the `p` parameter.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Temperature *float64 `json:"temperature,omitempty" url:"-"`
	// The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	MaxTokens *int `json:"max_tokens,omitempty" url:"-"`
	// The maximum number of input tokens to send to the model. If not specified, `max_input_tokens` is the model's context length limit minus a small buffer.
	//
	// Input will be truncated according to the `prompt_truncation` parameter.
	//
	// Compatible Deployments: Cohere Platform
	MaxInputTokens *int `json:"max_input_tokens,omitempty" url:"-"`
	// Ensures only the top `k` most likely tokens are considered for generation at each step.
	// Defaults to `0`, min value of `0`, max value of `500`.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	K *int `json:"k,omitempty" url:"-"`
	// Ensures that only the most likely tokens, with total probability mass of `p`, are considered for generation at each step. If both `k` and `p` are enabled, `p` acts after `k`.
	// Defaults to `0.75`. min value of `0.01`, max value of `0.99`.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	P *float64 `json:"p,omitempty" url:"-"`
	// If specified, the backend will make a best effort to sample tokens
	// deterministically, such that repeated requests with the same
	// seed and parameters should return the same result. However,
	// determinism cannot be totally guaranteed.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Seed *int `json:"seed,omitempty" url:"-"`
	// A list of up to 5 strings that the model will use to stop generation. If the model generates a string that matches any of the strings in the list, it will stop generating tokens and return the generated text up to that point not including the stop sequence.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	StopSequences []string `json:"stop_sequences,omitempty" url:"-"`
	// Defaults to `0.0`, min value of `0.0`, max value of `1.0`.
	//
	// Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	FrequencyPenalty *float64 `json:"frequency_penalty,omitempty" url:"-"`
	// Defaults to `0.0`, min value of `0.0`, max value of `1.0`.
	//
	// Used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	PresencePenalty *float64 `json:"presence_penalty,omitempty" url:"-"`
	// When enabled, the user's prompt will be sent to the model without
	// any pre-processing.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	RawPrompting *bool `json:"raw_prompting,omitempty" url:"-"`
	// The prompt is returned in the `prompt` response field when this is enabled.
	ReturnPrompt *bool `json:"return_prompt,omitempty" url:"-"`
	// A list of available tools (functions) that the model may suggest invoking before producing a text response.
	//
	// When `tools` is passed (without `tool_results`), the `text` field in the response will be `""` and the `tool_calls` field in the response will be populated with a list of tool calls that need to be made. If no calls need to be made, the `tool_calls` array will be empty.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Tools []*Tool `json:"tools,omitempty" url:"-"`
	// A list of results from invoking tools recommended by the model in the previous chat turn. Results are used to produce a text response and will be referenced in citations. When using `tool_results`, `tools` must be passed as well.
	// Each tool_result contains information about how it was invoked, as well as a list of outputs in the form of dictionaries.
	//
	// **Note**: `outputs` must be a list of objects. If your tool returns a single object (eg `{"status": 200}`), make sure to wrap it in a list.
	// “`
	// tool_results = [
	//
	//	{
	//	  "call": {
	//	    "name": <tool name>,
	//	    "parameters": {
	//	      <param name>: <param value>
	//	    }
	//	  },
	//	  "outputs": [{
	//	    <key>: <value>
	//	  }]
	//	},
	//	...
	//
	// ]
	// “`
	// **Note**: Chat calls with `tool_results` should not be included in the Chat history to avoid duplication of the message text.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	ToolResults []*ToolResult `json:"tool_results,omitempty" url:"-"`
	// Forces the chat to be single step. Defaults to `false`.
	ForceSingleStep *bool           `json:"force_single_step,omitempty" url:"-"`
	ResponseFormat  *ResponseFormat `json:"response_format,omitempty" url:"-"`
	// Used to select the [safety instruction](https://docs.cohere.com/docs/safety-modes) inserted into the prompt. Defaults to `CONTEXTUAL`.
	// When `NONE` is specified, the safety instruction will be omitted.
	//
	// Safety modes are not yet configurable in combination with `tools`, `tool_results` and `documents` parameters.
	//
	// **Note**: This parameter is only compatible with models [Command R 08-2024](https://docs.cohere.com/docs/command-r#august-2024-release), [Command R+ 08-2024](https://docs.cohere.com/docs/command-r-plus#august-2024-release) and newer.
	//
	// **Note**: `command-r7b-12-2024` only supports `"CONTEXTUAL"` and `"STRICT"` modes.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	SafetyMode *ChatRequestSafetyMode `json:"safety_mode,omitempty" url:"-"`
	// contains filtered or unexported fields
}

func (*ChatRequest) MarshalJSON

func (c *ChatRequest) MarshalJSON() ([]byte, error)

func (*ChatRequest) Stream

func (c *ChatRequest) Stream() bool

func (*ChatRequest) UnmarshalJSON

func (c *ChatRequest) UnmarshalJSON(data []byte) error

type ChatRequestCitationQuality

type ChatRequestCitationQuality string

Defaults to `"accurate"`.

Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want `"accurate"` results, `"fast"` results or no results.

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

const (
	ChatRequestCitationQualityFast     ChatRequestCitationQuality = "fast"
	ChatRequestCitationQualityAccurate ChatRequestCitationQuality = "accurate"
	ChatRequestCitationQualityOff      ChatRequestCitationQuality = "off"
)

func NewChatRequestCitationQualityFromString

func NewChatRequestCitationQualityFromString(s string) (ChatRequestCitationQuality, error)

func (ChatRequestCitationQuality) Ptr

type ChatRequestConnectorsSearchOptions added in v2.6.0

type ChatRequestConnectorsSearchOptions struct {
	// If specified, the backend will make a best effort to sample tokens
	// deterministically, such that repeated requests with the same
	// seed and parameters should return the same result. However,
	// determinism cannot be totally guaranteed.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Seed *int `json:"seed,omitempty" url:"seed,omitempty"`
	// contains filtered or unexported fields
}

(internal) Sets inference and model options for RAG search query and tool use generations. Defaults are used when options are not specified here, meaning that other parameters outside of connectors_search_options are ignored (such as model= or temperature=).

func (*ChatRequestConnectorsSearchOptions) GetExtraProperties added in v2.8.2

func (c *ChatRequestConnectorsSearchOptions) GetExtraProperties() map[string]interface{}

func (*ChatRequestConnectorsSearchOptions) GetSeed added in v2.12.4

func (*ChatRequestConnectorsSearchOptions) String added in v2.6.0

func (*ChatRequestConnectorsSearchOptions) UnmarshalJSON added in v2.6.0

func (c *ChatRequestConnectorsSearchOptions) UnmarshalJSON(data []byte) error

type ChatRequestPromptTruncation

type ChatRequestPromptTruncation string

Defaults to `AUTO` when `connectors` are specified and `OFF` in all other cases.

Dictates how the prompt will be constructed.

With `prompt_truncation` set to "AUTO", some elements from `chat_history` and `documents` will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be changed and ranked by relevance.

With `prompt_truncation` set to "AUTO_PRESERVE_ORDER", some elements from `chat_history` and `documents` will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be preserved as they are inputted into the API.

With `prompt_truncation` set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a `TooManyTokens` error will be returned.

Compatible Deployments:

  • AUTO: Cohere Platform Only
  • AUTO_PRESERVE_ORDER: Azure, AWS Sagemaker/Bedrock, Private Deployments
const (
	ChatRequestPromptTruncationOff               ChatRequestPromptTruncation = "OFF"
	ChatRequestPromptTruncationAuto              ChatRequestPromptTruncation = "AUTO"
	ChatRequestPromptTruncationAutoPreserveOrder ChatRequestPromptTruncation = "AUTO_PRESERVE_ORDER"
)

func NewChatRequestPromptTruncationFromString

func NewChatRequestPromptTruncationFromString(s string) (ChatRequestPromptTruncation, error)

func (ChatRequestPromptTruncation) Ptr

type ChatRequestSafetyMode added in v2.11.0

type ChatRequestSafetyMode string

Used to select the [safety instruction](https://docs.cohere.com/docs/safety-modes) inserted into the prompt. Defaults to `CONTEXTUAL`. When `NONE` is specified, the safety instruction will be omitted.

Safety modes are not yet configurable in combination with `tools`, `tool_results` and `documents` parameters.

**Note**: This parameter is only compatible with models [Command R 08-2024](https://docs.cohere.com/docs/command-r#august-2024-release), [Command R+ 08-2024](https://docs.cohere.com/docs/command-r-plus#august-2024-release) and newer.

**Note**: `command-r7b-12-2024` only supports `"CONTEXTUAL"` and `"STRICT"` modes.

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

const (
	ChatRequestSafetyModeContextual ChatRequestSafetyMode = "CONTEXTUAL"
	ChatRequestSafetyModeStrict     ChatRequestSafetyMode = "STRICT"
	ChatRequestSafetyModeNone       ChatRequestSafetyMode = "NONE"
)

func NewChatRequestSafetyModeFromString added in v2.11.0

func NewChatRequestSafetyModeFromString(s string) (ChatRequestSafetyMode, error)

func (ChatRequestSafetyMode) Ptr added in v2.11.0

type ChatResponse added in v2.12.0

type ChatResponse struct {
	// Unique identifier for the generated reply. Useful for submitting feedback.
	Id           string           `json:"id" url:"id"`
	FinishReason ChatFinishReason `json:"finish_reason" url:"finish_reason"`
	// The prompt that was used. Only present when `return_prompt` in the request is set to true.
	Prompt   *string                   `json:"prompt,omitempty" url:"prompt,omitempty"`
	Message  *AssistantMessageResponse `json:"message,omitempty" url:"message,omitempty"`
	Usage    *Usage                    `json:"usage,omitempty" url:"usage,omitempty"`
	Logprobs []*LogprobItem            `json:"logprobs,omitempty" url:"logprobs,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatResponse) GetExtraProperties added in v2.12.0

func (c *ChatResponse) GetExtraProperties() map[string]interface{}

func (*ChatResponse) GetFinishReason added in v2.12.4

func (c *ChatResponse) GetFinishReason() ChatFinishReason

func (*ChatResponse) GetId added in v2.12.4

func (c *ChatResponse) GetId() string

func (*ChatResponse) GetLogprobs added in v2.12.4

func (c *ChatResponse) GetLogprobs() []*LogprobItem

func (*ChatResponse) GetMessage added in v2.12.4

func (c *ChatResponse) GetMessage() *AssistantMessageResponse

func (*ChatResponse) GetPrompt added in v2.12.4

func (c *ChatResponse) GetPrompt() *string

func (*ChatResponse) GetUsage added in v2.12.4

func (c *ChatResponse) GetUsage() *Usage

func (*ChatResponse) String added in v2.12.0

func (c *ChatResponse) String() string

func (*ChatResponse) UnmarshalJSON added in v2.12.0

func (c *ChatResponse) UnmarshalJSON(data []byte) error

type ChatSearchQueriesGenerationEvent

type ChatSearchQueriesGenerationEvent struct {
	// Generated search queries, meant to be used as part of the RAG flow.
	SearchQueries []*ChatSearchQuery `json:"search_queries,omitempty" url:"search_queries,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatSearchQueriesGenerationEvent) GetExtraProperties added in v2.8.2

func (c *ChatSearchQueriesGenerationEvent) GetExtraProperties() map[string]interface{}

func (*ChatSearchQueriesGenerationEvent) GetSearchQueries added in v2.12.4

func (c *ChatSearchQueriesGenerationEvent) GetSearchQueries() []*ChatSearchQuery

func (*ChatSearchQueriesGenerationEvent) String

func (*ChatSearchQueriesGenerationEvent) UnmarshalJSON

func (c *ChatSearchQueriesGenerationEvent) UnmarshalJSON(data []byte) error

type ChatSearchQuery

type ChatSearchQuery struct {
	// The text of the search query.
	Text string `json:"text" url:"text"`
	// Unique identifier for the generated search query. Useful for submitting feedback.
	GenerationId string `json:"generation_id" url:"generation_id"`
	// contains filtered or unexported fields
}

The generated search query. Contains the text of the query and a unique identifier for the query.

func (*ChatSearchQuery) GetExtraProperties added in v2.8.2

func (c *ChatSearchQuery) GetExtraProperties() map[string]interface{}

func (*ChatSearchQuery) GetGenerationId added in v2.12.4

func (c *ChatSearchQuery) GetGenerationId() string

func (*ChatSearchQuery) GetText added in v2.12.4

func (c *ChatSearchQuery) GetText() string

func (*ChatSearchQuery) String

func (c *ChatSearchQuery) String() string

func (*ChatSearchQuery) UnmarshalJSON

func (c *ChatSearchQuery) UnmarshalJSON(data []byte) error

type ChatSearchResult

type ChatSearchResult struct {
	SearchQuery *ChatSearchQuery `json:"search_query,omitempty" url:"search_query,omitempty"`
	// The connector from which this result comes from.
	Connector *ChatSearchResultConnector `json:"connector,omitempty" url:"connector,omitempty"`
	// Identifiers of documents found by this search query.
	DocumentIds []string `json:"document_ids,omitempty" url:"document_ids,omitempty"`
	// An error message if the search failed.
	ErrorMessage *string `json:"error_message,omitempty" url:"error_message,omitempty"`
	// Whether a chat request should continue or not if the request to this connector fails.
	ContinueOnFailure *bool `json:"continue_on_failure,omitempty" url:"continue_on_failure,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatSearchResult) GetConnector added in v2.12.4

func (c *ChatSearchResult) GetConnector() *ChatSearchResultConnector

func (*ChatSearchResult) GetContinueOnFailure added in v2.12.4

func (c *ChatSearchResult) GetContinueOnFailure() *bool

func (*ChatSearchResult) GetDocumentIds added in v2.12.4

func (c *ChatSearchResult) GetDocumentIds() []string

func (*ChatSearchResult) GetErrorMessage added in v2.12.4

func (c *ChatSearchResult) GetErrorMessage() *string

func (*ChatSearchResult) GetExtraProperties added in v2.8.2

func (c *ChatSearchResult) GetExtraProperties() map[string]interface{}

func (*ChatSearchResult) GetSearchQuery added in v2.12.4

func (c *ChatSearchResult) GetSearchQuery() *ChatSearchQuery

func (*ChatSearchResult) String

func (c *ChatSearchResult) String() string

func (*ChatSearchResult) UnmarshalJSON

func (c *ChatSearchResult) UnmarshalJSON(data []byte) error

type ChatSearchResultConnector added in v2.5.2

type ChatSearchResultConnector struct {
	// The identifier of the connector.
	Id string `json:"id" url:"id"`
	// contains filtered or unexported fields
}

The connector used for fetching documents.

func (*ChatSearchResultConnector) GetExtraProperties added in v2.8.2

func (c *ChatSearchResultConnector) GetExtraProperties() map[string]interface{}

func (*ChatSearchResultConnector) GetId added in v2.12.4

func (c *ChatSearchResultConnector) GetId() string

func (*ChatSearchResultConnector) String added in v2.5.2

func (c *ChatSearchResultConnector) String() string

func (*ChatSearchResultConnector) UnmarshalJSON added in v2.5.2

func (c *ChatSearchResultConnector) UnmarshalJSON(data []byte) error

type ChatSearchResultsEvent

type ChatSearchResultsEvent struct {
	// Conducted searches and the ids of documents retrieved from each of them.
	SearchResults []*ChatSearchResult `json:"search_results,omitempty" url:"search_results,omitempty"`
	// Documents fetched from searches or provided by the user.
	Documents []ChatDocument `json:"documents,omitempty" url:"documents,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatSearchResultsEvent) GetDocuments added in v2.12.4

func (c *ChatSearchResultsEvent) GetDocuments() []ChatDocument

func (*ChatSearchResultsEvent) GetExtraProperties added in v2.8.2

func (c *ChatSearchResultsEvent) GetExtraProperties() map[string]interface{}

func (*ChatSearchResultsEvent) GetSearchResults added in v2.12.4

func (c *ChatSearchResultsEvent) GetSearchResults() []*ChatSearchResult

func (*ChatSearchResultsEvent) String

func (c *ChatSearchResultsEvent) String() string

func (*ChatSearchResultsEvent) UnmarshalJSON

func (c *ChatSearchResultsEvent) UnmarshalJSON(data []byte) error

type ChatStreamEndEvent

type ChatStreamEndEvent struct {
	// - `COMPLETE` - the model sent back a finished reply
	// - `ERROR_LIMIT` - the reply was cut off because the model reached the maximum number of tokens for its context length
	// - `MAX_TOKENS` - the reply was cut off because the model reached the maximum number of tokens specified by the max_tokens parameter
	// - `ERROR` - something went wrong when generating the reply
	// - `ERROR_TOXIC` - the model generated a reply that was deemed toxic
	FinishReason ChatStreamEndEventFinishReason `json:"finish_reason" url:"finish_reason"`
	// The consolidated response from the model. Contains the generated reply and all the other information streamed back in the previous events.
	Response *NonStreamedChatResponse `json:"response,omitempty" url:"response,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatStreamEndEvent) GetExtraProperties added in v2.8.2

func (c *ChatStreamEndEvent) GetExtraProperties() map[string]interface{}

func (*ChatStreamEndEvent) GetFinishReason added in v2.12.4

func (*ChatStreamEndEvent) GetResponse added in v2.12.4

func (c *ChatStreamEndEvent) GetResponse() *NonStreamedChatResponse

func (*ChatStreamEndEvent) String

func (c *ChatStreamEndEvent) String() string

func (*ChatStreamEndEvent) UnmarshalJSON

func (c *ChatStreamEndEvent) UnmarshalJSON(data []byte) error

type ChatStreamEndEventFinishReason

type ChatStreamEndEventFinishReason string

- `COMPLETE` - the model sent back a finished reply - `ERROR_LIMIT` - the reply was cut off because the model reached the maximum number of tokens for its context length - `MAX_TOKENS` - the reply was cut off because the model reached the maximum number of tokens specified by the max_tokens parameter - `ERROR` - something went wrong when generating the reply - `ERROR_TOXIC` - the model generated a reply that was deemed toxic

const (
	ChatStreamEndEventFinishReasonComplete   ChatStreamEndEventFinishReason = "COMPLETE"
	ChatStreamEndEventFinishReasonErrorLimit ChatStreamEndEventFinishReason = "ERROR_LIMIT"
	ChatStreamEndEventFinishReasonMaxTokens  ChatStreamEndEventFinishReason = "MAX_TOKENS"
	ChatStreamEndEventFinishReasonError      ChatStreamEndEventFinishReason = "ERROR"
	ChatStreamEndEventFinishReasonErrorToxic ChatStreamEndEventFinishReason = "ERROR_TOXIC"
)

func NewChatStreamEndEventFinishReasonFromString

func NewChatStreamEndEventFinishReasonFromString(s string) (ChatStreamEndEventFinishReason, error)

func (ChatStreamEndEventFinishReason) Ptr

type ChatStreamEvent

type ChatStreamEvent struct {
	// contains filtered or unexported fields
}

func (*ChatStreamEvent) GetExtraProperties added in v2.8.2

func (c *ChatStreamEvent) GetExtraProperties() map[string]interface{}

func (*ChatStreamEvent) String

func (c *ChatStreamEvent) String() string

func (*ChatStreamEvent) UnmarshalJSON

func (c *ChatStreamEvent) UnmarshalJSON(data []byte) error

type ChatStreamEventType added in v2.12.0

type ChatStreamEventType struct {
	// contains filtered or unexported fields
}

The streamed event types

func (*ChatStreamEventType) GetExtraProperties added in v2.12.0

func (c *ChatStreamEventType) GetExtraProperties() map[string]interface{}

func (*ChatStreamEventType) String added in v2.12.0

func (c *ChatStreamEventType) String() string

func (*ChatStreamEventType) UnmarshalJSON added in v2.12.0

func (c *ChatStreamEventType) UnmarshalJSON(data []byte) error

type ChatStreamRequest

type ChatStreamRequest struct {
	// Pass text/event-stream to receive the streamed response as server-sent events. The default is `\n` delimited events.
	Accepts *string `json:"-" url:"-"`
	// Text input for the model to respond to.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Message string `json:"message" url:"-"`
	// Defaults to `command-r-plus-08-2024`.
	//
	// The name of a compatible [Cohere model](https://docs.cohere.com/docs/models) or the ID of a [fine-tuned](https://docs.cohere.com/docs/chat-fine-tuning) model.
	//
	// Compatible Deployments: Cohere Platform, Private Deployments
	Model *string `json:"model,omitempty" url:"-"`
	// Defaults to `false`.
	//
	// When `true`, the response will be a JSON stream of events. The final event will contain the complete response, and will have an `event_type` of `"stream-end"`.
	//
	// Streaming is beneficial for user interfaces that render the contents of the response piece by piece, as it gets generated.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	//
	// When specified, the default Cohere preamble will be replaced with the provided one. Preambles are a part of the prompt used to adjust the model's overall behavior and conversation style, and use the `SYSTEM` role.
	//
	// The `SYSTEM` role is also used for the contents of the optional `chat_history=` parameter. When used with the `chat_history=` parameter it adds content throughout a conversation. Conversely, when used with the `preamble=` parameter it adds content at the start of the conversation only.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Preamble *string `json:"preamble,omitempty" url:"-"`
	// A list of previous messages between the user and the model, giving the model conversational context for responding to the user's `message`.
	//
	// Each item represents a single message in the chat history, excluding the current user turn. It has two properties: `role` and `message`. The `role` identifies the sender (`CHATBOT`, `SYSTEM`, or `USER`), while the `message` contains the text content.
	//
	// The chat_history parameter should not be used for `SYSTEM` messages in most cases. Instead, to add a `SYSTEM` role message at the beginning of a conversation, the `preamble` parameter should be used.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	ChatHistory []*Message `json:"chat_history,omitempty" url:"-"`
	// An alternative to `chat_history`.
	//
	// Providing a `conversation_id` creates or resumes a persisted conversation with the specified ID. The ID can be any non empty string.
	//
	// Compatible Deployments: Cohere Platform
	ConversationId *string `json:"conversation_id,omitempty" url:"-"`
	// Defaults to `AUTO` when `connectors` are specified and `OFF` in all other cases.
	//
	// Dictates how the prompt will be constructed.
	//
	// With `prompt_truncation` set to "AUTO", some elements from `chat_history` and `documents` will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be changed and ranked by relevance.
	//
	// With `prompt_truncation` set to "AUTO_PRESERVE_ORDER", some elements from `chat_history` and `documents` will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be preserved as they are inputted into the API.
	//
	// With `prompt_truncation` set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a `TooManyTokens` error will be returned.
	//
	// Compatible Deployments:
	//   - AUTO: Cohere Platform Only
	//   - AUTO_PRESERVE_ORDER: Azure, AWS Sagemaker/Bedrock, Private Deployments
	PromptTruncation *ChatStreamRequestPromptTruncation `json:"prompt_truncation,omitempty" url:"-"`
	// Accepts `{"id": "web-search"}`, and/or the `"id"` for a custom [connector](https://docs.cohere.com/docs/connectors), if you've [created](https://docs.cohere.com/v1/docs/creating-and-deploying-a-connector) one.
	//
	// When specified, the model's reply will be enriched with information found by querying each of the connectors (RAG).
	//
	// Compatible Deployments: Cohere Platform
	Connectors []*ChatConnector `json:"connectors,omitempty" url:"-"`
	// Defaults to `false`.
	//
	// When `true`, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's `message` will be generated.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	SearchQueriesOnly *bool `json:"search_queries_only,omitempty" url:"-"`
	// A list of relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary.
	//
	// Example:
	// “`
	// [
	//
	//	{ "title": "Tall penguins", "text": "Emperor penguins are the tallest." },
	//	{ "title": "Penguin habitats", "text": "Emperor penguins only live in Antarctica." },
	//
	// ]
	// “`
	//
	// Keys and values from each document will be serialized to a string and passed to the model. The resulting generation will include citations that reference some of these documents.
	//
	// Some suggested keys are "text", "author", and "date". For better generation quality, it is recommended to keep the total word count of the strings in the dictionary to under 300 words.
	//
	// An `id` field (string) can be optionally supplied to identify the document in the citations. This field will not be passed to the model.
	//
	// An `_excludes` field (array of strings) can be optionally supplied to omit some key-value pairs from being shown to the model. The omitted fields will still show up in the citation object. The "_excludes" field will not be passed to the model.
	//
	// See ['Document Mode'](https://docs.cohere.com/docs/retrieval-augmented-generation-rag#document-mode) in the guide for more information.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Documents []ChatDocument `json:"documents,omitempty" url:"-"`
	// Defaults to `"accurate"`.
	//
	// Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want `"accurate"` results, `"fast"` results or no results.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	CitationQuality *ChatStreamRequestCitationQuality `json:"citation_quality,omitempty" url:"-"`
	// Defaults to `0.3`.
	//
	// A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations.
	//
	// Randomness can be further maximized by increasing the  value of the `p` parameter.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Temperature *float64 `json:"temperature,omitempty" url:"-"`
	// The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	MaxTokens *int `json:"max_tokens,omitempty" url:"-"`
	// The maximum number of input tokens to send to the model. If not specified, `max_input_tokens` is the model's context length limit minus a small buffer.
	//
	// Input will be truncated according to the `prompt_truncation` parameter.
	//
	// Compatible Deployments: Cohere Platform
	MaxInputTokens *int `json:"max_input_tokens,omitempty" url:"-"`
	// Ensures only the top `k` most likely tokens are considered for generation at each step.
	// Defaults to `0`, min value of `0`, max value of `500`.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	K *int `json:"k,omitempty" url:"-"`
	// Ensures that only the most likely tokens, with total probability mass of `p`, are considered for generation at each step. If both `k` and `p` are enabled, `p` acts after `k`.
	// Defaults to `0.75`. min value of `0.01`, max value of `0.99`.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	P *float64 `json:"p,omitempty" url:"-"`
	// If specified, the backend will make a best effort to sample tokens
	// deterministically, such that repeated requests with the same
	// seed and parameters should return the same result. However,
	// determinism cannot be totally guaranteed.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Seed *int `json:"seed,omitempty" url:"-"`
	// A list of up to 5 strings that the model will use to stop generation. If the model generates a string that matches any of the strings in the list, it will stop generating tokens and return the generated text up to that point not including the stop sequence.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	StopSequences []string `json:"stop_sequences,omitempty" url:"-"`
	// Defaults to `0.0`, min value of `0.0`, max value of `1.0`.
	//
	// Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	FrequencyPenalty *float64 `json:"frequency_penalty,omitempty" url:"-"`
	// Defaults to `0.0`, min value of `0.0`, max value of `1.0`.
	//
	// Used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	PresencePenalty *float64 `json:"presence_penalty,omitempty" url:"-"`
	// When enabled, the user's prompt will be sent to the model without
	// any pre-processing.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	RawPrompting *bool `json:"raw_prompting,omitempty" url:"-"`
	// The prompt is returned in the `prompt` response field when this is enabled.
	ReturnPrompt *bool `json:"return_prompt,omitempty" url:"-"`
	// A list of available tools (functions) that the model may suggest invoking before producing a text response.
	//
	// When `tools` is passed (without `tool_results`), the `text` field in the response will be `""` and the `tool_calls` field in the response will be populated with a list of tool calls that need to be made. If no calls need to be made, the `tool_calls` array will be empty.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Tools []*Tool `json:"tools,omitempty" url:"-"`
	// A list of results from invoking tools recommended by the model in the previous chat turn. Results are used to produce a text response and will be referenced in citations. When using `tool_results`, `tools` must be passed as well.
	// Each tool_result contains information about how it was invoked, as well as a list of outputs in the form of dictionaries.
	//
	// **Note**: `outputs` must be a list of objects. If your tool returns a single object (eg `{"status": 200}`), make sure to wrap it in a list.
	// “`
	// tool_results = [
	//
	//	{
	//	  "call": {
	//	    "name": <tool name>,
	//	    "parameters": {
	//	      <param name>: <param value>
	//	    }
	//	  },
	//	  "outputs": [{
	//	    <key>: <value>
	//	  }]
	//	},
	//	...
	//
	// ]
	// “`
	// **Note**: Chat calls with `tool_results` should not be included in the Chat history to avoid duplication of the message text.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	ToolResults []*ToolResult `json:"tool_results,omitempty" url:"-"`
	// Forces the chat to be single step. Defaults to `false`.
	ForceSingleStep *bool           `json:"force_single_step,omitempty" url:"-"`
	ResponseFormat  *ResponseFormat `json:"response_format,omitempty" url:"-"`
	// Used to select the [safety instruction](https://docs.cohere.com/docs/safety-modes) inserted into the prompt. Defaults to `CONTEXTUAL`.
	// When `NONE` is specified, the safety instruction will be omitted.
	//
	// Safety modes are not yet configurable in combination with `tools`, `tool_results` and `documents` parameters.
	//
	// **Note**: This parameter is only compatible with models [Command R 08-2024](https://docs.cohere.com/docs/command-r#august-2024-release), [Command R+ 08-2024](https://docs.cohere.com/docs/command-r-plus#august-2024-release) and newer.
	//
	// **Note**: `command-r7b-12-2024` only supports `"CONTEXTUAL"` and `"STRICT"` modes.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	SafetyMode *ChatStreamRequestSafetyMode `json:"safety_mode,omitempty" url:"-"`
	// contains filtered or unexported fields
}

func (*ChatStreamRequest) MarshalJSON

func (c *ChatStreamRequest) MarshalJSON() ([]byte, error)

func (*ChatStreamRequest) Stream

func (c *ChatStreamRequest) Stream() bool

func (*ChatStreamRequest) UnmarshalJSON

func (c *ChatStreamRequest) UnmarshalJSON(data []byte) error

type ChatStreamRequestCitationQuality

type ChatStreamRequestCitationQuality string

Defaults to `"accurate"`.

Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want `"accurate"` results, `"fast"` results or no results.

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

const (
	ChatStreamRequestCitationQualityFast     ChatStreamRequestCitationQuality = "fast"
	ChatStreamRequestCitationQualityAccurate ChatStreamRequestCitationQuality = "accurate"
	ChatStreamRequestCitationQualityOff      ChatStreamRequestCitationQuality = "off"
)

func NewChatStreamRequestCitationQualityFromString

func NewChatStreamRequestCitationQualityFromString(s string) (ChatStreamRequestCitationQuality, error)

func (ChatStreamRequestCitationQuality) Ptr

type ChatStreamRequestConnectorsSearchOptions added in v2.6.0

type ChatStreamRequestConnectorsSearchOptions struct {
	// If specified, the backend will make a best effort to sample tokens
	// deterministically, such that repeated requests with the same
	// seed and parameters should return the same result. However,
	// determinism cannot be totally guaranteed.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Seed *int `json:"seed,omitempty" url:"seed,omitempty"`
	// contains filtered or unexported fields
}

(internal) Sets inference and model options for RAG search query and tool use generations. Defaults are used when options are not specified here, meaning that other parameters outside of connectors_search_options are ignored (such as model= or temperature=).

func (*ChatStreamRequestConnectorsSearchOptions) GetExtraProperties added in v2.8.2

func (c *ChatStreamRequestConnectorsSearchOptions) GetExtraProperties() map[string]interface{}

func (*ChatStreamRequestConnectorsSearchOptions) GetSeed added in v2.12.4

func (*ChatStreamRequestConnectorsSearchOptions) String added in v2.6.0

func (*ChatStreamRequestConnectorsSearchOptions) UnmarshalJSON added in v2.6.0

func (c *ChatStreamRequestConnectorsSearchOptions) UnmarshalJSON(data []byte) error

type ChatStreamRequestPromptTruncation

type ChatStreamRequestPromptTruncation string

Defaults to `AUTO` when `connectors` are specified and `OFF` in all other cases.

Dictates how the prompt will be constructed.

With `prompt_truncation` set to "AUTO", some elements from `chat_history` and `documents` will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be changed and ranked by relevance.

With `prompt_truncation` set to "AUTO_PRESERVE_ORDER", some elements from `chat_history` and `documents` will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be preserved as they are inputted into the API.

With `prompt_truncation` set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a `TooManyTokens` error will be returned.

Compatible Deployments:

  • AUTO: Cohere Platform Only
  • AUTO_PRESERVE_ORDER: Azure, AWS Sagemaker/Bedrock, Private Deployments
const (
	ChatStreamRequestPromptTruncationOff               ChatStreamRequestPromptTruncation = "OFF"
	ChatStreamRequestPromptTruncationAuto              ChatStreamRequestPromptTruncation = "AUTO"
	ChatStreamRequestPromptTruncationAutoPreserveOrder ChatStreamRequestPromptTruncation = "AUTO_PRESERVE_ORDER"
)

func NewChatStreamRequestPromptTruncationFromString

func NewChatStreamRequestPromptTruncationFromString(s string) (ChatStreamRequestPromptTruncation, error)

func (ChatStreamRequestPromptTruncation) Ptr

type ChatStreamRequestSafetyMode added in v2.11.0

type ChatStreamRequestSafetyMode string

Used to select the [safety instruction](https://docs.cohere.com/docs/safety-modes) inserted into the prompt. Defaults to `CONTEXTUAL`. When `NONE` is specified, the safety instruction will be omitted.

Safety modes are not yet configurable in combination with `tools`, `tool_results` and `documents` parameters.

**Note**: This parameter is only compatible with models [Command R 08-2024](https://docs.cohere.com/docs/command-r#august-2024-release), [Command R+ 08-2024](https://docs.cohere.com/docs/command-r-plus#august-2024-release) and newer.

**Note**: `command-r7b-12-2024` only supports `"CONTEXTUAL"` and `"STRICT"` modes.

Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

const (
	ChatStreamRequestSafetyModeContextual ChatStreamRequestSafetyMode = "CONTEXTUAL"
	ChatStreamRequestSafetyModeStrict     ChatStreamRequestSafetyMode = "STRICT"
	ChatStreamRequestSafetyModeNone       ChatStreamRequestSafetyMode = "NONE"
)

func NewChatStreamRequestSafetyModeFromString added in v2.11.0

func NewChatStreamRequestSafetyModeFromString(s string) (ChatStreamRequestSafetyMode, error)

func (ChatStreamRequestSafetyMode) Ptr added in v2.11.0

type ChatStreamStartEvent

type ChatStreamStartEvent struct {
	// Unique identifier for the generated reply. Useful for submitting feedback.
	GenerationId string `json:"generation_id" url:"generation_id"`
	// contains filtered or unexported fields
}

func (*ChatStreamStartEvent) GetExtraProperties added in v2.8.2

func (c *ChatStreamStartEvent) GetExtraProperties() map[string]interface{}

func (*ChatStreamStartEvent) GetGenerationId added in v2.12.4

func (c *ChatStreamStartEvent) GetGenerationId() string

func (*ChatStreamStartEvent) String

func (c *ChatStreamStartEvent) String() string

func (*ChatStreamStartEvent) UnmarshalJSON

func (c *ChatStreamStartEvent) UnmarshalJSON(data []byte) error

type ChatTextGenerationEvent

type ChatTextGenerationEvent struct {
	// The next batch of text generated by the model.
	Text string `json:"text" url:"text"`
	// contains filtered or unexported fields
}

func (*ChatTextGenerationEvent) GetExtraProperties added in v2.8.2

func (c *ChatTextGenerationEvent) GetExtraProperties() map[string]interface{}

func (*ChatTextGenerationEvent) GetText added in v2.12.4

func (c *ChatTextGenerationEvent) GetText() string

func (*ChatTextGenerationEvent) String

func (c *ChatTextGenerationEvent) String() string

func (*ChatTextGenerationEvent) UnmarshalJSON

func (c *ChatTextGenerationEvent) UnmarshalJSON(data []byte) error

type ChatToolCallDeltaEvent added in v2.12.0

type ChatToolCallDeltaEvent struct {
	Index *int                         `json:"index,omitempty" url:"index,omitempty"`
	Delta *ChatToolCallDeltaEventDelta `json:"delta,omitempty" url:"delta,omitempty"`
	// contains filtered or unexported fields
}

A streamed event delta which signifies a delta in tool call arguments.

func (*ChatToolCallDeltaEvent) GetDelta added in v2.12.4

func (*ChatToolCallDeltaEvent) GetExtraProperties added in v2.12.0

func (c *ChatToolCallDeltaEvent) GetExtraProperties() map[string]interface{}

func (*ChatToolCallDeltaEvent) GetIndex added in v2.12.4

func (c *ChatToolCallDeltaEvent) GetIndex() *int

func (*ChatToolCallDeltaEvent) String added in v2.12.0

func (c *ChatToolCallDeltaEvent) String() string

func (*ChatToolCallDeltaEvent) UnmarshalJSON added in v2.12.0

func (c *ChatToolCallDeltaEvent) UnmarshalJSON(data []byte) error

type ChatToolCallDeltaEventDelta added in v2.12.0

type ChatToolCallDeltaEventDelta struct {
	Message *ChatToolCallDeltaEventDeltaMessage `json:"message,omitempty" url:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatToolCallDeltaEventDelta) GetExtraProperties added in v2.12.0

func (c *ChatToolCallDeltaEventDelta) GetExtraProperties() map[string]interface{}

func (*ChatToolCallDeltaEventDelta) GetMessage added in v2.12.4

func (*ChatToolCallDeltaEventDelta) String added in v2.12.0

func (c *ChatToolCallDeltaEventDelta) String() string

func (*ChatToolCallDeltaEventDelta) UnmarshalJSON added in v2.12.0

func (c *ChatToolCallDeltaEventDelta) UnmarshalJSON(data []byte) error

type ChatToolCallDeltaEventDeltaMessage added in v2.12.3

type ChatToolCallDeltaEventDeltaMessage struct {
	ToolCalls *ChatToolCallDeltaEventDeltaMessageToolCalls `json:"tool_calls,omitempty" url:"tool_calls,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatToolCallDeltaEventDeltaMessage) GetExtraProperties added in v2.12.3

func (c *ChatToolCallDeltaEventDeltaMessage) GetExtraProperties() map[string]interface{}

func (*ChatToolCallDeltaEventDeltaMessage) GetToolCalls added in v2.12.4

func (*ChatToolCallDeltaEventDeltaMessage) String added in v2.12.3

func (*ChatToolCallDeltaEventDeltaMessage) UnmarshalJSON added in v2.12.3

func (c *ChatToolCallDeltaEventDeltaMessage) UnmarshalJSON(data []byte) error

type ChatToolCallDeltaEventDeltaMessageToolCalls added in v2.12.3

type ChatToolCallDeltaEventDeltaMessageToolCalls struct {
	Function *ChatToolCallDeltaEventDeltaMessageToolCallsFunction `json:"function,omitempty" url:"function,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatToolCallDeltaEventDeltaMessageToolCalls) GetExtraProperties added in v2.12.3

func (c *ChatToolCallDeltaEventDeltaMessageToolCalls) GetExtraProperties() map[string]interface{}

func (*ChatToolCallDeltaEventDeltaMessageToolCalls) GetFunction added in v2.12.4

func (*ChatToolCallDeltaEventDeltaMessageToolCalls) String added in v2.12.3

func (*ChatToolCallDeltaEventDeltaMessageToolCalls) UnmarshalJSON added in v2.12.3

func (c *ChatToolCallDeltaEventDeltaMessageToolCalls) UnmarshalJSON(data []byte) error

type ChatToolCallDeltaEventDeltaMessageToolCallsFunction added in v2.12.3

type ChatToolCallDeltaEventDeltaMessageToolCallsFunction struct {
	Arguments *string `json:"arguments,omitempty" url:"arguments,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatToolCallDeltaEventDeltaMessageToolCallsFunction) GetArguments added in v2.12.4

func (*ChatToolCallDeltaEventDeltaMessageToolCallsFunction) GetExtraProperties added in v2.12.3

func (c *ChatToolCallDeltaEventDeltaMessageToolCallsFunction) GetExtraProperties() map[string]interface{}

func (*ChatToolCallDeltaEventDeltaMessageToolCallsFunction) String added in v2.12.3

func (*ChatToolCallDeltaEventDeltaMessageToolCallsFunction) UnmarshalJSON added in v2.12.3

type ChatToolCallEndEvent added in v2.12.0

type ChatToolCallEndEvent struct {
	Index *int `json:"index,omitempty" url:"index,omitempty"`
	// contains filtered or unexported fields
}

A streamed event delta which signifies a tool call has finished streaming.

func (*ChatToolCallEndEvent) GetExtraProperties added in v2.12.0

func (c *ChatToolCallEndEvent) GetExtraProperties() map[string]interface{}

func (*ChatToolCallEndEvent) GetIndex added in v2.12.4

func (c *ChatToolCallEndEvent) GetIndex() *int

func (*ChatToolCallEndEvent) String added in v2.12.0

func (c *ChatToolCallEndEvent) String() string

func (*ChatToolCallEndEvent) UnmarshalJSON added in v2.12.0

func (c *ChatToolCallEndEvent) UnmarshalJSON(data []byte) error

type ChatToolCallStartEvent added in v2.12.0

type ChatToolCallStartEvent struct {
	Index *int                         `json:"index,omitempty" url:"index,omitempty"`
	Delta *ChatToolCallStartEventDelta `json:"delta,omitempty" url:"delta,omitempty"`
	// contains filtered or unexported fields
}

A streamed event delta which signifies a tool call has started streaming.

func (*ChatToolCallStartEvent) GetDelta added in v2.12.4

func (*ChatToolCallStartEvent) GetExtraProperties added in v2.12.0

func (c *ChatToolCallStartEvent) GetExtraProperties() map[string]interface{}

func (*ChatToolCallStartEvent) GetIndex added in v2.12.4

func (c *ChatToolCallStartEvent) GetIndex() *int

func (*ChatToolCallStartEvent) String added in v2.12.0

func (c *ChatToolCallStartEvent) String() string

func (*ChatToolCallStartEvent) UnmarshalJSON added in v2.12.0

func (c *ChatToolCallStartEvent) UnmarshalJSON(data []byte) error

type ChatToolCallStartEventDelta added in v2.12.0

type ChatToolCallStartEventDelta struct {
	Message *ChatToolCallStartEventDeltaMessage `json:"message,omitempty" url:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatToolCallStartEventDelta) GetExtraProperties added in v2.12.0

func (c *ChatToolCallStartEventDelta) GetExtraProperties() map[string]interface{}

func (*ChatToolCallStartEventDelta) GetMessage added in v2.12.4

func (*ChatToolCallStartEventDelta) String added in v2.12.0

func (c *ChatToolCallStartEventDelta) String() string

func (*ChatToolCallStartEventDelta) UnmarshalJSON added in v2.12.0

func (c *ChatToolCallStartEventDelta) UnmarshalJSON(data []byte) error

type ChatToolCallStartEventDeltaMessage added in v2.12.3

type ChatToolCallStartEventDeltaMessage struct {
	ToolCalls *ToolCallV2 `json:"tool_calls,omitempty" url:"tool_calls,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatToolCallStartEventDeltaMessage) GetExtraProperties added in v2.12.3

func (c *ChatToolCallStartEventDeltaMessage) GetExtraProperties() map[string]interface{}

func (*ChatToolCallStartEventDeltaMessage) GetToolCalls added in v2.12.4

func (*ChatToolCallStartEventDeltaMessage) String added in v2.12.3

func (*ChatToolCallStartEventDeltaMessage) UnmarshalJSON added in v2.12.3

func (c *ChatToolCallStartEventDeltaMessage) UnmarshalJSON(data []byte) error

type ChatToolCallsChunkEvent added in v2.8.2

type ChatToolCallsChunkEvent struct {
	ToolCallDelta *ToolCallDelta `json:"tool_call_delta,omitempty" url:"tool_call_delta,omitempty"`
	Text          *string        `json:"text,omitempty" url:"text,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatToolCallsChunkEvent) GetExtraProperties added in v2.8.2

func (c *ChatToolCallsChunkEvent) GetExtraProperties() map[string]interface{}

func (*ChatToolCallsChunkEvent) GetText added in v2.12.4

func (c *ChatToolCallsChunkEvent) GetText() *string

func (*ChatToolCallsChunkEvent) GetToolCallDelta added in v2.12.4

func (c *ChatToolCallsChunkEvent) GetToolCallDelta() *ToolCallDelta

func (*ChatToolCallsChunkEvent) String added in v2.8.2

func (c *ChatToolCallsChunkEvent) String() string

func (*ChatToolCallsChunkEvent) UnmarshalJSON added in v2.8.2

func (c *ChatToolCallsChunkEvent) UnmarshalJSON(data []byte) error

type ChatToolCallsGenerationEvent added in v2.6.0

type ChatToolCallsGenerationEvent struct {
	// The text generated related to the tool calls generated
	Text      *string     `json:"text,omitempty" url:"text,omitempty"`
	ToolCalls []*ToolCall `json:"tool_calls,omitempty" url:"tool_calls,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatToolCallsGenerationEvent) GetExtraProperties added in v2.8.2

func (c *ChatToolCallsGenerationEvent) GetExtraProperties() map[string]interface{}

func (*ChatToolCallsGenerationEvent) GetText added in v2.12.4

func (c *ChatToolCallsGenerationEvent) GetText() *string

func (*ChatToolCallsGenerationEvent) GetToolCalls added in v2.12.4

func (c *ChatToolCallsGenerationEvent) GetToolCalls() []*ToolCall

func (*ChatToolCallsGenerationEvent) String added in v2.6.0

func (*ChatToolCallsGenerationEvent) UnmarshalJSON added in v2.6.0

func (c *ChatToolCallsGenerationEvent) UnmarshalJSON(data []byte) error

type ChatToolPlanDeltaEvent added in v2.12.0

type ChatToolPlanDeltaEvent struct {
	Delta *ChatToolPlanDeltaEventDelta `json:"delta,omitempty" url:"delta,omitempty"`
	// contains filtered or unexported fields
}

A streamed event which contains a delta of tool plan text.

func (*ChatToolPlanDeltaEvent) GetDelta added in v2.12.4

func (*ChatToolPlanDeltaEvent) GetExtraProperties added in v2.12.0

func (c *ChatToolPlanDeltaEvent) GetExtraProperties() map[string]interface{}

func (*ChatToolPlanDeltaEvent) String added in v2.12.0

func (c *ChatToolPlanDeltaEvent) String() string

func (*ChatToolPlanDeltaEvent) UnmarshalJSON added in v2.12.0

func (c *ChatToolPlanDeltaEvent) UnmarshalJSON(data []byte) error

type ChatToolPlanDeltaEventDelta added in v2.12.0

type ChatToolPlanDeltaEventDelta struct {
	Message *ChatToolPlanDeltaEventDeltaMessage `json:"message,omitempty" url:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatToolPlanDeltaEventDelta) GetExtraProperties added in v2.12.0

func (c *ChatToolPlanDeltaEventDelta) GetExtraProperties() map[string]interface{}

func (*ChatToolPlanDeltaEventDelta) GetMessage added in v2.12.4

func (*ChatToolPlanDeltaEventDelta) String added in v2.12.0

func (c *ChatToolPlanDeltaEventDelta) String() string

func (*ChatToolPlanDeltaEventDelta) UnmarshalJSON added in v2.12.0

func (c *ChatToolPlanDeltaEventDelta) UnmarshalJSON(data []byte) error

type ChatToolPlanDeltaEventDeltaMessage added in v2.12.3

type ChatToolPlanDeltaEventDeltaMessage struct {
	ToolPlan *string `json:"tool_plan,omitempty" url:"tool_plan,omitempty"`
	// contains filtered or unexported fields
}

func (*ChatToolPlanDeltaEventDeltaMessage) GetExtraProperties added in v2.12.3

func (c *ChatToolPlanDeltaEventDeltaMessage) GetExtraProperties() map[string]interface{}

func (*ChatToolPlanDeltaEventDeltaMessage) GetToolPlan added in v2.12.4

func (c *ChatToolPlanDeltaEventDeltaMessage) GetToolPlan() *string

func (*ChatToolPlanDeltaEventDeltaMessage) String added in v2.12.3

func (*ChatToolPlanDeltaEventDeltaMessage) UnmarshalJSON added in v2.12.3

func (c *ChatToolPlanDeltaEventDeltaMessage) UnmarshalJSON(data []byte) error

type CheckApiKeyResponse added in v2.7.4

type CheckApiKeyResponse struct {
	Valid          bool    `json:"valid" url:"valid"`
	OrganizationId *string `json:"organization_id,omitempty" url:"organization_id,omitempty"`
	OwnerId        *string `json:"owner_id,omitempty" url:"owner_id,omitempty"`
	// contains filtered or unexported fields
}

func (*CheckApiKeyResponse) GetExtraProperties added in v2.8.2

func (c *CheckApiKeyResponse) GetExtraProperties() map[string]interface{}

func (*CheckApiKeyResponse) GetOrganizationId added in v2.12.4

func (c *CheckApiKeyResponse) GetOrganizationId() *string

func (*CheckApiKeyResponse) GetOwnerId added in v2.12.4

func (c *CheckApiKeyResponse) GetOwnerId() *string

func (*CheckApiKeyResponse) GetValid added in v2.12.4

func (c *CheckApiKeyResponse) GetValid() bool

func (*CheckApiKeyResponse) String added in v2.7.4

func (c *CheckApiKeyResponse) String() string

func (*CheckApiKeyResponse) UnmarshalJSON added in v2.7.4

func (c *CheckApiKeyResponse) UnmarshalJSON(data []byte) error

type Citation added in v2.12.0

type Citation struct {
	// Start index of the cited snippet in the original source text.
	Start *int `json:"start,omitempty" url:"start,omitempty"`
	// End index of the cited snippet in the original source text.
	End *int `json:"end,omitempty" url:"end,omitempty"`
	// Text snippet that is being cited.
	Text    *string   `json:"text,omitempty" url:"text,omitempty"`
	Sources []*Source `json:"sources,omitempty" url:"sources,omitempty"`
	// contains filtered or unexported fields
}

Citation information containing sources and the text cited.

func (*Citation) GetEnd added in v2.12.4

func (c *Citation) GetEnd() *int

func (*Citation) GetExtraProperties added in v2.12.0

func (c *Citation) GetExtraProperties() map[string]interface{}

func (*Citation) GetSources added in v2.12.4

func (c *Citation) GetSources() []*Source

func (*Citation) GetStart added in v2.12.4

func (c *Citation) GetStart() *int

func (*Citation) GetText added in v2.12.4

func (c *Citation) GetText() *string

func (*Citation) String added in v2.12.0

func (c *Citation) String() string

func (*Citation) UnmarshalJSON added in v2.12.0

func (c *Citation) UnmarshalJSON(data []byte) error

type CitationEndEvent added in v2.12.0

type CitationEndEvent struct {
	Index *int `json:"index,omitempty" url:"index,omitempty"`
	// contains filtered or unexported fields
}

A streamed event which signifies a citation has finished streaming.

func (*CitationEndEvent) GetExtraProperties added in v2.12.0

func (c *CitationEndEvent) GetExtraProperties() map[string]interface{}

func (*CitationEndEvent) GetIndex added in v2.12.4

func (c *CitationEndEvent) GetIndex() *int

func (*CitationEndEvent) String added in v2.12.0

func (c *CitationEndEvent) String() string

func (*CitationEndEvent) UnmarshalJSON added in v2.12.0

func (c *CitationEndEvent) UnmarshalJSON(data []byte) error

type CitationOptions added in v2.12.0

type CitationOptions struct {
	// Defaults to `"accurate"`.
	// Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want `"accurate"` results, `"fast"` results or no results.
	//
	// **Note**: `command-r7b-12-2024` only supports `"fast"` and `"off"` modes. Its default is `"fast"`.
	Mode *CitationOptionsMode `json:"mode,omitempty" url:"mode,omitempty"`
	// contains filtered or unexported fields
}

Options for controlling citation generation.

func (*CitationOptions) GetExtraProperties added in v2.12.0

func (c *CitationOptions) GetExtraProperties() map[string]interface{}

func (*CitationOptions) GetMode added in v2.12.4

func (c *CitationOptions) GetMode() *CitationOptionsMode

func (*CitationOptions) String added in v2.12.0

func (c *CitationOptions) String() string

func (*CitationOptions) UnmarshalJSON added in v2.12.0

func (c *CitationOptions) UnmarshalJSON(data []byte) error

type CitationOptionsMode added in v2.12.0

type CitationOptionsMode string

Defaults to `"accurate"`. Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want `"accurate"` results, `"fast"` results or no results.

**Note**: `command-r7b-12-2024` only supports `"fast"` and `"off"` modes. Its default is `"fast"`.

const (
	CitationOptionsModeFast     CitationOptionsMode = "FAST"
	CitationOptionsModeAccurate CitationOptionsMode = "ACCURATE"
	CitationOptionsModeOff      CitationOptionsMode = "OFF"
)

func NewCitationOptionsModeFromString added in v2.12.0

func NewCitationOptionsModeFromString(s string) (CitationOptionsMode, error)

func (CitationOptionsMode) Ptr added in v2.12.0

type CitationStartEvent added in v2.12.0

type CitationStartEvent struct {
	Index *int                     `json:"index,omitempty" url:"index,omitempty"`
	Delta *CitationStartEventDelta `json:"delta,omitempty" url:"delta,omitempty"`
	// contains filtered or unexported fields
}

A streamed event which signifies a citation has been created.

func (*CitationStartEvent) GetDelta added in v2.12.4

func (*CitationStartEvent) GetExtraProperties added in v2.12.0

func (c *CitationStartEvent) GetExtraProperties() map[string]interface{}

func (*CitationStartEvent) GetIndex added in v2.12.4

func (c *CitationStartEvent) GetIndex() *int

func (*CitationStartEvent) String added in v2.12.0

func (c *CitationStartEvent) String() string

func (*CitationStartEvent) UnmarshalJSON added in v2.12.0

func (c *CitationStartEvent) UnmarshalJSON(data []byte) error

type CitationStartEventDelta added in v2.12.0

type CitationStartEventDelta struct {
	Message *CitationStartEventDeltaMessage `json:"message,omitempty" url:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*CitationStartEventDelta) GetExtraProperties added in v2.12.0

func (c *CitationStartEventDelta) GetExtraProperties() map[string]interface{}

func (*CitationStartEventDelta) GetMessage added in v2.12.4

func (*CitationStartEventDelta) String added in v2.12.0

func (c *CitationStartEventDelta) String() string

func (*CitationStartEventDelta) UnmarshalJSON added in v2.12.0

func (c *CitationStartEventDelta) UnmarshalJSON(data []byte) error

type CitationStartEventDeltaMessage added in v2.12.0

type CitationStartEventDeltaMessage struct {
	Citations *Citation `json:"citations,omitempty" url:"citations,omitempty"`
	// contains filtered or unexported fields
}

func (*CitationStartEventDeltaMessage) GetCitations added in v2.12.4

func (c *CitationStartEventDeltaMessage) GetCitations() *Citation

func (*CitationStartEventDeltaMessage) GetExtraProperties added in v2.12.0

func (c *CitationStartEventDeltaMessage) GetExtraProperties() map[string]interface{}

func (*CitationStartEventDeltaMessage) String added in v2.12.0

func (*CitationStartEventDeltaMessage) UnmarshalJSON added in v2.12.0

func (c *CitationStartEventDeltaMessage) UnmarshalJSON(data []byte) error

type ClassifyDataMetrics added in v2.6.0

type ClassifyDataMetrics struct {
	LabelMetrics []*LabelMetric `json:"label_metrics,omitempty" url:"label_metrics,omitempty"`
	// contains filtered or unexported fields
}

func (*ClassifyDataMetrics) GetExtraProperties added in v2.8.2

func (c *ClassifyDataMetrics) GetExtraProperties() map[string]interface{}

func (*ClassifyDataMetrics) GetLabelMetrics added in v2.12.4

func (c *ClassifyDataMetrics) GetLabelMetrics() []*LabelMetric

func (*ClassifyDataMetrics) String added in v2.6.0

func (c *ClassifyDataMetrics) String() string

func (*ClassifyDataMetrics) UnmarshalJSON added in v2.6.0

func (c *ClassifyDataMetrics) UnmarshalJSON(data []byte) error

type ClassifyExample added in v2.5.2

type ClassifyExample struct {
	Text  *string `json:"text,omitempty" url:"text,omitempty"`
	Label *string `json:"label,omitempty" url:"label,omitempty"`
	// contains filtered or unexported fields
}

func (*ClassifyExample) GetExtraProperties added in v2.8.2

func (c *ClassifyExample) GetExtraProperties() map[string]interface{}

func (*ClassifyExample) GetLabel added in v2.12.4

func (c *ClassifyExample) GetLabel() *string

func (*ClassifyExample) GetText added in v2.12.4

func (c *ClassifyExample) GetText() *string

func (*ClassifyExample) String added in v2.5.2

func (c *ClassifyExample) String() string

func (*ClassifyExample) UnmarshalJSON added in v2.5.2

func (c *ClassifyExample) UnmarshalJSON(data []byte) error

type ClassifyRequest

type ClassifyRequest struct {
	// A list of up to 96 texts to be classified. Each one must be a non-empty string.
	// There is, however, no consistent, universal limit to the length a particular input can be. We perform classification on the first `x` tokens of each input, and `x` varies depending on which underlying model is powering classification. The maximum token length for each model is listed in the "max tokens" column [here](https://docs.cohere.com/docs/models).
	// Note: by default the `truncate` parameter is set to `END`, so tokens exceeding the limit will be automatically dropped. This behavior can be disabled by setting `truncate` to `NONE`, which will result in validation errors for longer texts.
	Inputs []string `json:"inputs,omitempty" url:"-"`
	// An array of examples to provide context to the model. Each example is a text string and its associated label/class. Each unique label requires at least 2 examples associated with it; the maximum number of examples is 2500, and each example has a maximum length of 512 tokens. The values should be structured as `{text: "...",label: "..."}`.
	// 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.
	Examples []*ClassifyExample `json:"examples,omitempty" url:"-"`
	// The identifier of the model. Currently available models are `embed-multilingual-v2.0`, `embed-english-light-v2.0`, and `embed-english-v2.0` (default). Smaller "light" models are faster, while larger models will perform better. [Fine-tuned models](https://docs.cohere.com/docs/fine-tuning) can also be supplied with their full ID.
	Model *string `json:"model,omitempty" url:"-"`
	// The ID of a custom playground preset. You can create presets in the [playground](https://dashboard.cohere.com/playground/classify?model=large). If you use a preset, all other parameters become optional, and any included parameters will override the preset's parameters.
	Preset *string `json:"preset,omitempty" url:"-"`
	// One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length.
	// Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.
	// If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.
	Truncate *ClassifyRequestTruncate `json:"truncate,omitempty" url:"-"`
}

type ClassifyRequestTruncate

type ClassifyRequestTruncate string

One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length. Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model. If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.

const (
	ClassifyRequestTruncateNone  ClassifyRequestTruncate = "NONE"
	ClassifyRequestTruncateStart ClassifyRequestTruncate = "START"
	ClassifyRequestTruncateEnd   ClassifyRequestTruncate = "END"
)

func NewClassifyRequestTruncateFromString

func NewClassifyRequestTruncateFromString(s string) (ClassifyRequestTruncate, error)

func (ClassifyRequestTruncate) Ptr

type ClassifyResponse

type ClassifyResponse struct {
	Id              string                                 `json:"id" url:"id"`
	Classifications []*ClassifyResponseClassificationsItem `json:"classifications,omitempty" url:"classifications,omitempty"`
	Meta            *ApiMeta                               `json:"meta,omitempty" url:"meta,omitempty"`
	// contains filtered or unexported fields
}

func (*ClassifyResponse) GetClassifications added in v2.12.4

func (c *ClassifyResponse) GetClassifications() []*ClassifyResponseClassificationsItem

func (*ClassifyResponse) GetExtraProperties added in v2.8.2

func (c *ClassifyResponse) GetExtraProperties() map[string]interface{}

func (*ClassifyResponse) GetId added in v2.12.4

func (c *ClassifyResponse) GetId() string

func (*ClassifyResponse) GetMeta added in v2.12.4

func (c *ClassifyResponse) GetMeta() *ApiMeta

func (*ClassifyResponse) String

func (c *ClassifyResponse) String() string

func (*ClassifyResponse) UnmarshalJSON

func (c *ClassifyResponse) UnmarshalJSON(data []byte) error

type ClassifyResponseClassificationsItem

type ClassifyResponseClassificationsItem struct {
	Id string `json:"id" url:"id"`
	// The input text that was classified
	Input *string `json:"input,omitempty" url:"input,omitempty"`
	// The predicted label for the associated query (only filled for single-label models)
	Prediction *string `json:"prediction,omitempty" url:"prediction,omitempty"`
	// An array containing the predicted labels for the associated query (only filled for single-label classification)
	Predictions []string `json:"predictions,omitempty" url:"predictions,omitempty"`
	// The confidence score for the top predicted class (only filled for single-label classification)
	Confidence *float64 `json:"confidence,omitempty" url:"confidence,omitempty"`
	// An array containing the confidence scores of all the predictions in the same order
	Confidences []float64 `json:"confidences,omitempty" url:"confidences,omitempty"`
	// A map containing each label and its confidence score according to the classifier. All the confidence scores add up to 1 for single-label classification. For multi-label classification the label confidences are independent of each other, so they don't have to sum up to 1.
	Labels map[string]*ClassifyResponseClassificationsItemLabelsValue `json:"labels,omitempty" url:"labels,omitempty"`
	// The type of classification performed
	ClassificationType ClassifyResponseClassificationsItemClassificationType `json:"classification_type" url:"classification_type"`
	// contains filtered or unexported fields
}

func (*ClassifyResponseClassificationsItem) GetClassificationType added in v2.12.4

func (*ClassifyResponseClassificationsItem) GetConfidence added in v2.12.4

func (c *ClassifyResponseClassificationsItem) GetConfidence() *float64

func (*ClassifyResponseClassificationsItem) GetConfidences added in v2.12.4

func (c *ClassifyResponseClassificationsItem) GetConfidences() []float64

func (*ClassifyResponseClassificationsItem) GetExtraProperties added in v2.8.2

func (c *ClassifyResponseClassificationsItem) GetExtraProperties() map[string]interface{}

func (*ClassifyResponseClassificationsItem) GetId added in v2.12.4

func (*ClassifyResponseClassificationsItem) GetInput added in v2.12.4

func (*ClassifyResponseClassificationsItem) GetLabels added in v2.12.4

func (*ClassifyResponseClassificationsItem) GetPrediction added in v2.12.4

func (c *ClassifyResponseClassificationsItem) GetPrediction() *string

func (*ClassifyResponseClassificationsItem) GetPredictions added in v2.12.4

func (c *ClassifyResponseClassificationsItem) GetPredictions() []string

func (*ClassifyResponseClassificationsItem) String

func (*ClassifyResponseClassificationsItem) UnmarshalJSON

func (c *ClassifyResponseClassificationsItem) UnmarshalJSON(data []byte) error

type ClassifyResponseClassificationsItemClassificationType

type ClassifyResponseClassificationsItemClassificationType string

The type of classification performed

const (
	ClassifyResponseClassificationsItemClassificationTypeSingleLabel ClassifyResponseClassificationsItemClassificationType = "single-label"
	ClassifyResponseClassificationsItemClassificationTypeMultiLabel  ClassifyResponseClassificationsItemClassificationType = "multi-label"
)

func NewClassifyResponseClassificationsItemClassificationTypeFromString

func NewClassifyResponseClassificationsItemClassificationTypeFromString(s string) (ClassifyResponseClassificationsItemClassificationType, error)

func (ClassifyResponseClassificationsItemClassificationType) Ptr

type ClassifyResponseClassificationsItemLabelsValue

type ClassifyResponseClassificationsItemLabelsValue struct {
	Confidence *float64 `json:"confidence,omitempty" url:"confidence,omitempty"`
	// contains filtered or unexported fields
}

func (*ClassifyResponseClassificationsItemLabelsValue) GetConfidence added in v2.12.4

func (*ClassifyResponseClassificationsItemLabelsValue) GetExtraProperties added in v2.8.2

func (c *ClassifyResponseClassificationsItemLabelsValue) GetExtraProperties() map[string]interface{}

func (*ClassifyResponseClassificationsItemLabelsValue) String

func (*ClassifyResponseClassificationsItemLabelsValue) UnmarshalJSON

type ClientClosedRequestError added in v2.8.2

type ClientClosedRequestError struct {
	*core.APIError
	Body interface{}
}

This error is returned when a request is cancelled by the user.

func (*ClientClosedRequestError) MarshalJSON added in v2.8.2

func (c *ClientClosedRequestError) MarshalJSON() ([]byte, error)

func (*ClientClosedRequestError) UnmarshalJSON added in v2.8.2

func (c *ClientClosedRequestError) UnmarshalJSON(data []byte) error

func (*ClientClosedRequestError) Unwrap added in v2.8.2

func (c *ClientClosedRequestError) Unwrap() error

type CompatibleEndpoint added in v2.6.0

type CompatibleEndpoint string

One of the Cohere API endpoints that the model can be used with.

const (
	CompatibleEndpointChat      CompatibleEndpoint = "chat"
	CompatibleEndpointEmbed     CompatibleEndpoint = "embed"
	CompatibleEndpointClassify  CompatibleEndpoint = "classify"
	CompatibleEndpointSummarize CompatibleEndpoint = "summarize"
	CompatibleEndpointRerank    CompatibleEndpoint = "rerank"
	CompatibleEndpointRate      CompatibleEndpoint = "rate"
	CompatibleEndpointGenerate  CompatibleEndpoint = "generate"
)

func NewCompatibleEndpointFromString added in v2.6.0

func NewCompatibleEndpointFromString(s string) (CompatibleEndpoint, error)

func (CompatibleEndpoint) Ptr added in v2.6.0

type Connector added in v2.2.0

type Connector struct {
	// The unique identifier of the connector (used in both `/connectors` & `/chat` endpoints).
	// This is automatically created from the name of the connector upon registration.
	Id string `json:"id" url:"id"`
	// The organization to which this connector belongs. This is automatically set to
	// the organization of the user who created the connector.
	OrganizationId *string `json:"organization_id,omitempty" url:"organization_id,omitempty"`
	// A human-readable name for the connector.
	Name string `json:"name" url:"name"`
	// A description of the connector.
	Description *string `json:"description,omitempty" url:"description,omitempty"`
	// The URL of the connector that will be used to search for documents.
	Url *string `json:"url,omitempty" url:"url,omitempty"`
	// The UTC time at which the connector was created.
	CreatedAt time.Time `json:"created_at" url:"created_at"`
	// The UTC time at which the connector was last updated.
	UpdatedAt time.Time `json:"updated_at" url:"updated_at"`
	// A list of fields to exclude from the prompt (fields remain in the document).
	Excludes []string `json:"excludes,omitempty" url:"excludes,omitempty"`
	// The type of authentication/authorization used by the connector. Possible values: [oauth, service_auth]
	AuthType *string `json:"auth_type,omitempty" url:"auth_type,omitempty"`
	// The OAuth 2.0 configuration for the connector.
	Oauth *ConnectorOAuth `json:"oauth,omitempty" url:"oauth,omitempty"`
	// The OAuth status for the user making the request. One of ["valid", "expired", ""]. Empty string (field is omitted) means the user has not authorized the connector yet.
	AuthStatus *ConnectorAuthStatus `json:"auth_status,omitempty" url:"auth_status,omitempty"`
	// Whether the connector is active or not.
	Active *bool `json:"active,omitempty" url:"active,omitempty"`
	// Whether a chat request should continue or not if the request to this connector fails.
	ContinueOnFailure *bool `json:"continue_on_failure,omitempty" url:"continue_on_failure,omitempty"`
	// contains filtered or unexported fields
}

A connector allows you to integrate data sources with the '/chat' endpoint to create grounded generations with citations to the data source. documents to help answer users.

func (*Connector) GetActive added in v2.12.4

func (c *Connector) GetActive() *bool

func (*Connector) GetAuthStatus added in v2.12.4

func (c *Connector) GetAuthStatus() *ConnectorAuthStatus

func (*Connector) GetAuthType added in v2.12.4

func (c *Connector) GetAuthType() *string

func (*Connector) GetContinueOnFailure added in v2.12.4

func (c *Connector) GetContinueOnFailure() *bool

func (*Connector) GetCreatedAt added in v2.12.4

func (c *Connector) GetCreatedAt() time.Time

func (*Connector) GetDescription added in v2.12.4

func (c *Connector) GetDescription() *string

func (*Connector) GetExcludes added in v2.12.4

func (c *Connector) GetExcludes() []string

func (*Connector) GetExtraProperties added in v2.8.2

func (c *Connector) GetExtraProperties() map[string]interface{}

func (*Connector) GetId added in v2.12.4

func (c *Connector) GetId() string

func (*Connector) GetName added in v2.12.4

func (c *Connector) GetName() string

func (*Connector) GetOauth added in v2.12.4

func (c *Connector) GetOauth() *ConnectorOAuth

func (*Connector) GetOrganizationId added in v2.12.4

func (c *Connector) GetOrganizationId() *string

func (*Connector) GetUpdatedAt added in v2.12.4

func (c *Connector) GetUpdatedAt() time.Time

func (*Connector) GetUrl added in v2.12.4

func (c *Connector) GetUrl() *string

func (*Connector) MarshalJSON added in v2.6.0

func (c *Connector) MarshalJSON() ([]byte, error)

func (*Connector) String added in v2.2.0

func (c *Connector) String() string

func (*Connector) UnmarshalJSON added in v2.2.0

func (c *Connector) UnmarshalJSON(data []byte) error

type ConnectorAuthStatus added in v2.2.0

type ConnectorAuthStatus string

The OAuth status for the user making the request. One of ["valid", "expired", ""]. Empty string (field is omitted) means the user has not authorized the connector yet.

const (
	ConnectorAuthStatusValid   ConnectorAuthStatus = "valid"
	ConnectorAuthStatusExpired ConnectorAuthStatus = "expired"
)

func NewConnectorAuthStatusFromString added in v2.2.0

func NewConnectorAuthStatusFromString(s string) (ConnectorAuthStatus, error)

func (ConnectorAuthStatus) Ptr added in v2.2.0

type ConnectorOAuth added in v2.2.0

type ConnectorOAuth struct {
	// The OAuth 2.0 client ID. This field is encrypted at rest.
	ClientId *string `json:"client_id,omitempty" url:"client_id,omitempty"`
	// The OAuth 2.0 client Secret. This field is encrypted at rest and never returned in a response.
	ClientSecret *string `json:"client_secret,omitempty" url:"client_secret,omitempty"`
	// The OAuth 2.0 /authorize endpoint to use when users authorize the connector.
	AuthorizeUrl string `json:"authorize_url" url:"authorize_url"`
	// The OAuth 2.0 /token endpoint to use when users authorize the connector.
	TokenUrl string `json:"token_url" url:"token_url"`
	// The OAuth scopes to request when users authorize the connector.
	Scope *string `json:"scope,omitempty" url:"scope,omitempty"`
	// contains filtered or unexported fields
}

func (*ConnectorOAuth) GetAuthorizeUrl added in v2.12.4

func (c *ConnectorOAuth) GetAuthorizeUrl() string

func (*ConnectorOAuth) GetClientId added in v2.12.4

func (c *ConnectorOAuth) GetClientId() *string

func (*ConnectorOAuth) GetClientSecret added in v2.12.4

func (c *ConnectorOAuth) GetClientSecret() *string

func (*ConnectorOAuth) GetExtraProperties added in v2.8.2

func (c *ConnectorOAuth) GetExtraProperties() map[string]interface{}

func (*ConnectorOAuth) GetScope added in v2.12.4

func (c *ConnectorOAuth) GetScope() *string

func (*ConnectorOAuth) GetTokenUrl added in v2.12.4

func (c *ConnectorOAuth) GetTokenUrl() string

func (*ConnectorOAuth) String added in v2.2.0

func (c *ConnectorOAuth) String() string

func (*ConnectorOAuth) UnmarshalJSON added in v2.2.0

func (c *ConnectorOAuth) UnmarshalJSON(data []byte) error

type ConnectorsListRequest added in v2.4.1

type ConnectorsListRequest struct {
	// Maximum number of connectors to return [0, 100].
	Limit *float64 `json:"-" url:"limit,omitempty"`
	// Number of connectors to skip before returning results [0, inf].
	Offset *float64 `json:"-" url:"offset,omitempty"`
}

type ConnectorsOAuthAuthorizeRequest added in v2.5.0

type ConnectorsOAuthAuthorizeRequest struct {
	// The URL to redirect to after the connector has been authorized.
	AfterTokenRedirect *string `json:"-" url:"after_token_redirect,omitempty"`
}

type Content added in v2.12.0

type Content struct {
	Type string
	Text *TextContent
}

A Content block which contains information about the content type and the content itself.

func (*Content) Accept added in v2.12.0

func (c *Content) Accept(visitor ContentVisitor) error

func (*Content) GetText added in v2.12.4

func (c *Content) GetText() *TextContent

func (*Content) GetType added in v2.12.4

func (c *Content) GetType() string

func (Content) MarshalJSON added in v2.12.0

func (c Content) MarshalJSON() ([]byte, error)

func (*Content) UnmarshalJSON added in v2.12.0

func (c *Content) UnmarshalJSON(data []byte) error

type ContentVisitor added in v2.12.0

type ContentVisitor interface {
	VisitText(*TextContent) error
}

type CreateConnectorOAuth added in v2.2.0

type CreateConnectorOAuth struct {
	// The OAuth 2.0 client ID. This fields is encrypted at rest.
	ClientId *string `json:"client_id,omitempty" url:"client_id,omitempty"`
	// The OAuth 2.0 client Secret. This field is encrypted at rest and never returned in a response.
	ClientSecret *string `json:"client_secret,omitempty" url:"client_secret,omitempty"`
	// The OAuth 2.0 /authorize endpoint to use when users authorize the connector.
	AuthorizeUrl *string `json:"authorize_url,omitempty" url:"authorize_url,omitempty"`
	// The OAuth 2.0 /token endpoint to use when users authorize the connector.
	TokenUrl *string `json:"token_url,omitempty" url:"token_url,omitempty"`
	// The OAuth scopes to request when users authorize the connector.
	Scope *string `json:"scope,omitempty" url:"scope,omitempty"`
	// contains filtered or unexported fields
}

func (*CreateConnectorOAuth) GetAuthorizeUrl added in v2.12.4

func (c *CreateConnectorOAuth) GetAuthorizeUrl() *string

func (*CreateConnectorOAuth) GetClientId added in v2.12.4

func (c *CreateConnectorOAuth) GetClientId() *string

func (*CreateConnectorOAuth) GetClientSecret added in v2.12.4

func (c *CreateConnectorOAuth) GetClientSecret() *string

func (*CreateConnectorOAuth) GetExtraProperties added in v2.8.2

func (c *CreateConnectorOAuth) GetExtraProperties() map[string]interface{}

func (*CreateConnectorOAuth) GetScope added in v2.12.4

func (c *CreateConnectorOAuth) GetScope() *string

func (*CreateConnectorOAuth) GetTokenUrl added in v2.12.4

func (c *CreateConnectorOAuth) GetTokenUrl() *string

func (*CreateConnectorOAuth) String added in v2.2.0

func (c *CreateConnectorOAuth) String() string

func (*CreateConnectorOAuth) UnmarshalJSON added in v2.2.0

func (c *CreateConnectorOAuth) UnmarshalJSON(data []byte) error

type CreateConnectorRequest added in v2.5.0

type CreateConnectorRequest struct {
	// A human-readable name for the connector.
	Name string `json:"name" url:"-"`
	// A description of the connector.
	Description *string `json:"description,omitempty" url:"-"`
	// The URL of the connector that will be used to search for documents.
	Url string `json:"url" url:"-"`
	// A list of fields to exclude from the prompt (fields remain in the document).
	Excludes []string `json:"excludes,omitempty" url:"-"`
	// The OAuth 2.0 configuration for the connector. Cannot be specified if service_auth is specified.
	Oauth *CreateConnectorOAuth `json:"oauth,omitempty" url:"-"`
	// Whether the connector is active or not.
	Active *bool `json:"active,omitempty" url:"-"`
	// Whether a chat request should continue or not if the request to this connector fails.
	ContinueOnFailure *bool `json:"continue_on_failure,omitempty" url:"-"`
	// The service to service authentication configuration for the connector. Cannot be specified if oauth is specified.
	ServiceAuth *CreateConnectorServiceAuth `json:"service_auth,omitempty" url:"-"`
}

type CreateConnectorResponse added in v2.5.0

type CreateConnectorResponse struct {
	Connector *Connector `json:"connector,omitempty" url:"connector,omitempty"`
	// contains filtered or unexported fields
}

func (*CreateConnectorResponse) GetConnector added in v2.12.4

func (c *CreateConnectorResponse) GetConnector() *Connector

func (*CreateConnectorResponse) GetExtraProperties added in v2.8.2

func (c *CreateConnectorResponse) GetExtraProperties() map[string]interface{}

func (*CreateConnectorResponse) String added in v2.5.0

func (c *CreateConnectorResponse) String() string

func (*CreateConnectorResponse) UnmarshalJSON added in v2.5.0

func (c *CreateConnectorResponse) UnmarshalJSON(data []byte) error

type CreateConnectorServiceAuth added in v2.2.0

type CreateConnectorServiceAuth struct {
	Type AuthTokenType `json:"type" url:"type"`
	// The token that will be used in the HTTP Authorization header when making requests to the connector. This field is encrypted at rest and never returned in a response.
	Token string `json:"token" url:"token"`
	// contains filtered or unexported fields
}

func (*CreateConnectorServiceAuth) GetExtraProperties added in v2.8.2

func (c *CreateConnectorServiceAuth) GetExtraProperties() map[string]interface{}

func (*CreateConnectorServiceAuth) GetToken added in v2.12.4

func (c *CreateConnectorServiceAuth) GetToken() string

func (*CreateConnectorServiceAuth) GetType added in v2.12.4

func (*CreateConnectorServiceAuth) String added in v2.2.0

func (c *CreateConnectorServiceAuth) String() string

func (*CreateConnectorServiceAuth) UnmarshalJSON added in v2.2.0

func (c *CreateConnectorServiceAuth) UnmarshalJSON(data []byte) error

type CreateEmbedJobRequest added in v2.5.0

type CreateEmbedJobRequest struct {
	// ID of the embedding model.
	//
	// Available models and corresponding embedding dimensions:
	//
	// - `embed-english-v3.0` : 1024
	// - `embed-multilingual-v3.0` : 1024
	// - `embed-english-light-v3.0` : 384
	// - `embed-multilingual-light-v3.0` : 384
	Model string `json:"model" url:"-"`
	// ID of a [Dataset](https://docs.cohere.com/docs/datasets). The Dataset must be of type `embed-input` and must have a validation status `Validated`
	DatasetId string         `json:"dataset_id" url:"-"`
	InputType EmbedInputType `json:"input_type" url:"-"`
	// The name of the embed job.
	Name *string `json:"name,omitempty" url:"-"`
	// Specifies the types of embeddings you want to get back. Not required and default is None, which returns the Embed Floats response type. Can be one or more of the following types.
	//
	// * `"float"`: Use this when you want to get back the default float embeddings. Valid for all models.
	// * `"int8"`: Use this when you want to get back signed int8 embeddings. Valid for only v3 models.
	// * `"uint8"`: Use this when you want to get back unsigned int8 embeddings. Valid for only v3 models.
	// * `"binary"`: Use this when you want to get back signed binary embeddings. Valid for only v3 models.
	// * `"ubinary"`: Use this when you want to get back unsigned binary embeddings. Valid for only v3 models.
	EmbeddingTypes []EmbeddingType `json:"embedding_types,omitempty" url:"-"`
	// One of `START|END` to specify how the API will handle inputs longer than the maximum token length.
	//
	// Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.
	Truncate *CreateEmbedJobRequestTruncate `json:"truncate,omitempty" url:"-"`
}

type CreateEmbedJobRequestTruncate added in v2.5.0

type CreateEmbedJobRequestTruncate string

One of `START|END` to specify how the API will handle inputs longer than the maximum token length.

Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

const (
	CreateEmbedJobRequestTruncateStart CreateEmbedJobRequestTruncate = "START"
	CreateEmbedJobRequestTruncateEnd   CreateEmbedJobRequestTruncate = "END"
)

func NewCreateEmbedJobRequestTruncateFromString added in v2.5.0

func NewCreateEmbedJobRequestTruncateFromString(s string) (CreateEmbedJobRequestTruncate, error)

func (CreateEmbedJobRequestTruncate) Ptr added in v2.5.0

type CreateEmbedJobResponse added in v2.5.0

type CreateEmbedJobResponse struct {
	JobId string   `json:"job_id" url:"job_id"`
	Meta  *ApiMeta `json:"meta,omitempty" url:"meta,omitempty"`
	// contains filtered or unexported fields
}

Response from creating an embed job.

func (*CreateEmbedJobResponse) GetExtraProperties added in v2.8.2

func (c *CreateEmbedJobResponse) GetExtraProperties() map[string]interface{}

func (*CreateEmbedJobResponse) GetJobId added in v2.12.4

func (c *CreateEmbedJobResponse) GetJobId() string

func (*CreateEmbedJobResponse) GetMeta added in v2.12.4

func (c *CreateEmbedJobResponse) GetMeta() *ApiMeta

func (*CreateEmbedJobResponse) String added in v2.5.0

func (c *CreateEmbedJobResponse) String() string

func (*CreateEmbedJobResponse) UnmarshalJSON added in v2.5.0

func (c *CreateEmbedJobResponse) UnmarshalJSON(data []byte) error

type Dataset

type Dataset struct {
	// The dataset ID
	Id string `json:"id" url:"id"`
	// The name of the dataset
	Name string `json:"name" url:"name"`
	// The creation date
	CreatedAt time.Time `json:"created_at" url:"created_at"`
	// The last update date
	UpdatedAt        time.Time               `json:"updated_at" url:"updated_at"`
	DatasetType      DatasetType             `json:"dataset_type" url:"dataset_type"`
	ValidationStatus DatasetValidationStatus `json:"validation_status" url:"validation_status"`
	// Errors found during validation
	ValidationError *string `json:"validation_error,omitempty" url:"validation_error,omitempty"`
	// the avro schema of the dataset
	Schema         *string  `json:"schema,omitempty" url:"schema,omitempty"`
	RequiredFields []string `json:"required_fields,omitempty" url:"required_fields,omitempty"`
	PreserveFields []string `json:"preserve_fields,omitempty" url:"preserve_fields,omitempty"`
	// the underlying files that make up the dataset
	DatasetParts []*DatasetPart `json:"dataset_parts,omitempty" url:"dataset_parts,omitempty"`
	// warnings found during validation
	ValidationWarnings []string `json:"validation_warnings,omitempty" url:"validation_warnings,omitempty"`
	// contains filtered or unexported fields
}

func (*Dataset) GetCreatedAt added in v2.12.4

func (d *Dataset) GetCreatedAt() time.Time

func (*Dataset) GetDatasetParts added in v2.12.4

func (d *Dataset) GetDatasetParts() []*DatasetPart

func (*Dataset) GetDatasetType added in v2.12.4

func (d *Dataset) GetDatasetType() DatasetType

func (*Dataset) GetExtraProperties added in v2.8.2

func (d *Dataset) GetExtraProperties() map[string]interface{}

func (*Dataset) GetId added in v2.12.4

func (d *Dataset) GetId() string

func (*Dataset) GetName added in v2.12.4

func (d *Dataset) GetName() string

func (*Dataset) GetPreserveFields added in v2.12.4

func (d *Dataset) GetPreserveFields() []string

func (*Dataset) GetRequiredFields added in v2.12.4

func (d *Dataset) GetRequiredFields() []string

func (*Dataset) GetSchema added in v2.12.4

func (d *Dataset) GetSchema() *string

func (*Dataset) GetUpdatedAt added in v2.12.4

func (d *Dataset) GetUpdatedAt() time.Time

func (*Dataset) GetValidationError added in v2.12.4

func (d *Dataset) GetValidationError() *string

func (*Dataset) GetValidationStatus added in v2.12.4

func (d *Dataset) GetValidationStatus() DatasetValidationStatus

func (*Dataset) GetValidationWarnings added in v2.12.4

func (d *Dataset) GetValidationWarnings() []string

func (*Dataset) MarshalJSON added in v2.6.0

func (d *Dataset) MarshalJSON() ([]byte, error)

func (*Dataset) String

func (d *Dataset) String() string

func (*Dataset) UnmarshalJSON

func (d *Dataset) UnmarshalJSON(data []byte) error

type DatasetPart

type DatasetPart struct {
	// The dataset part ID
	Id string `json:"id" url:"id"`
	// The name of the dataset part
	Name string `json:"name" url:"name"`
	// The download url of the file
	Url *string `json:"url,omitempty" url:"url,omitempty"`
	// The index of the file
	Index *int `json:"index,omitempty" url:"index,omitempty"`
	// The size of the file in bytes
	SizeBytes *int `json:"size_bytes,omitempty" url:"size_bytes,omitempty"`
	// The number of rows in the file
	NumRows *int `json:"num_rows,omitempty" url:"num_rows,omitempty"`
	// The download url of the original file
	OriginalUrl *string `json:"original_url,omitempty" url:"original_url,omitempty"`
	// The first few rows of the parsed file
	Samples []string `json:"samples,omitempty" url:"samples,omitempty"`
	// contains filtered or unexported fields
}

func (*DatasetPart) GetExtraProperties added in v2.8.2

func (d *DatasetPart) GetExtraProperties() map[string]interface{}

func (*DatasetPart) GetId added in v2.12.4

func (d *DatasetPart) GetId() string

func (*DatasetPart) GetIndex added in v2.12.4

func (d *DatasetPart) GetIndex() *int

func (*DatasetPart) GetName added in v2.12.4

func (d *DatasetPart) GetName() string

func (*DatasetPart) GetNumRows added in v2.12.4

func (d *DatasetPart) GetNumRows() *int

func (*DatasetPart) GetOriginalUrl added in v2.12.4

func (d *DatasetPart) GetOriginalUrl() *string

func (*DatasetPart) GetSamples added in v2.12.4

func (d *DatasetPart) GetSamples() []string

func (*DatasetPart) GetSizeBytes added in v2.12.4

func (d *DatasetPart) GetSizeBytes() *int

func (*DatasetPart) GetUrl added in v2.12.4

func (d *DatasetPart) GetUrl() *string

func (*DatasetPart) String

func (d *DatasetPart) String() string

func (*DatasetPart) UnmarshalJSON

func (d *DatasetPart) UnmarshalJSON(data []byte) error

type DatasetType added in v2.5.0

type DatasetType string

The type of the dataset

const (
	DatasetTypeEmbedInput                             DatasetType = "embed-input"
	DatasetTypeEmbedResult                            DatasetType = "embed-result"
	DatasetTypeClusterResult                          DatasetType = "cluster-result"
	DatasetTypeClusterOutliers                        DatasetType = "cluster-outliers"
	DatasetTypeRerankerFinetuneInput                  DatasetType = "reranker-finetune-input"
	DatasetTypeSingleLabelClassificationFinetuneInput DatasetType = "single-label-classification-finetune-input"
	DatasetTypeChatFinetuneInput                      DatasetType = "chat-finetune-input"
	DatasetTypeMultiLabelClassificationFinetuneInput  DatasetType = "multi-label-classification-finetune-input"
)

func NewDatasetTypeFromString added in v2.5.0

func NewDatasetTypeFromString(s string) (DatasetType, error)

func (DatasetType) Ptr added in v2.5.0

func (d DatasetType) Ptr() *DatasetType

type DatasetValidationStatus added in v2.5.0

type DatasetValidationStatus string

The validation status of the dataset

const (
	DatasetValidationStatusUnknown    DatasetValidationStatus = "unknown"
	DatasetValidationStatusQueued     DatasetValidationStatus = "queued"
	DatasetValidationStatusProcessing DatasetValidationStatus = "processing"
	DatasetValidationStatusFailed     DatasetValidationStatus = "failed"
	DatasetValidationStatusValidated  DatasetValidationStatus = "validated"
	DatasetValidationStatusSkipped    DatasetValidationStatus = "skipped"
)

func NewDatasetValidationStatusFromString added in v2.5.0

func NewDatasetValidationStatusFromString(s string) (DatasetValidationStatus, error)

func (DatasetValidationStatus) Ptr added in v2.5.0

type DatasetsCreateRequest added in v2.5.0

type DatasetsCreateRequest struct {
	// The name of the uploaded dataset.
	Name string `json:"-" url:"name"`
	// The dataset type, which is used to validate the data. Valid types are `embed-input`, `reranker-finetune-input`, `single-label-classification-finetune-input`, `chat-finetune-input`, and `multi-label-classification-finetune-input`.
	Type DatasetType `json:"-" url:"type"`
	// Indicates if the original file should be stored.
	KeepOriginalFile *bool `json:"-" url:"keep_original_file,omitempty"`
	// Indicates whether rows with malformed input should be dropped (instead of failing the validation check). Dropped rows will be returned in the warnings field.
	SkipMalformedInput *bool `json:"-" url:"skip_malformed_input,omitempty"`
	// List of names of fields that will be persisted in the Dataset. By default the Dataset will retain only the required fields indicated in the [schema for the corresponding Dataset type](https://docs.cohere.com/docs/datasets#dataset-types). For example, datasets of type `embed-input` will drop all fields other than the required `text` field. If any of the fields in `keep_fields` are missing from the uploaded file, Dataset validation will fail.
	KeepFields []*string `json:"-" url:"keep_fields,omitempty"`
	// List of names of fields that will be persisted in the Dataset. By default the Dataset will retain only the required fields indicated in the [schema for the corresponding Dataset type](https://docs.cohere.com/docs/datasets#dataset-types). For example, Datasets of type `embed-input` will drop all fields other than the required `text` field. If any of the fields in `optional_fields` are missing from the uploaded file, Dataset validation will pass.
	OptionalFields []*string `json:"-" url:"optional_fields,omitempty"`
	// Raw .txt uploads will be split into entries using the text_separator value.
	TextSeparator *string `json:"-" url:"text_separator,omitempty"`
	// The delimiter used for .csv uploads.
	CsvDelimiter *string `json:"-" url:"csv_delimiter,omitempty"`
	// flag to enable dry_run mode
	DryRun *bool `json:"-" url:"dry_run,omitempty"`
}

type DatasetsCreateResponse added in v2.5.0

type DatasetsCreateResponse struct {
	// The dataset ID
	Id *string `json:"id,omitempty" url:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*DatasetsCreateResponse) GetExtraProperties added in v2.8.2

func (d *DatasetsCreateResponse) GetExtraProperties() map[string]interface{}

func (*DatasetsCreateResponse) GetId added in v2.12.4

func (d *DatasetsCreateResponse) GetId() *string

func (*DatasetsCreateResponse) String added in v2.5.0

func (d *DatasetsCreateResponse) String() string

func (*DatasetsCreateResponse) UnmarshalJSON added in v2.5.0

func (d *DatasetsCreateResponse) UnmarshalJSON(data []byte) error

type DatasetsCreateResponseDatasetPartsItem added in v2.7.4

type DatasetsCreateResponseDatasetPartsItem struct {
	// the name of the dataset part
	Name *string `json:"name,omitempty" url:"name,omitempty"`
	// the number of rows in the dataset part
	NumRows *float64 `json:"num_rows,omitempty" url:"num_rows,omitempty"`
	Samples []string `json:"samples,omitempty" url:"samples,omitempty"`
	// the kind of dataset part
	PartKind *string `json:"part_kind,omitempty" url:"part_kind,omitempty"`
	// contains filtered or unexported fields
}

the underlying files that make up the dataset

func (*DatasetsCreateResponseDatasetPartsItem) GetExtraProperties added in v2.8.2

func (d *DatasetsCreateResponseDatasetPartsItem) GetExtraProperties() map[string]interface{}

func (*DatasetsCreateResponseDatasetPartsItem) GetName added in v2.12.4

func (*DatasetsCreateResponseDatasetPartsItem) GetNumRows added in v2.12.4

func (*DatasetsCreateResponseDatasetPartsItem) GetPartKind added in v2.12.4

func (*DatasetsCreateResponseDatasetPartsItem) GetSamples added in v2.12.4

func (*DatasetsCreateResponseDatasetPartsItem) String added in v2.7.4

func (*DatasetsCreateResponseDatasetPartsItem) UnmarshalJSON added in v2.7.4

func (d *DatasetsCreateResponseDatasetPartsItem) UnmarshalJSON(data []byte) error

type DatasetsGetResponse added in v2.2.0

type DatasetsGetResponse struct {
	Dataset *Dataset `json:"dataset,omitempty" url:"dataset,omitempty"`
	// contains filtered or unexported fields
}

func (*DatasetsGetResponse) GetDataset added in v2.12.4

func (d *DatasetsGetResponse) GetDataset() *Dataset

func (*DatasetsGetResponse) GetExtraProperties added in v2.8.2

func (d *DatasetsGetResponse) GetExtraProperties() map[string]interface{}

func (*DatasetsGetResponse) String added in v2.2.0

func (d *DatasetsGetResponse) String() string

func (*DatasetsGetResponse) UnmarshalJSON added in v2.2.0

func (d *DatasetsGetResponse) UnmarshalJSON(data []byte) error

type DatasetsGetUsageResponse added in v2.2.0

type DatasetsGetUsageResponse struct {
	// The total number of bytes used by the organization.
	OrganizationUsage *int64 `json:"organization_usage,omitempty" url:"organization_usage,omitempty"`
	// contains filtered or unexported fields
}

func (*DatasetsGetUsageResponse) GetExtraProperties added in v2.8.2

func (d *DatasetsGetUsageResponse) GetExtraProperties() map[string]interface{}

func (*DatasetsGetUsageResponse) GetOrganizationUsage added in v2.12.4

func (d *DatasetsGetUsageResponse) GetOrganizationUsage() *int64

func (*DatasetsGetUsageResponse) String added in v2.2.0

func (d *DatasetsGetUsageResponse) String() string

func (*DatasetsGetUsageResponse) UnmarshalJSON added in v2.2.0

func (d *DatasetsGetUsageResponse) UnmarshalJSON(data []byte) error

type DatasetsListRequest added in v2.2.0

type DatasetsListRequest struct {
	// optional filter by dataset type
	DatasetType *string `json:"-" url:"datasetType,omitempty"`
	// optional filter before a date
	Before *time.Time `json:"-" url:"before,omitempty"`
	// optional filter after a date
	After *time.Time `json:"-" url:"after,omitempty"`
	// optional limit to number of results
	Limit *float64 `json:"-" url:"limit,omitempty"`
	// optional offset to start of results
	Offset *float64 `json:"-" url:"offset,omitempty"`
	// optional filter by validation status
	ValidationStatus *DatasetValidationStatus `json:"-" url:"validationStatus,omitempty"`
}

type DatasetsListResponse added in v2.2.0

type DatasetsListResponse struct {
	Datasets []*Dataset `json:"datasets,omitempty" url:"datasets,omitempty"`
	// contains filtered or unexported fields
}

func (*DatasetsListResponse) GetDatasets added in v2.12.4

func (d *DatasetsListResponse) GetDatasets() []*Dataset

func (*DatasetsListResponse) GetExtraProperties added in v2.8.2

func (d *DatasetsListResponse) GetExtraProperties() map[string]interface{}

func (*DatasetsListResponse) String added in v2.2.0

func (d *DatasetsListResponse) String() string

func (*DatasetsListResponse) UnmarshalJSON added in v2.2.0

func (d *DatasetsListResponse) UnmarshalJSON(data []byte) error

type DeleteConnectorResponse added in v2.5.0

type DeleteConnectorResponse = map[string]interface{}

type DetokenizeRequest

type DetokenizeRequest struct {
	// The list of tokens to be detokenized.
	Tokens []int `json:"tokens,omitempty" url:"-"`
	// An optional parameter to provide the model name. This will ensure that the detokenization is done by the tokenizer used by that model.
	Model string `json:"model" url:"-"`
}

type DetokenizeResponse

type DetokenizeResponse struct {
	// A string representing the list of tokens.
	Text string   `json:"text" url:"text"`
	Meta *ApiMeta `json:"meta,omitempty" url:"meta,omitempty"`
	// contains filtered or unexported fields
}

func (*DetokenizeResponse) GetExtraProperties added in v2.8.2

func (d *DetokenizeResponse) GetExtraProperties() map[string]interface{}

func (*DetokenizeResponse) GetMeta added in v2.12.4

func (d *DetokenizeResponse) GetMeta() *ApiMeta

func (*DetokenizeResponse) GetText added in v2.12.4

func (d *DetokenizeResponse) GetText() string

func (*DetokenizeResponse) String

func (d *DetokenizeResponse) String() string

func (*DetokenizeResponse) UnmarshalJSON

func (d *DetokenizeResponse) UnmarshalJSON(data []byte) error

type Document added in v2.12.0

type Document struct {
	// A relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary.
	Data map[string]string `json:"data,omitempty" url:"data,omitempty"`
	// Unique identifier for this document which will be referenced in citations. If not provided an ID will be automatically generated.
	Id *string `json:"id,omitempty" url:"id,omitempty"`
	// contains filtered or unexported fields
}

Relevant information that could be used by the model to generate a more accurate reply. The content of each document are generally short (should be under 300 words). Metadata should be used to provide additional information, both the key name and the value will be passed to the model.

func (*Document) GetData added in v2.12.4

func (d *Document) GetData() map[string]string

func (*Document) GetExtraProperties added in v2.12.0

func (d *Document) GetExtraProperties() map[string]interface{}

func (*Document) GetId added in v2.12.4

func (d *Document) GetId() *string

func (*Document) String added in v2.12.0

func (d *Document) String() string

func (*Document) UnmarshalJSON added in v2.12.0

func (d *Document) UnmarshalJSON(data []byte) error

type DocumentContent added in v2.12.0

type DocumentContent struct {
	Document *Document `json:"document,omitempty" url:"document,omitempty"`
	// contains filtered or unexported fields
}

Document content.

func (*DocumentContent) GetDocument added in v2.12.4

func (d *DocumentContent) GetDocument() *Document

func (*DocumentContent) GetExtraProperties added in v2.12.0

func (d *DocumentContent) GetExtraProperties() map[string]interface{}

func (*DocumentContent) String added in v2.12.0

func (d *DocumentContent) String() string

func (*DocumentContent) UnmarshalJSON added in v2.12.0

func (d *DocumentContent) UnmarshalJSON(data []byte) error

type DocumentSource added in v2.12.0

type DocumentSource struct {
	// The unique identifier of the document
	Id       *string                `json:"id,omitempty" url:"id,omitempty"`
	Document map[string]interface{} `json:"document,omitempty" url:"document,omitempty"`
	// contains filtered or unexported fields
}

A document source object containing the unique identifier of the document and the document itself.

func (*DocumentSource) GetDocument added in v2.12.4

func (d *DocumentSource) GetDocument() map[string]interface{}

func (*DocumentSource) GetExtraProperties added in v2.12.0

func (d *DocumentSource) GetExtraProperties() map[string]interface{}

func (*DocumentSource) GetId added in v2.12.4

func (d *DocumentSource) GetId() *string

func (*DocumentSource) String added in v2.12.0

func (d *DocumentSource) String() string

func (*DocumentSource) UnmarshalJSON added in v2.12.0

func (d *DocumentSource) UnmarshalJSON(data []byte) error

type EmbedByTypeResponse added in v2.4.1

type EmbedByTypeResponse struct {
	Id string `json:"id" url:"id"`
	// An object with different embedding types. The length of each embedding type array will be the same as the length of the original `texts` array.
	Embeddings *EmbedByTypeResponseEmbeddings `json:"embeddings,omitempty" url:"embeddings,omitempty"`
	// The text entries for which embeddings were returned.
	Texts []string `json:"texts,omitempty" url:"texts,omitempty"`
	// The image entries for which embeddings were returned.
	Images []*Image `json:"images,omitempty" url:"images,omitempty"`
	Meta   *ApiMeta `json:"meta,omitempty" url:"meta,omitempty"`
	// contains filtered or unexported fields
}

func (*EmbedByTypeResponse) GetEmbeddings added in v2.12.4

func (*EmbedByTypeResponse) GetExtraProperties added in v2.8.2

func (e *EmbedByTypeResponse) GetExtraProperties() map[string]interface{}

func (*EmbedByTypeResponse) GetId added in v2.12.4

func (e *EmbedByTypeResponse) GetId() string

func (*EmbedByTypeResponse) GetImages added in v2.12.4

func (e *EmbedByTypeResponse) GetImages() []*Image

func (*EmbedByTypeResponse) GetMeta added in v2.12.4

func (e *EmbedByTypeResponse) GetMeta() *ApiMeta

func (*EmbedByTypeResponse) GetTexts added in v2.12.4

func (e *EmbedByTypeResponse) GetTexts() []string

func (*EmbedByTypeResponse) String added in v2.4.1

func (e *EmbedByTypeResponse) String() string

func (*EmbedByTypeResponse) UnmarshalJSON added in v2.4.1

func (e *EmbedByTypeResponse) UnmarshalJSON(data []byte) error

type EmbedByTypeResponseEmbeddings added in v2.4.1

type EmbedByTypeResponseEmbeddings struct {
	// An array of float embeddings.
	Float [][]float64 `json:"float,omitempty" url:"float,omitempty"`
	// An array of signed int8 embeddings. Each value is between -128 and 127.
	Int8 [][]int `json:"int8,omitempty" url:"int8,omitempty"`
	// An array of unsigned int8 embeddings. Each value is between 0 and 255.
	Uint8 [][]int `json:"uint8,omitempty" url:"uint8,omitempty"`
	// An array of packed signed binary embeddings. The length of each binary embedding is 1/8 the length of the float embeddings of the provided model. Each value is between -128 and 127.
	Binary [][]int `json:"binary,omitempty" url:"binary,omitempty"`
	// An array of packed unsigned binary embeddings. The length of each binary embedding is 1/8 the length of the float embeddings of the provided model. Each value is between 0 and 255.
	Ubinary [][]int `json:"ubinary,omitempty" url:"ubinary,omitempty"`
	// contains filtered or unexported fields
}

An object with different embedding types. The length of each embedding type array will be the same as the length of the original `texts` array.

func (*EmbedByTypeResponseEmbeddings) GetBinary added in v2.12.4

func (e *EmbedByTypeResponseEmbeddings) GetBinary() [][]int

func (*EmbedByTypeResponseEmbeddings) GetExtraProperties added in v2.8.2

func (e *EmbedByTypeResponseEmbeddings) GetExtraProperties() map[string]interface{}

func (*EmbedByTypeResponseEmbeddings) GetFloat added in v2.12.4

func (e *EmbedByTypeResponseEmbeddings) GetFloat() [][]float64

func (*EmbedByTypeResponseEmbeddings) GetInt8 added in v2.12.4

func (e *EmbedByTypeResponseEmbeddings) GetInt8() [][]int

func (*EmbedByTypeResponseEmbeddings) GetUbinary added in v2.12.4

func (e *EmbedByTypeResponseEmbeddings) GetUbinary() [][]int

func (*EmbedByTypeResponseEmbeddings) GetUint8 added in v2.12.4

func (e *EmbedByTypeResponseEmbeddings) GetUint8() [][]int

func (*EmbedByTypeResponseEmbeddings) String added in v2.4.1

func (*EmbedByTypeResponseEmbeddings) UnmarshalJSON added in v2.4.1

func (e *EmbedByTypeResponseEmbeddings) UnmarshalJSON(data []byte) error

type EmbedFloatsResponse added in v2.4.1

type EmbedFloatsResponse struct {
	Id string `json:"id" url:"id"`
	// An array of embeddings, where each embedding is an array of floats. The length of the `embeddings` array will be the same as the length of the original `texts` array.
	Embeddings [][]float64 `json:"embeddings,omitempty" url:"embeddings,omitempty"`
	// The text entries for which embeddings were returned.
	Texts []string `json:"texts,omitempty" url:"texts,omitempty"`
	// The image entries for which embeddings were returned.
	Images []*Image `json:"images,omitempty" url:"images,omitempty"`
	Meta   *ApiMeta `json:"meta,omitempty" url:"meta,omitempty"`
	// contains filtered or unexported fields
}

func (*EmbedFloatsResponse) GetEmbeddings added in v2.12.4

func (e *EmbedFloatsResponse) GetEmbeddings() [][]float64

func (*EmbedFloatsResponse) GetExtraProperties added in v2.8.2

func (e *EmbedFloatsResponse) GetExtraProperties() map[string]interface{}

func (*EmbedFloatsResponse) GetId added in v2.12.4

func (e *EmbedFloatsResponse) GetId() string

func (*EmbedFloatsResponse) GetImages added in v2.12.4

func (e *EmbedFloatsResponse) GetImages() []*Image

func (*EmbedFloatsResponse) GetMeta added in v2.12.4

func (e *EmbedFloatsResponse) GetMeta() *ApiMeta

func (*EmbedFloatsResponse) GetTexts added in v2.12.4

func (e *EmbedFloatsResponse) GetTexts() []string

func (*EmbedFloatsResponse) String added in v2.4.1

func (e *EmbedFloatsResponse) String() string

func (*EmbedFloatsResponse) UnmarshalJSON added in v2.4.1

func (e *EmbedFloatsResponse) UnmarshalJSON(data []byte) error

type EmbedInputType added in v2.5.0

type EmbedInputType string

Specifies the type of input passed to the model. Required for embedding models v3 and higher.

- `"search_document"`: Used for embeddings stored in a vector database for search use-cases. - `"search_query"`: Used for embeddings of search queries run against a vector DB to find relevant documents. - `"classification"`: Used for embeddings passed through a text classifier. - `"clustering"`: Used for the embeddings run through a clustering algorithm. - `"image"`: Used for embeddings with image input.

const (
	EmbedInputTypeSearchDocument EmbedInputType = "search_document"
	EmbedInputTypeSearchQuery    EmbedInputType = "search_query"
	EmbedInputTypeClassification EmbedInputType = "classification"
	EmbedInputTypeClustering     EmbedInputType = "clustering"
	EmbedInputTypeImage          EmbedInputType = "image"
)

func NewEmbedInputTypeFromString added in v2.5.0

func NewEmbedInputTypeFromString(s string) (EmbedInputType, error)

func (EmbedInputType) Ptr added in v2.5.0

func (e EmbedInputType) Ptr() *EmbedInputType

type EmbedJob added in v2.5.0

type EmbedJob struct {
	// ID of the embed job
	JobId string `json:"job_id" url:"job_id"`
	// The name of the embed job
	Name *string `json:"name,omitempty" url:"name,omitempty"`
	// The status of the embed job
	Status EmbedJobStatus `json:"status" url:"status"`
	// The creation date of the embed job
	CreatedAt time.Time `json:"created_at" url:"created_at"`
	// ID of the input dataset
	InputDatasetId string `json:"input_dataset_id" url:"input_dataset_id"`
	// ID of the resulting output dataset
	OutputDatasetId *string `json:"output_dataset_id,omitempty" url:"output_dataset_id,omitempty"`
	// ID of the model used to embed
	Model string `json:"model" url:"model"`
	// The truncation option used
	Truncate EmbedJobTruncate `json:"truncate" url:"truncate"`
	Meta     *ApiMeta         `json:"meta,omitempty" url:"meta,omitempty"`
	// contains filtered or unexported fields
}

func (*EmbedJob) GetCreatedAt added in v2.12.4

func (e *EmbedJob) GetCreatedAt() time.Time

func (*EmbedJob) GetExtraProperties added in v2.8.2

func (e *EmbedJob) GetExtraProperties() map[string]interface{}

func (*EmbedJob) GetInputDatasetId added in v2.12.4

func (e *EmbedJob) GetInputDatasetId() string

func (*EmbedJob) GetJobId added in v2.12.4

func (e *EmbedJob) GetJobId() string

func (*EmbedJob) GetMeta added in v2.12.4

func (e *EmbedJob) GetMeta() *ApiMeta

func (*EmbedJob) GetModel added in v2.12.4

func (e *EmbedJob) GetModel() string

func (*EmbedJob) GetName added in v2.12.4

func (e *EmbedJob) GetName() *string

func (*EmbedJob) GetOutputDatasetId added in v2.12.4

func (e *EmbedJob) GetOutputDatasetId() *string

func (*EmbedJob) GetStatus added in v2.12.4

func (e *EmbedJob) GetStatus() EmbedJobStatus

func (*EmbedJob) GetTruncate added in v2.12.4

func (e *EmbedJob) GetTruncate() EmbedJobTruncate

func (*EmbedJob) MarshalJSON added in v2.6.0

func (e *EmbedJob) MarshalJSON() ([]byte, error)

func (*EmbedJob) String added in v2.5.0

func (e *EmbedJob) String() string

func (*EmbedJob) UnmarshalJSON added in v2.5.0

func (e *EmbedJob) UnmarshalJSON(data []byte) error

type EmbedJobStatus added in v2.5.0

type EmbedJobStatus string

The status of the embed job

const (
	EmbedJobStatusProcessing EmbedJobStatus = "processing"
	EmbedJobStatusComplete   EmbedJobStatus = "complete"
	EmbedJobStatusCancelling EmbedJobStatus = "cancelling"
	EmbedJobStatusCancelled  EmbedJobStatus = "cancelled"
	EmbedJobStatusFailed     EmbedJobStatus = "failed"
)

func NewEmbedJobStatusFromString added in v2.5.0

func NewEmbedJobStatusFromString(s string) (EmbedJobStatus, error)

func (EmbedJobStatus) Ptr added in v2.5.0

func (e EmbedJobStatus) Ptr() *EmbedJobStatus

type EmbedJobTruncate added in v2.5.0

type EmbedJobTruncate string

The truncation option used

const (
	EmbedJobTruncateStart EmbedJobTruncate = "START"
	EmbedJobTruncateEnd   EmbedJobTruncate = "END"
)

func NewEmbedJobTruncateFromString added in v2.5.0

func NewEmbedJobTruncateFromString(s string) (EmbedJobTruncate, error)

func (EmbedJobTruncate) Ptr added in v2.5.0

type EmbedRequest

type EmbedRequest struct {
	// An array of strings for the model to embed. Maximum number of texts per call is `96`. We recommend reducing the length of each text to be under `512` tokens for optimal quality.
	Texts []string `json:"texts,omitempty" url:"-"`
	// An array of image data URIs for the model to embed. Maximum number of images per call is `1`.
	//
	// The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg` or `image/png` format and has a maximum size of 5MB.
	Images []string `json:"images,omitempty" url:"-"`
	// Defaults to embed-english-v2.0
	//
	// The identifier of the model. Smaller "light" models are faster, while larger models will perform better. [Custom models](https://docs.cohere.com/docs/training-custom-models) can also be supplied with their full ID.
	//
	// Available models and corresponding embedding dimensions:
	//
	// * `embed-english-v3.0`  1024
	// * `embed-multilingual-v3.0`  1024
	// * `embed-english-light-v3.0`  384
	// * `embed-multilingual-light-v3.0`  384
	//
	// * `embed-english-v2.0`  4096
	// * `embed-english-light-v2.0`  1024
	// * `embed-multilingual-v2.0`  768
	Model     *string         `json:"model,omitempty" url:"-"`
	InputType *EmbedInputType `json:"input_type,omitempty" url:"-"`
	// Specifies the types of embeddings you want to get back. Not required and default is None, which returns the Embed Floats response type. Can be one or more of the following types.
	//
	// * `"float"`: Use this when you want to get back the default float embeddings. Valid for all models.
	// * `"int8"`: Use this when you want to get back signed int8 embeddings. Valid for only v3 models.
	// * `"uint8"`: Use this when you want to get back unsigned int8 embeddings. Valid for only v3 models.
	// * `"binary"`: Use this when you want to get back signed binary embeddings. Valid for only v3 models.
	// * `"ubinary"`: Use this when you want to get back unsigned binary embeddings. Valid for only v3 models.
	EmbeddingTypes []EmbeddingType `json:"embedding_types,omitempty" url:"-"`
	// One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length.
	//
	// Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.
	//
	// If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.
	Truncate *EmbedRequestTruncate `json:"truncate,omitempty" url:"-"`
}

type EmbedRequestTruncate

type EmbedRequestTruncate string

One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length.

Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.

const (
	EmbedRequestTruncateNone  EmbedRequestTruncate = "NONE"
	EmbedRequestTruncateStart EmbedRequestTruncate = "START"
	EmbedRequestTruncateEnd   EmbedRequestTruncate = "END"
)

func NewEmbedRequestTruncateFromString

func NewEmbedRequestTruncateFromString(s string) (EmbedRequestTruncate, error)

func (EmbedRequestTruncate) Ptr

type EmbedResponse

type EmbedResponse struct {
	ResponseType     string
	EmbeddingsFloats *EmbedFloatsResponse
	EmbeddingsByType *EmbedByTypeResponse
}

func (*EmbedResponse) Accept added in v2.4.1

func (e *EmbedResponse) Accept(visitor EmbedResponseVisitor) error

func (*EmbedResponse) GetEmbeddingsByType added in v2.12.4

func (e *EmbedResponse) GetEmbeddingsByType() *EmbedByTypeResponse

func (*EmbedResponse) GetEmbeddingsFloats added in v2.12.4

func (e *EmbedResponse) GetEmbeddingsFloats() *EmbedFloatsResponse

func (*EmbedResponse) GetResponseType added in v2.12.4

func (e *EmbedResponse) GetResponseType() string

func (EmbedResponse) MarshalJSON added in v2.4.1

func (e EmbedResponse) MarshalJSON() ([]byte, error)

func (*EmbedResponse) UnmarshalJSON

func (e *EmbedResponse) UnmarshalJSON(data []byte) error

type EmbedResponseVisitor added in v2.4.1

type EmbedResponseVisitor interface {
	VisitEmbeddingsFloats(*EmbedFloatsResponse) error
	VisitEmbeddingsByType(*EmbedByTypeResponse) error
}

type EmbeddingType added in v2.7.1

type EmbeddingType string
const (
	EmbeddingTypeFloat   EmbeddingType = "float"
	EmbeddingTypeInt8    EmbeddingType = "int8"
	EmbeddingTypeUint8   EmbeddingType = "uint8"
	EmbeddingTypeBinary  EmbeddingType = "binary"
	EmbeddingTypeUbinary EmbeddingType = "ubinary"
)

func NewEmbeddingTypeFromString added in v2.7.1

func NewEmbeddingTypeFromString(s string) (EmbeddingType, error)

func (EmbeddingType) Ptr added in v2.7.1

func (e EmbeddingType) Ptr() *EmbeddingType

type FileParam added in v2.12.4

type FileParam struct {
	io.Reader
	// contains filtered or unexported fields
}

FileParam is a file type suitable for multipart/form-data uploads.

func NewFileParam added in v2.12.4

func NewFileParam(
	reader io.Reader,
	filename string,
	contentType string,
	opts ...FileParamOption,
) *FileParam

NewFileParam returns a *FileParam type suitable for multipart/form-data uploads. All file upload endpoints accept a simple io.Reader, which is usually created by opening a file via os.Open.

However, some endpoints require additional metadata about the file such as a specific Content-Type or custom filename. FileParam makes it easier to create the correct type signature for these endpoints.

func (*FileParam) ContentType added in v2.12.4

func (f *FileParam) ContentType() string

func (*FileParam) Name added in v2.12.4

func (f *FileParam) Name() string

type FileParamOption added in v2.12.4

type FileParamOption interface {
	// contains filtered or unexported methods
}

FileParamOption adapts the behavior of the FileParam. No options are implemented yet, but this interface allows for future extensibility.

type FinetuneDatasetMetrics added in v2.6.0

type FinetuneDatasetMetrics struct {
	// The number of tokens of valid examples that can be used for training.
	TrainableTokenCount *int64 `json:"trainable_token_count,omitempty" url:"trainable_token_count,omitempty"`
	// The overall number of examples.
	TotalExamples *int64 `json:"total_examples,omitempty" url:"total_examples,omitempty"`
	// The number of training examples.
	TrainExamples *int64 `json:"train_examples,omitempty" url:"train_examples,omitempty"`
	// The size in bytes of all training examples.
	TrainSizeBytes *int64 `json:"train_size_bytes,omitempty" url:"train_size_bytes,omitempty"`
	// Number of evaluation examples.
	EvalExamples *int64 `json:"eval_examples,omitempty" url:"eval_examples,omitempty"`
	// The size in bytes of all eval examples.
	EvalSizeBytes *int64 `json:"eval_size_bytes,omitempty" url:"eval_size_bytes,omitempty"`
	// contains filtered or unexported fields
}

func (*FinetuneDatasetMetrics) GetEvalExamples added in v2.12.4

func (f *FinetuneDatasetMetrics) GetEvalExamples() *int64

func (*FinetuneDatasetMetrics) GetEvalSizeBytes added in v2.12.4

func (f *FinetuneDatasetMetrics) GetEvalSizeBytes() *int64

func (*FinetuneDatasetMetrics) GetExtraProperties added in v2.8.2

func (f *FinetuneDatasetMetrics) GetExtraProperties() map[string]interface{}

func (*FinetuneDatasetMetrics) GetTotalExamples added in v2.12.4

func (f *FinetuneDatasetMetrics) GetTotalExamples() *int64

func (*FinetuneDatasetMetrics) GetTrainExamples added in v2.12.4

func (f *FinetuneDatasetMetrics) GetTrainExamples() *int64

func (*FinetuneDatasetMetrics) GetTrainSizeBytes added in v2.12.4

func (f *FinetuneDatasetMetrics) GetTrainSizeBytes() *int64

func (*FinetuneDatasetMetrics) GetTrainableTokenCount added in v2.12.4

func (f *FinetuneDatasetMetrics) GetTrainableTokenCount() *int64

func (*FinetuneDatasetMetrics) String added in v2.6.0

func (f *FinetuneDatasetMetrics) String() string

func (*FinetuneDatasetMetrics) UnmarshalJSON added in v2.6.0

func (f *FinetuneDatasetMetrics) UnmarshalJSON(data []byte) error

type FinetuningListEventsRequest added in v2.7.0

type FinetuningListEventsRequest struct {
	// Maximum number of results to be returned by the server. If 0, defaults to
	// 50.
	PageSize *int `json:"-" url:"page_size,omitempty"`
	// Request a specific page of the list results.
	PageToken *string `json:"-" url:"page_token,omitempty"`
	// Comma separated list of fields. For example: "created_at,name". The default
	// sorting order is ascending. To specify descending order for a field, append
	// " desc" to the field name. For example: "created_at desc,name".
	//
	// Supported sorting fields:
	//   - created_at (default)
	OrderBy *string `json:"-" url:"order_by,omitempty"`
}

type FinetuningListFinetunedModelsRequest added in v2.7.0

type FinetuningListFinetunedModelsRequest struct {
	// Maximum number of results to be returned by the server. If 0, defaults to
	// 50.
	PageSize *int `json:"-" url:"page_size,omitempty"`
	// Request a specific page of the list results.
	PageToken *string `json:"-" url:"page_token,omitempty"`
	// Comma separated list of fields. For example: "created_at,name". The default
	// sorting order is ascending. To specify descending order for a field, append
	// " desc" to the field name. For example: "created_at desc,name".
	//
	// Supported sorting fields:
	//   - created_at (default)
	OrderBy *string `json:"-" url:"order_by,omitempty"`
}

type FinetuningListTrainingStepMetricsRequest added in v2.7.0

type FinetuningListTrainingStepMetricsRequest struct {
	// Maximum number of results to be returned by the server. If 0, defaults to
	// 50.
	PageSize *int `json:"-" url:"page_size,omitempty"`
	// Request a specific page of the list results.
	PageToken *string `json:"-" url:"page_token,omitempty"`
}

type FinetuningUpdateFinetunedModelRequest added in v2.7.0

type FinetuningUpdateFinetunedModelRequest struct {
	// FinetunedModel name (e.g. `foobar`).
	Name string `json:"name" url:"-"`
	// User ID of the creator.
	CreatorId *string `json:"creator_id,omitempty" url:"-"`
	// Organization ID.
	OrganizationId *string `json:"organization_id,omitempty" url:"-"`
	// FinetunedModel settings such as dataset, hyperparameters...
	Settings *finetuning.Settings `json:"settings,omitempty" url:"-"`
	// Current stage in the life-cycle of the fine-tuned model.
	Status *finetuning.Status `json:"status,omitempty" url:"-"`
	// Creation timestamp.
	CreatedAt *time.Time `json:"created_at,omitempty" url:"-"`
	// Latest update timestamp.
	UpdatedAt *time.Time `json:"updated_at,omitempty" url:"-"`
	// Timestamp for the completed fine-tuning.
	CompletedAt *time.Time `json:"completed_at,omitempty" url:"-"`
	// Deprecated: Timestamp for the latest request to this fine-tuned model.
	LastUsed *time.Time `json:"last_used,omitempty" url:"-"`
}

func (*FinetuningUpdateFinetunedModelRequest) MarshalJSON added in v2.7.0

func (f *FinetuningUpdateFinetunedModelRequest) MarshalJSON() ([]byte, error)

func (*FinetuningUpdateFinetunedModelRequest) UnmarshalJSON added in v2.7.0

func (f *FinetuningUpdateFinetunedModelRequest) UnmarshalJSON(data []byte) error

type FinishReason

type FinishReason string
const (
	FinishReasonComplete     FinishReason = "COMPLETE"
	FinishReasonStopSequence FinishReason = "STOP_SEQUENCE"
	FinishReasonError        FinishReason = "ERROR"
	FinishReasonErrorToxic   FinishReason = "ERROR_TOXIC"
	FinishReasonErrorLimit   FinishReason = "ERROR_LIMIT"
	FinishReasonUserCancel   FinishReason = "USER_CANCEL"
	FinishReasonMaxTokens    FinishReason = "MAX_TOKENS"
)

func NewFinishReasonFromString

func NewFinishReasonFromString(s string) (FinishReason, error)

func (FinishReason) Ptr

func (f FinishReason) Ptr() *FinishReason

type ForbiddenError added in v2.2.0

type ForbiddenError struct {
	*core.APIError
	Body interface{}
}

This error indicates that the operation attempted to be performed is not allowed. This could be because:

  • The api token is invalid
  • The user does not have the necessary permissions

func (*ForbiddenError) MarshalJSON added in v2.2.0

func (f *ForbiddenError) MarshalJSON() ([]byte, error)

func (*ForbiddenError) UnmarshalJSON added in v2.2.0

func (f *ForbiddenError) UnmarshalJSON(data []byte) error

func (*ForbiddenError) Unwrap added in v2.2.0

func (f *ForbiddenError) Unwrap() error

type GatewayTimeoutError added in v2.8.2

type GatewayTimeoutError struct {
	*core.APIError
	Body interface{}
}

This error is returned when a request to the server times out. This could be due to:

  • An internal services taking too long to respond

func (*GatewayTimeoutError) MarshalJSON added in v2.8.2

func (g *GatewayTimeoutError) MarshalJSON() ([]byte, error)

func (*GatewayTimeoutError) UnmarshalJSON added in v2.8.2

func (g *GatewayTimeoutError) UnmarshalJSON(data []byte) error

func (*GatewayTimeoutError) Unwrap added in v2.8.2

func (g *GatewayTimeoutError) Unwrap() error

type GenerateRequest

type GenerateRequest struct {
	// The input text that serves as the starting point for generating the response.
	// Note: The prompt will be pre-processed and modified before reaching the model.
	Prompt string `json:"prompt" url:"-"`
	// The identifier of the model to generate with. Currently available models are `command` (default), `command-nightly` (experimental), `command-light`, and `command-light-nightly` (experimental).
	// Smaller, "light" models are faster, while larger models will perform better. [Custom models](https://docs.cohere.com/docs/training-custom-models) can also be supplied with their full ID.
	Model *string `json:"model,omitempty" url:"-"`
	// The maximum number of generations that will be returned. Defaults to `1`, min value of `1`, max value of `5`.
	NumGenerations *int `json:"num_generations,omitempty" url:"-"`
	// When `true`, the response will be a JSON stream of events. Streaming is beneficial for user interfaces that render the contents of the response piece by piece, as it gets generated.
	//
	// The final event will contain the complete response, and will contain an `is_finished` field set to `true`. The event will also contain a `finish_reason`, which can be one of the following:
	// - `COMPLETE` - the model sent back a finished reply
	// - `MAX_TOKENS` - the reply was cut off because the model reached the maximum number of tokens for its context length
	// - `ERROR` - something went wrong when generating the reply
	// - `ERROR_TOXIC` - the model generated a reply that was deemed toxic
	//
	// The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations.
	//
	// This parameter is off by default, and if it's not specified, the model will continue generating until it emits an EOS completion token. See [BPE Tokens](/bpe-tokens-wiki) for more details.
	//
	// Can only be set to `0` if `return_likelihoods` is set to `ALL` to get the likelihood of the prompt.
	MaxTokens *int `json:"max_tokens,omitempty" url:"-"`
	// One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length.
	//
	// Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.
	//
	// If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.
	Truncate *GenerateRequestTruncate `json:"truncate,omitempty" url:"-"`
	// A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations. See [Temperature](/temperature-wiki) for more details.
	// Defaults to `0.75`, min value of `0.0`, max value of `5.0`.
	Temperature *float64 `json:"temperature,omitempty" url:"-"`
	// If specified, the backend will make a best effort to sample tokens
	// deterministically, such that repeated requests with the same
	// seed and parameters should return the same result. However,
	// determinism cannot be totally guaranteed.
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Seed *int `json:"seed,omitempty" url:"-"`
	// Identifier of a custom preset. A preset is a combination of parameters, such as prompt, temperature etc. You can create presets in the [playground](https://dashboard.cohere.com/playground/generate).
	// When a preset is specified, the `prompt` parameter becomes optional, and any included parameters will override the preset's parameters.
	Preset *string `json:"preset,omitempty" url:"-"`
	// The generated text will be cut at the beginning of the earliest occurrence of an end sequence. The sequence will be excluded from the text.
	EndSequences []string `json:"end_sequences,omitempty" url:"-"`
	// The generated text will be cut at the end of the earliest occurrence of a stop sequence. The sequence will be included the text.
	StopSequences []string `json:"stop_sequences,omitempty" url:"-"`
	// Ensures only the top `k` most likely tokens are considered for generation at each step.
	// Defaults to `0`, min value of `0`, max value of `500`.
	K *int `json:"k,omitempty" url:"-"`
	// Ensures that only the most likely tokens, with total probability mass of `p`, are considered for generation at each step. If both `k` and `p` are enabled, `p` acts after `k`.
	// Defaults to `0.75`. min value of `0.01`, max value of `0.99`.
	P *float64 `json:"p,omitempty" url:"-"`
	// Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.
	//
	// Using `frequency_penalty` in combination with `presence_penalty` is not supported on newer models.
	FrequencyPenalty *float64 `json:"frequency_penalty,omitempty" url:"-"`
	// Defaults to `0.0`, min value of `0.0`, max value of `1.0`.
	//
	// Can be used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.
	//
	// Using `frequency_penalty` in combination with `presence_penalty` is not supported on newer models.
	PresencePenalty *float64 `json:"presence_penalty,omitempty" url:"-"`
	// One of `GENERATION|NONE` to specify how and if the token likelihoods are returned with the response. Defaults to `NONE`.
	//
	// If `GENERATION` is selected, the token likelihoods will only be provided for generated text.
	//
	// WARNING: `ALL` is deprecated, and will be removed in a future release.
	ReturnLikelihoods *GenerateRequestReturnLikelihoods `json:"return_likelihoods,omitempty" url:"-"`
	// When enabled, the user's prompt will be sent to the model without any pre-processing.
	RawPrompting *bool `json:"raw_prompting,omitempty" url:"-"`
	// contains filtered or unexported fields
}

func (*GenerateRequest) MarshalJSON added in v2.5.1

func (g *GenerateRequest) MarshalJSON() ([]byte, error)

func (*GenerateRequest) Stream

func (g *GenerateRequest) Stream() bool

func (*GenerateRequest) UnmarshalJSON added in v2.5.1

func (g *GenerateRequest) UnmarshalJSON(data []byte) error

type GenerateRequestReturnLikelihoods

type GenerateRequestReturnLikelihoods string

One of `GENERATION|NONE` to specify how and if the token likelihoods are returned with the response. Defaults to `NONE`.

If `GENERATION` is selected, the token likelihoods will only be provided for generated text.

WARNING: `ALL` is deprecated, and will be removed in a future release.

const (
	GenerateRequestReturnLikelihoodsGeneration GenerateRequestReturnLikelihoods = "GENERATION"
	GenerateRequestReturnLikelihoodsAll        GenerateRequestReturnLikelihoods = "ALL"
	GenerateRequestReturnLikelihoodsNone       GenerateRequestReturnLikelihoods = "NONE"
)

func NewGenerateRequestReturnLikelihoodsFromString

func NewGenerateRequestReturnLikelihoodsFromString(s string) (GenerateRequestReturnLikelihoods, error)

func (GenerateRequestReturnLikelihoods) Ptr

type GenerateRequestTruncate

type GenerateRequestTruncate string

One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length.

Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.

const (
	GenerateRequestTruncateNone  GenerateRequestTruncate = "NONE"
	GenerateRequestTruncateStart GenerateRequestTruncate = "START"
	GenerateRequestTruncateEnd   GenerateRequestTruncate = "END"
)

func NewGenerateRequestTruncateFromString

func NewGenerateRequestTruncateFromString(s string) (GenerateRequestTruncate, error)

func (GenerateRequestTruncate) Ptr

type GenerateStreamEnd added in v2.5.0

type GenerateStreamEnd struct {
	IsFinished   bool                       `json:"is_finished" url:"is_finished"`
	FinishReason *FinishReason              `json:"finish_reason,omitempty" url:"finish_reason,omitempty"`
	Response     *GenerateStreamEndResponse `json:"response,omitempty" url:"response,omitempty"`
	// contains filtered or unexported fields
}

func (*GenerateStreamEnd) GetExtraProperties added in v2.8.2

func (g *GenerateStreamEnd) GetExtraProperties() map[string]interface{}

func (*GenerateStreamEnd) GetFinishReason added in v2.12.4

func (g *GenerateStreamEnd) GetFinishReason() *FinishReason

func (*GenerateStreamEnd) GetIsFinished added in v2.12.4

func (g *GenerateStreamEnd) GetIsFinished() bool

func (*GenerateStreamEnd) GetResponse added in v2.12.4

func (g *GenerateStreamEnd) GetResponse() *GenerateStreamEndResponse

func (*GenerateStreamEnd) String added in v2.5.0

func (g *GenerateStreamEnd) String() string

func (*GenerateStreamEnd) UnmarshalJSON added in v2.5.0

func (g *GenerateStreamEnd) UnmarshalJSON(data []byte) error

type GenerateStreamEndResponse added in v2.5.0

type GenerateStreamEndResponse struct {
	Id          string                      `json:"id" url:"id"`
	Prompt      *string                     `json:"prompt,omitempty" url:"prompt,omitempty"`
	Generations []*SingleGenerationInStream `json:"generations,omitempty" url:"generations,omitempty"`
	// contains filtered or unexported fields
}

func (*GenerateStreamEndResponse) GetExtraProperties added in v2.8.2

func (g *GenerateStreamEndResponse) GetExtraProperties() map[string]interface{}

func (*GenerateStreamEndResponse) GetGenerations added in v2.12.4

func (g *GenerateStreamEndResponse) GetGenerations() []*SingleGenerationInStream

func (*GenerateStreamEndResponse) GetId added in v2.12.4

func (g *GenerateStreamEndResponse) GetId() string

func (*GenerateStreamEndResponse) GetPrompt added in v2.12.4

func (g *GenerateStreamEndResponse) GetPrompt() *string

func (*GenerateStreamEndResponse) String added in v2.5.0

func (g *GenerateStreamEndResponse) String() string

func (*GenerateStreamEndResponse) UnmarshalJSON added in v2.5.0

func (g *GenerateStreamEndResponse) UnmarshalJSON(data []byte) error

type GenerateStreamError added in v2.5.0

type GenerateStreamError struct {
	// Refers to the nth generation. Only present when `num_generations` is greater than zero.
	Index        *int         `json:"index,omitempty" url:"index,omitempty"`
	IsFinished   bool         `json:"is_finished" url:"is_finished"`
	FinishReason FinishReason `json:"finish_reason" url:"finish_reason"`
	// Error message
	Err string `json:"err" url:"err"`
	// contains filtered or unexported fields
}

func (*GenerateStreamError) GetErr added in v2.12.4

func (g *GenerateStreamError) GetErr() string

func (*GenerateStreamError) GetExtraProperties added in v2.8.2

func (g *GenerateStreamError) GetExtraProperties() map[string]interface{}

func (*GenerateStreamError) GetFinishReason added in v2.12.4

func (g *GenerateStreamError) GetFinishReason() FinishReason

func (*GenerateStreamError) GetIndex added in v2.12.4

func (g *GenerateStreamError) GetIndex() *int

func (*GenerateStreamError) GetIsFinished added in v2.12.4

func (g *GenerateStreamError) GetIsFinished() bool

func (*GenerateStreamError) String added in v2.5.0

func (g *GenerateStreamError) String() string

func (*GenerateStreamError) UnmarshalJSON added in v2.5.0

func (g *GenerateStreamError) UnmarshalJSON(data []byte) error

type GenerateStreamEvent added in v2.5.0

type GenerateStreamEvent struct {
	// contains filtered or unexported fields
}

func (*GenerateStreamEvent) GetExtraProperties added in v2.8.2

func (g *GenerateStreamEvent) GetExtraProperties() map[string]interface{}

func (*GenerateStreamEvent) String added in v2.5.0

func (g *GenerateStreamEvent) String() string

func (*GenerateStreamEvent) UnmarshalJSON added in v2.5.0

func (g *GenerateStreamEvent) UnmarshalJSON(data []byte) error

type GenerateStreamRequest added in v2.5.0

type GenerateStreamRequest struct {
	// The input text that serves as the starting point for generating the response.
	// Note: The prompt will be pre-processed and modified before reaching the model.
	Prompt string `json:"prompt" url:"-"`
	// The identifier of the model to generate with. Currently available models are `command` (default), `command-nightly` (experimental), `command-light`, and `command-light-nightly` (experimental).
	// Smaller, "light" models are faster, while larger models will perform better. [Custom models](https://docs.cohere.com/docs/training-custom-models) can also be supplied with their full ID.
	Model *string `json:"model,omitempty" url:"-"`
	// The maximum number of generations that will be returned. Defaults to `1`, min value of `1`, max value of `5`.
	NumGenerations *int `json:"num_generations,omitempty" url:"-"`
	// When `true`, the response will be a JSON stream of events. Streaming is beneficial for user interfaces that render the contents of the response piece by piece, as it gets generated.
	//
	// The final event will contain the complete response, and will contain an `is_finished` field set to `true`. The event will also contain a `finish_reason`, which can be one of the following:
	// - `COMPLETE` - the model sent back a finished reply
	// - `MAX_TOKENS` - the reply was cut off because the model reached the maximum number of tokens for its context length
	// - `ERROR` - something went wrong when generating the reply
	// - `ERROR_TOXIC` - the model generated a reply that was deemed toxic
	//
	// The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations.
	//
	// This parameter is off by default, and if it's not specified, the model will continue generating until it emits an EOS completion token. See [BPE Tokens](/bpe-tokens-wiki) for more details.
	//
	// Can only be set to `0` if `return_likelihoods` is set to `ALL` to get the likelihood of the prompt.
	MaxTokens *int `json:"max_tokens,omitempty" url:"-"`
	// One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length.
	//
	// Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.
	//
	// If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.
	Truncate *GenerateStreamRequestTruncate `json:"truncate,omitempty" url:"-"`
	// A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations. See [Temperature](/temperature-wiki) for more details.
	// Defaults to `0.75`, min value of `0.0`, max value of `5.0`.
	Temperature *float64 `json:"temperature,omitempty" url:"-"`
	// If specified, the backend will make a best effort to sample tokens
	// deterministically, such that repeated requests with the same
	// seed and parameters should return the same result. However,
	// determinism cannot be totally guaranteed.
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	Seed *int `json:"seed,omitempty" url:"-"`
	// Identifier of a custom preset. A preset is a combination of parameters, such as prompt, temperature etc. You can create presets in the [playground](https://dashboard.cohere.com/playground/generate).
	// When a preset is specified, the `prompt` parameter becomes optional, and any included parameters will override the preset's parameters.
	Preset *string `json:"preset,omitempty" url:"-"`
	// The generated text will be cut at the beginning of the earliest occurrence of an end sequence. The sequence will be excluded from the text.
	EndSequences []string `json:"end_sequences,omitempty" url:"-"`
	// The generated text will be cut at the end of the earliest occurrence of a stop sequence. The sequence will be included the text.
	StopSequences []string `json:"stop_sequences,omitempty" url:"-"`
	// Ensures only the top `k` most likely tokens are considered for generation at each step.
	// Defaults to `0`, min value of `0`, max value of `500`.
	K *int `json:"k,omitempty" url:"-"`
	// Ensures that only the most likely tokens, with total probability mass of `p`, are considered for generation at each step. If both `k` and `p` are enabled, `p` acts after `k`.
	// Defaults to `0.75`. min value of `0.01`, max value of `0.99`.
	P *float64 `json:"p,omitempty" url:"-"`
	// Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.
	//
	// Using `frequency_penalty` in combination with `presence_penalty` is not supported on newer models.
	FrequencyPenalty *float64 `json:"frequency_penalty,omitempty" url:"-"`
	// Defaults to `0.0`, min value of `0.0`, max value of `1.0`.
	//
	// Can be used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.
	//
	// Using `frequency_penalty` in combination with `presence_penalty` is not supported on newer models.
	PresencePenalty *float64 `json:"presence_penalty,omitempty" url:"-"`
	// One of `GENERATION|NONE` to specify how and if the token likelihoods are returned with the response. Defaults to `NONE`.
	//
	// If `GENERATION` is selected, the token likelihoods will only be provided for generated text.
	//
	// WARNING: `ALL` is deprecated, and will be removed in a future release.
	ReturnLikelihoods *GenerateStreamRequestReturnLikelihoods `json:"return_likelihoods,omitempty" url:"-"`
	// When enabled, the user's prompt will be sent to the model without any pre-processing.
	RawPrompting *bool `json:"raw_prompting,omitempty" url:"-"`
	// contains filtered or unexported fields
}

func (*GenerateStreamRequest) MarshalJSON added in v2.5.1

func (g *GenerateStreamRequest) MarshalJSON() ([]byte, error)

func (*GenerateStreamRequest) Stream added in v2.5.1

func (g *GenerateStreamRequest) Stream() bool

func (*GenerateStreamRequest) UnmarshalJSON added in v2.5.1

func (g *GenerateStreamRequest) UnmarshalJSON(data []byte) error

type GenerateStreamRequestReturnLikelihoods added in v2.5.0

type GenerateStreamRequestReturnLikelihoods string

One of `GENERATION|NONE` to specify how and if the token likelihoods are returned with the response. Defaults to `NONE`.

If `GENERATION` is selected, the token likelihoods will only be provided for generated text.

WARNING: `ALL` is deprecated, and will be removed in a future release.

const (
	GenerateStreamRequestReturnLikelihoodsGeneration GenerateStreamRequestReturnLikelihoods = "GENERATION"
	GenerateStreamRequestReturnLikelihoodsAll        GenerateStreamRequestReturnLikelihoods = "ALL"
	GenerateStreamRequestReturnLikelihoodsNone       GenerateStreamRequestReturnLikelihoods = "NONE"
)

func NewGenerateStreamRequestReturnLikelihoodsFromString added in v2.5.0

func NewGenerateStreamRequestReturnLikelihoodsFromString(s string) (GenerateStreamRequestReturnLikelihoods, error)

func (GenerateStreamRequestReturnLikelihoods) Ptr added in v2.5.0

type GenerateStreamRequestTruncate added in v2.5.0

type GenerateStreamRequestTruncate string

One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length.

Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.

const (
	GenerateStreamRequestTruncateNone  GenerateStreamRequestTruncate = "NONE"
	GenerateStreamRequestTruncateStart GenerateStreamRequestTruncate = "START"
	GenerateStreamRequestTruncateEnd   GenerateStreamRequestTruncate = "END"
)

func NewGenerateStreamRequestTruncateFromString added in v2.5.0

func NewGenerateStreamRequestTruncateFromString(s string) (GenerateStreamRequestTruncate, error)

func (GenerateStreamRequestTruncate) Ptr added in v2.5.0

type GenerateStreamText added in v2.5.0

type GenerateStreamText struct {
	// A segment of text of the generation.
	Text string `json:"text" url:"text"`
	// Refers to the nth generation. Only present when `num_generations` is greater than zero, and only when text responses are being streamed.
	Index      *int `json:"index,omitempty" url:"index,omitempty"`
	IsFinished bool `json:"is_finished" url:"is_finished"`
	// contains filtered or unexported fields
}

func (*GenerateStreamText) GetExtraProperties added in v2.8.2

func (g *GenerateStreamText) GetExtraProperties() map[string]interface{}

func (*GenerateStreamText) GetIndex added in v2.12.4

func (g *GenerateStreamText) GetIndex() *int

func (*GenerateStreamText) GetIsFinished added in v2.12.4

func (g *GenerateStreamText) GetIsFinished() bool

func (*GenerateStreamText) GetText added in v2.12.4

func (g *GenerateStreamText) GetText() string

func (*GenerateStreamText) String added in v2.5.0

func (g *GenerateStreamText) String() string

func (*GenerateStreamText) UnmarshalJSON added in v2.5.0

func (g *GenerateStreamText) UnmarshalJSON(data []byte) error

type GenerateStreamedResponse added in v2.5.0

type GenerateStreamedResponse struct {
	EventType      string
	TextGeneration *GenerateStreamText
	StreamEnd      *GenerateStreamEnd
	StreamError    *GenerateStreamError
}

Response in content type stream when `stream` is `true` in the request parameters. Generation tokens are streamed with the GenerationStream response. The final response is of type GenerationFinalResponse.

func (*GenerateStreamedResponse) Accept added in v2.5.0

func (*GenerateStreamedResponse) GetEventType added in v2.12.4

func (g *GenerateStreamedResponse) GetEventType() string

func (*GenerateStreamedResponse) GetStreamEnd added in v2.12.4

func (g *GenerateStreamedResponse) GetStreamEnd() *GenerateStreamEnd

func (*GenerateStreamedResponse) GetStreamError added in v2.12.4

func (g *GenerateStreamedResponse) GetStreamError() *GenerateStreamError

func (*GenerateStreamedResponse) GetTextGeneration added in v2.12.4

func (g *GenerateStreamedResponse) GetTextGeneration() *GenerateStreamText

func (GenerateStreamedResponse) MarshalJSON added in v2.5.0

func (g GenerateStreamedResponse) MarshalJSON() ([]byte, error)

func (*GenerateStreamedResponse) UnmarshalJSON added in v2.5.0

func (g *GenerateStreamedResponse) UnmarshalJSON(data []byte) error

type GenerateStreamedResponseVisitor added in v2.5.0

type GenerateStreamedResponseVisitor interface {
	VisitTextGeneration(*GenerateStreamText) error
	VisitStreamEnd(*GenerateStreamEnd) error
	VisitStreamError(*GenerateStreamError) error
}

type Generation

type Generation struct {
	Id string `json:"id" url:"id"`
	// Prompt used for generations.
	Prompt *string `json:"prompt,omitempty" url:"prompt,omitempty"`
	// List of generated results
	Generations []*SingleGeneration `json:"generations,omitempty" url:"generations,omitempty"`
	Meta        *ApiMeta            `json:"meta,omitempty" url:"meta,omitempty"`
	// contains filtered or unexported fields
}

func (*Generation) GetExtraProperties added in v2.8.2

func (g *Generation) GetExtraProperties() map[string]interface{}

func (*Generation) GetGenerations added in v2.12.4

func (g *Generation) GetGenerations() []*SingleGeneration

func (*Generation) GetId added in v2.12.4

func (g *Generation) GetId() string

func (*Generation) GetMeta added in v2.12.4

func (g *Generation) GetMeta() *ApiMeta

func (*Generation) GetPrompt added in v2.12.4

func (g *Generation) GetPrompt() *string

func (*Generation) String

func (g *Generation) String() string

func (*Generation) UnmarshalJSON

func (g *Generation) UnmarshalJSON(data []byte) error

type GetConnectorResponse added in v2.5.0

type GetConnectorResponse struct {
	Connector *Connector `json:"connector,omitempty" url:"connector,omitempty"`
	// contains filtered or unexported fields
}

func (*GetConnectorResponse) GetConnector added in v2.12.4

func (g *GetConnectorResponse) GetConnector() *Connector

func (*GetConnectorResponse) GetExtraProperties added in v2.8.2

func (g *GetConnectorResponse) GetExtraProperties() map[string]interface{}

func (*GetConnectorResponse) String added in v2.5.0

func (g *GetConnectorResponse) String() string

func (*GetConnectorResponse) UnmarshalJSON added in v2.5.0

func (g *GetConnectorResponse) UnmarshalJSON(data []byte) error

type GetModelResponse added in v2.7.1

type GetModelResponse struct {
	// Specify this name in the `model` parameter of API requests to use your chosen model.
	Name *string `json:"name,omitempty" url:"name,omitempty"`
	// The API endpoints that the model is compatible with.
	Endpoints []CompatibleEndpoint `json:"endpoints,omitempty" url:"endpoints,omitempty"`
	// Whether the model has been fine-tuned or not.
	Finetuned *bool `json:"finetuned,omitempty" url:"finetuned,omitempty"`
	// The maximum number of tokens that the model can process in a single request. Note that not all of these tokens are always available due to special tokens and preambles that Cohere has added by default.
	ContextLength *float64 `json:"context_length,omitempty" url:"context_length,omitempty"`
	// Public URL to the tokenizer's configuration file.
	TokenizerUrl *string `json:"tokenizer_url,omitempty" url:"tokenizer_url,omitempty"`
	// The API endpoints that the model is default to.
	DefaultEndpoints []CompatibleEndpoint `json:"default_endpoints,omitempty" url:"default_endpoints,omitempty"`
	// contains filtered or unexported fields
}

Contains information about the model and which API endpoints it can be used with.

func (*GetModelResponse) GetContextLength added in v2.12.4

func (g *GetModelResponse) GetContextLength() *float64

func (*GetModelResponse) GetDefaultEndpoints added in v2.12.4

func (g *GetModelResponse) GetDefaultEndpoints() []CompatibleEndpoint

func (*GetModelResponse) GetEndpoints added in v2.12.4

func (g *GetModelResponse) GetEndpoints() []CompatibleEndpoint

func (*GetModelResponse) GetExtraProperties added in v2.8.2

func (g *GetModelResponse) GetExtraProperties() map[string]interface{}

func (*GetModelResponse) GetFinetuned added in v2.12.4

func (g *GetModelResponse) GetFinetuned() *bool

func (*GetModelResponse) GetName added in v2.12.4

func (g *GetModelResponse) GetName() *string

func (*GetModelResponse) GetTokenizerUrl added in v2.12.4

func (g *GetModelResponse) GetTokenizerUrl() *string

func (*GetModelResponse) String added in v2.7.1

func (g *GetModelResponse) String() string

func (*GetModelResponse) UnmarshalJSON added in v2.7.1

func (g *GetModelResponse) UnmarshalJSON(data []byte) error

type Image added in v2.12.1

type Image struct {
	// Width of the image in pixels
	Width int64 `json:"width" url:"width"`
	// Height of the image in pixels
	Height int64 `json:"height" url:"height"`
	// Format of the image
	Format string `json:"format" url:"format"`
	// Bit depth of the image
	BitDepth int64 `json:"bit_depth" url:"bit_depth"`
	// contains filtered or unexported fields
}

func (*Image) GetBitDepth added in v2.12.4

func (i *Image) GetBitDepth() int64

func (*Image) GetExtraProperties added in v2.12.1

func (i *Image) GetExtraProperties() map[string]interface{}

func (*Image) GetFormat added in v2.12.4

func (i *Image) GetFormat() string

func (*Image) GetHeight added in v2.12.4

func (i *Image) GetHeight() int64

func (*Image) GetWidth added in v2.12.4

func (i *Image) GetWidth() int64

func (*Image) String added in v2.12.1

func (i *Image) String() string

func (*Image) UnmarshalJSON added in v2.12.1

func (i *Image) UnmarshalJSON(data []byte) error

type InternalServerError

type InternalServerError struct {
	*core.APIError
	Body interface{}
}

This error is returned when an uncategorised internal server error occurs.

func (*InternalServerError) MarshalJSON

func (i *InternalServerError) MarshalJSON() ([]byte, error)

func (*InternalServerError) UnmarshalJSON

func (i *InternalServerError) UnmarshalJSON(data []byte) error

func (*InternalServerError) Unwrap

func (i *InternalServerError) Unwrap() error

type InvalidTokenError added in v2.12.4

type InvalidTokenError struct {
	*core.APIError
	Body interface{}
}

This error is returned when a request or response contains a deny-listed token.

func (*InvalidTokenError) MarshalJSON added in v2.12.4

func (i *InvalidTokenError) MarshalJSON() ([]byte, error)

func (*InvalidTokenError) UnmarshalJSON added in v2.12.4

func (i *InvalidTokenError) UnmarshalJSON(data []byte) error

func (*InvalidTokenError) Unwrap added in v2.12.4

func (i *InvalidTokenError) Unwrap() error

type JsonResponseFormat added in v2.10.0

type JsonResponseFormat struct {
	// A JSON schema object that the output will adhere to. There are some restrictions we have on the schema, refer to [our guide](https://docs.cohere.com/docs/structured-outputs-json#schema-constraints) for more information.
	// Example (required name and age object):
	// “`json
	//
	//	{
	//	  "type": "object",
	//	  "properties": {
	//	    "name": {"type": "string"},
	//	    "age": {"type": "integer"}
	//	  },
	//	  "required": ["name", "age"]
	//	}
	//
	// “`
	//
	// **Note**: This field must not be specified when the `type` is set to `"text"`.
	Schema map[string]interface{} `json:"schema,omitempty" url:"schema,omitempty"`
	// contains filtered or unexported fields
}

func (*JsonResponseFormat) GetExtraProperties added in v2.10.0

func (j *JsonResponseFormat) GetExtraProperties() map[string]interface{}

func (*JsonResponseFormat) GetSchema added in v2.12.4

func (j *JsonResponseFormat) GetSchema() map[string]interface{}

func (*JsonResponseFormat) String added in v2.10.0

func (j *JsonResponseFormat) String() string

func (*JsonResponseFormat) UnmarshalJSON added in v2.10.0

func (j *JsonResponseFormat) UnmarshalJSON(data []byte) error

type JsonResponseFormatV2 added in v2.12.0

type JsonResponseFormatV2 struct {
	// A [JSON schema](https://json-schema.org/overview/what-is-jsonschema) object that the output will adhere to. There are some restrictions we have on the schema, refer to [our guide](https://docs.cohere.com/docs/structured-outputs-json#schema-constraints) for more information.
	// Example (required name and age object):
	// “`json
	//
	//	{
	//	  "type": "object",
	//	  "properties": {
	//	    "name": {"type": "string"},
	//	    "age": {"type": "integer"}
	//	  },
	//	  "required": ["name", "age"]
	//	}
	//
	// “`
	//
	// **Note**: This field must not be specified when the `type` is set to `"text"`.
	JsonSchema map[string]interface{} `json:"json_schema,omitempty" url:"json_schema,omitempty"`
	// contains filtered or unexported fields
}

func (*JsonResponseFormatV2) GetExtraProperties added in v2.12.0

func (j *JsonResponseFormatV2) GetExtraProperties() map[string]interface{}

func (*JsonResponseFormatV2) GetJsonSchema added in v2.12.4

func (j *JsonResponseFormatV2) GetJsonSchema() map[string]interface{}

func (*JsonResponseFormatV2) String added in v2.12.0

func (j *JsonResponseFormatV2) String() string

func (*JsonResponseFormatV2) UnmarshalJSON added in v2.12.0

func (j *JsonResponseFormatV2) UnmarshalJSON(data []byte) error

type LabelMetric added in v2.6.0

type LabelMetric struct {
	// Total number of examples for this label
	TotalExamples *int64 `json:"total_examples,omitempty" url:"total_examples,omitempty"`
	// value of the label
	Label *string `json:"label,omitempty" url:"label,omitempty"`
	// samples for this label
	Samples []string `json:"samples,omitempty" url:"samples,omitempty"`
	// contains filtered or unexported fields
}

func (*LabelMetric) GetExtraProperties added in v2.8.2

func (l *LabelMetric) GetExtraProperties() map[string]interface{}

func (*LabelMetric) GetLabel added in v2.12.4

func (l *LabelMetric) GetLabel() *string

func (*LabelMetric) GetSamples added in v2.12.4

func (l *LabelMetric) GetSamples() []string

func (*LabelMetric) GetTotalExamples added in v2.12.4

func (l *LabelMetric) GetTotalExamples() *int64

func (*LabelMetric) String added in v2.6.0

func (l *LabelMetric) String() string

func (*LabelMetric) UnmarshalJSON added in v2.6.0

func (l *LabelMetric) UnmarshalJSON(data []byte) error

type ListConnectorsResponse added in v2.5.0

type ListConnectorsResponse struct {
	Connectors []*Connector `json:"connectors,omitempty" url:"connectors,omitempty"`
	// Total number of connectors.
	TotalCount *float64 `json:"total_count,omitempty" url:"total_count,omitempty"`
	// contains filtered or unexported fields
}

func (*ListConnectorsResponse) GetConnectors added in v2.12.4

func (l *ListConnectorsResponse) GetConnectors() []*Connector

func (*ListConnectorsResponse) GetExtraProperties added in v2.8.2

func (l *ListConnectorsResponse) GetExtraProperties() map[string]interface{}

func (*ListConnectorsResponse) GetTotalCount added in v2.12.4

func (l *ListConnectorsResponse) GetTotalCount() *float64

func (*ListConnectorsResponse) String added in v2.5.0

func (l *ListConnectorsResponse) String() string

func (*ListConnectorsResponse) UnmarshalJSON added in v2.5.0

func (l *ListConnectorsResponse) UnmarshalJSON(data []byte) error

type ListEmbedJobResponse added in v2.5.0

type ListEmbedJobResponse struct {
	EmbedJobs []*EmbedJob `json:"embed_jobs,omitempty" url:"embed_jobs,omitempty"`
	// contains filtered or unexported fields
}

func (*ListEmbedJobResponse) GetEmbedJobs added in v2.12.4

func (l *ListEmbedJobResponse) GetEmbedJobs() []*EmbedJob

func (*ListEmbedJobResponse) GetExtraProperties added in v2.8.2

func (l *ListEmbedJobResponse) GetExtraProperties() map[string]interface{}

func (*ListEmbedJobResponse) String added in v2.5.0

func (l *ListEmbedJobResponse) String() string

func (*ListEmbedJobResponse) UnmarshalJSON added in v2.5.0

func (l *ListEmbedJobResponse) UnmarshalJSON(data []byte) error

type ListModelsResponse added in v2.6.0

type ListModelsResponse struct {
	Models []*GetModelResponse `json:"models,omitempty" url:"models,omitempty"`
	// A token to retrieve the next page of results. Provide in the page_token parameter of the next request.
	NextPageToken *string `json:"next_page_token,omitempty" url:"next_page_token,omitempty"`
	// contains filtered or unexported fields
}

func (*ListModelsResponse) GetExtraProperties added in v2.8.2

func (l *ListModelsResponse) GetExtraProperties() map[string]interface{}

func (*ListModelsResponse) GetModels added in v2.12.4

func (l *ListModelsResponse) GetModels() []*GetModelResponse

func (*ListModelsResponse) GetNextPageToken added in v2.12.4

func (l *ListModelsResponse) GetNextPageToken() *string

func (*ListModelsResponse) String added in v2.6.0

func (l *ListModelsResponse) String() string

func (*ListModelsResponse) UnmarshalJSON added in v2.6.0

func (l *ListModelsResponse) UnmarshalJSON(data []byte) error

type LogprobItem added in v2.12.1

type LogprobItem struct {
	// The text chunk for which the log probabilities was calculated.
	Text *string `json:"text,omitempty" url:"text,omitempty"`
	// The token ids of each token used to construct the text chunk.
	TokenIds []int `json:"token_ids,omitempty" url:"token_ids,omitempty"`
	// The log probability of each token used to construct the text chunk.
	Logprobs []float64 `json:"logprobs,omitempty" url:"logprobs,omitempty"`
	// contains filtered or unexported fields
}

func (*LogprobItem) GetExtraProperties added in v2.12.1

func (l *LogprobItem) GetExtraProperties() map[string]interface{}

func (*LogprobItem) GetLogprobs added in v2.12.4

func (l *LogprobItem) GetLogprobs() []float64

func (*LogprobItem) GetText added in v2.12.4

func (l *LogprobItem) GetText() *string

func (*LogprobItem) GetTokenIds added in v2.12.4

func (l *LogprobItem) GetTokenIds() []int

func (*LogprobItem) String added in v2.12.1

func (l *LogprobItem) String() string

func (*LogprobItem) UnmarshalJSON added in v2.12.1

func (l *LogprobItem) UnmarshalJSON(data []byte) error

type Message added in v2.8.0

type Message struct {
	Role    string
	Chatbot *ChatMessage
	System  *ChatMessage
	User    *ChatMessage
	Tool    *ToolMessage
}

func (*Message) Accept added in v2.8.0

func (m *Message) Accept(visitor MessageVisitor) error

func (*Message) GetChatbot added in v2.12.4

func (m *Message) GetChatbot() *ChatMessage

func (*Message) GetRole added in v2.12.4

func (m *Message) GetRole() string

func (*Message) GetSystem added in v2.12.4

func (m *Message) GetSystem() *ChatMessage

func (*Message) GetTool added in v2.12.4

func (m *Message) GetTool() *ToolMessage

func (*Message) GetUser added in v2.12.4

func (m *Message) GetUser() *ChatMessage

func (Message) MarshalJSON added in v2.8.0

func (m Message) MarshalJSON() ([]byte, error)

func (*Message) UnmarshalJSON added in v2.8.0

func (m *Message) UnmarshalJSON(data []byte) error

type MessageVisitor added in v2.8.0

type MessageVisitor interface {
	VisitChatbot(*ChatMessage) error
	VisitSystem(*ChatMessage) error
	VisitUser(*ChatMessage) error
	VisitTool(*ToolMessage) error
}

type Metrics added in v2.6.0

type Metrics struct {
	FinetuneDatasetMetrics *FinetuneDatasetMetrics `json:"finetune_dataset_metrics,omitempty" url:"finetune_dataset_metrics,omitempty"`
	EmbedData              *MetricsEmbedData       `json:"embed_data,omitempty" url:"embed_data,omitempty"`
	// contains filtered or unexported fields
}

func (*Metrics) GetEmbedData added in v2.12.4

func (m *Metrics) GetEmbedData() *MetricsEmbedData

func (*Metrics) GetExtraProperties added in v2.8.2

func (m *Metrics) GetExtraProperties() map[string]interface{}

func (*Metrics) GetFinetuneDatasetMetrics added in v2.12.4

func (m *Metrics) GetFinetuneDatasetMetrics() *FinetuneDatasetMetrics

func (*Metrics) String added in v2.6.0

func (m *Metrics) String() string

func (*Metrics) UnmarshalJSON added in v2.6.0

func (m *Metrics) UnmarshalJSON(data []byte) error

type MetricsEmbedData added in v2.7.4

type MetricsEmbedData struct {
	// the fields in the dataset
	Fields []*MetricsEmbedDataFieldsItem `json:"fields,omitempty" url:"fields,omitempty"`
	// contains filtered or unexported fields
}

func (*MetricsEmbedData) GetExtraProperties added in v2.8.2

func (m *MetricsEmbedData) GetExtraProperties() map[string]interface{}

func (*MetricsEmbedData) GetFields added in v2.12.4

func (m *MetricsEmbedData) GetFields() []*MetricsEmbedDataFieldsItem

func (*MetricsEmbedData) String added in v2.7.4

func (m *MetricsEmbedData) String() string

func (*MetricsEmbedData) UnmarshalJSON added in v2.7.4

func (m *MetricsEmbedData) UnmarshalJSON(data []byte) error

type MetricsEmbedDataFieldsItem added in v2.7.4

type MetricsEmbedDataFieldsItem struct {
	// the name of the field
	Name *string `json:"name,omitempty" url:"name,omitempty"`
	// the number of times the field appears in the dataset
	Count *float64 `json:"count,omitempty" url:"count,omitempty"`
	// contains filtered or unexported fields
}

func (*MetricsEmbedDataFieldsItem) GetCount added in v2.12.4

func (m *MetricsEmbedDataFieldsItem) GetCount() *float64

func (*MetricsEmbedDataFieldsItem) GetExtraProperties added in v2.8.2

func (m *MetricsEmbedDataFieldsItem) GetExtraProperties() map[string]interface{}

func (*MetricsEmbedDataFieldsItem) GetName added in v2.12.4

func (m *MetricsEmbedDataFieldsItem) GetName() *string

func (*MetricsEmbedDataFieldsItem) String added in v2.7.4

func (m *MetricsEmbedDataFieldsItem) String() string

func (*MetricsEmbedDataFieldsItem) UnmarshalJSON added in v2.7.4

func (m *MetricsEmbedDataFieldsItem) UnmarshalJSON(data []byte) error

type ModelsListRequest added in v2.6.0

type ModelsListRequest struct {
	// Maximum number of models to include in a page
	// Defaults to `20`, min value of `1`, max value of `1000`.
	PageSize *float64 `json:"-" url:"page_size,omitempty"`
	// Page token provided in the `next_page_token` field of a previous response.
	PageToken *string `json:"-" url:"page_token,omitempty"`
	// When provided, filters the list of models to only those that are compatible with the specified endpoint.
	Endpoint *CompatibleEndpoint `json:"-" url:"endpoint,omitempty"`
	// When provided, filters the list of models to only the default model to the endpoint. This parameter is only valid when `endpoint` is provided.
	DefaultOnly *bool `json:"-" url:"default_only,omitempty"`
}

type NonStreamedChatResponse

type NonStreamedChatResponse struct {
	// Contents of the reply generated by the model.
	Text string `json:"text" url:"text"`
	// Unique identifier for the generated reply. Useful for submitting feedback.
	GenerationId *string `json:"generation_id,omitempty" url:"generation_id,omitempty"`
	// Unique identifier for the response.
	ResponseId *string `json:"response_id,omitempty" url:"response_id,omitempty"`
	// Inline citations for the generated reply.
	Citations []*ChatCitation `json:"citations,omitempty" url:"citations,omitempty"`
	// Documents seen by the model when generating the reply.
	Documents []ChatDocument `json:"documents,omitempty" url:"documents,omitempty"`
	// Denotes that a search for documents is required during the RAG flow.
	IsSearchRequired *bool `json:"is_search_required,omitempty" url:"is_search_required,omitempty"`
	// Generated search queries, meant to be used as part of the RAG flow.
	SearchQueries []*ChatSearchQuery `json:"search_queries,omitempty" url:"search_queries,omitempty"`
	// Documents retrieved from each of the conducted searches.
	SearchResults []*ChatSearchResult `json:"search_results,omitempty" url:"search_results,omitempty"`
	FinishReason  *FinishReason       `json:"finish_reason,omitempty" url:"finish_reason,omitempty"`
	ToolCalls     []*ToolCall         `json:"tool_calls,omitempty" url:"tool_calls,omitempty"`
	// A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's `message`.
	ChatHistory []*Message `json:"chat_history,omitempty" url:"chat_history,omitempty"`
	// The prompt that was used. Only present when `return_prompt` in the request is set to true.
	Prompt *string  `json:"prompt,omitempty" url:"prompt,omitempty"`
	Meta   *ApiMeta `json:"meta,omitempty" url:"meta,omitempty"`
	// contains filtered or unexported fields
}

func (*NonStreamedChatResponse) GetChatHistory added in v2.12.4

func (n *NonStreamedChatResponse) GetChatHistory() []*Message

func (*NonStreamedChatResponse) GetCitations added in v2.12.4

func (n *NonStreamedChatResponse) GetCitations() []*ChatCitation

func (*NonStreamedChatResponse) GetDocuments added in v2.12.4

func (n *NonStreamedChatResponse) GetDocuments() []ChatDocument

func (*NonStreamedChatResponse) GetExtraProperties added in v2.8.2

func (n *NonStreamedChatResponse) GetExtraProperties() map[string]interface{}

func (*NonStreamedChatResponse) GetFinishReason added in v2.12.4

func (n *NonStreamedChatResponse) GetFinishReason() *FinishReason

func (*NonStreamedChatResponse) GetGenerationId added in v2.12.4

func (n *NonStreamedChatResponse) GetGenerationId() *string

func (*NonStreamedChatResponse) GetIsSearchRequired added in v2.12.4

func (n *NonStreamedChatResponse) GetIsSearchRequired() *bool

func (*NonStreamedChatResponse) GetMeta added in v2.12.4

func (n *NonStreamedChatResponse) GetMeta() *ApiMeta

func (*NonStreamedChatResponse) GetPrompt added in v2.12.4

func (n *NonStreamedChatResponse) GetPrompt() *string

func (*NonStreamedChatResponse) GetResponseId added in v2.12.4

func (n *NonStreamedChatResponse) GetResponseId() *string

func (*NonStreamedChatResponse) GetSearchQueries added in v2.12.4

func (n *NonStreamedChatResponse) GetSearchQueries() []*ChatSearchQuery

func (*NonStreamedChatResponse) GetSearchResults added in v2.12.4

func (n *NonStreamedChatResponse) GetSearchResults() []*ChatSearchResult

func (*NonStreamedChatResponse) GetText added in v2.12.4

func (n *NonStreamedChatResponse) GetText() string

func (*NonStreamedChatResponse) GetToolCalls added in v2.12.4

func (n *NonStreamedChatResponse) GetToolCalls() []*ToolCall

func (*NonStreamedChatResponse) String

func (n *NonStreamedChatResponse) String() string

func (*NonStreamedChatResponse) UnmarshalJSON

func (n *NonStreamedChatResponse) UnmarshalJSON(data []byte) error

type NotFoundError added in v2.2.0

type NotFoundError struct {
	*core.APIError
	Body interface{}
}

This error is returned when a resource is not found. This could be because:

  • The endpoint does not exist
  • The resource does not exist eg model id, dataset id

func (*NotFoundError) MarshalJSON added in v2.2.0

func (n *NotFoundError) MarshalJSON() ([]byte, error)

func (*NotFoundError) UnmarshalJSON added in v2.2.0

func (n *NotFoundError) UnmarshalJSON(data []byte) error

func (*NotFoundError) Unwrap added in v2.2.0

func (n *NotFoundError) Unwrap() error

type NotImplementedError added in v2.8.2

type NotImplementedError struct {
	*core.APIError
	Body interface{}
}

This error is returned when the requested feature is not implemented.

func (*NotImplementedError) MarshalJSON added in v2.8.2

func (n *NotImplementedError) MarshalJSON() ([]byte, error)

func (*NotImplementedError) UnmarshalJSON added in v2.8.2

func (n *NotImplementedError) UnmarshalJSON(data []byte) error

func (*NotImplementedError) Unwrap added in v2.8.2

func (n *NotImplementedError) Unwrap() error

type OAuthAuthorizeResponse added in v2.2.0

type OAuthAuthorizeResponse struct {
	// The OAuth 2.0 redirect url. Redirect the user to this url to authorize the connector.
	RedirectUrl *string `json:"redirect_url,omitempty" url:"redirect_url,omitempty"`
	// contains filtered or unexported fields
}

func (*OAuthAuthorizeResponse) GetExtraProperties added in v2.8.2

func (o *OAuthAuthorizeResponse) GetExtraProperties() map[string]interface{}

func (*OAuthAuthorizeResponse) GetRedirectUrl added in v2.12.4

func (o *OAuthAuthorizeResponse) GetRedirectUrl() *string

func (*OAuthAuthorizeResponse) String added in v2.2.0

func (o *OAuthAuthorizeResponse) String() string

func (*OAuthAuthorizeResponse) UnmarshalJSON added in v2.2.0

func (o *OAuthAuthorizeResponse) UnmarshalJSON(data []byte) error

type ParseInfo added in v2.5.2

type ParseInfo struct {
	Separator *string `json:"separator,omitempty" url:"separator,omitempty"`
	Delimiter *string `json:"delimiter,omitempty" url:"delimiter,omitempty"`
	// contains filtered or unexported fields
}

func (*ParseInfo) GetDelimiter added in v2.12.4

func (p *ParseInfo) GetDelimiter() *string

func (*ParseInfo) GetExtraProperties added in v2.8.2

func (p *ParseInfo) GetExtraProperties() map[string]interface{}

func (*ParseInfo) GetSeparator added in v2.12.4

func (p *ParseInfo) GetSeparator() *string

func (*ParseInfo) String added in v2.5.2

func (p *ParseInfo) String() string

func (*ParseInfo) UnmarshalJSON added in v2.5.2

func (p *ParseInfo) UnmarshalJSON(data []byte) error

type RerankDocument added in v2.8.5

type RerankDocument = map[string]string

type RerankRequest

type RerankRequest struct {
	// The identifier of the model to use, eg `rerank-v3.5`.
	Model *string `json:"model,omitempty" url:"-"`
	// The search query
	Query string `json:"query" url:"-"`
	// A list of document objects or strings to rerank.
	// If a document is provided the text fields is required and all other fields will be preserved in the response.
	//
	// The total max chunks (length of documents * max_chunks_per_doc) must be less than 10000.
	//
	// We recommend a maximum of 1,000 documents for optimal endpoint performance.
	Documents []*RerankRequestDocumentsItem `json:"documents,omitempty" url:"-"`
	// The number of most relevant documents or indices to return, defaults to the length of the documents
	TopN *int `json:"top_n,omitempty" url:"-"`
	// If a JSON object is provided, you can specify which keys you would like to have considered for reranking. The model will rerank based on order of the fields passed in (i.e. rank_fields=['title','author','text'] will rerank using the values in title, author, text  sequentially. If the length of title, author, and text exceeds the context length of the model, the chunking will not re-consider earlier fields). If not provided, the model will use the default text field for ranking.
	RankFields []string `json:"rank_fields,omitempty" url:"-"`
	// - If false, returns results without the doc text - the api will return a list of {index, relevance score} where index is inferred from the list passed into the request.
	// - If true, returns results with the doc text passed in - the api will return an ordered list of {index, text, relevance score} where index + text refers to the list passed into the request.
	ReturnDocuments *bool `json:"return_documents,omitempty" url:"-"`
	// The maximum number of chunks to produce internally from a document
	MaxChunksPerDoc *int `json:"max_chunks_per_doc,omitempty" url:"-"`
}

type RerankRequestDocumentsItem

type RerankRequestDocumentsItem struct {
	String         string
	RerankDocument RerankDocument
	// contains filtered or unexported fields
}

func (*RerankRequestDocumentsItem) Accept

func (*RerankRequestDocumentsItem) GetRerankDocument added in v2.12.4

func (r *RerankRequestDocumentsItem) GetRerankDocument() RerankDocument

func (*RerankRequestDocumentsItem) GetString added in v2.12.4

func (r *RerankRequestDocumentsItem) GetString() string

func (RerankRequestDocumentsItem) MarshalJSON

func (r RerankRequestDocumentsItem) MarshalJSON() ([]byte, error)

func (*RerankRequestDocumentsItem) UnmarshalJSON

func (r *RerankRequestDocumentsItem) UnmarshalJSON(data []byte) error

type RerankRequestDocumentsItemVisitor

type RerankRequestDocumentsItemVisitor interface {
	VisitString(string) error
	VisitRerankDocument(RerankDocument) error
}

type RerankResponse

type RerankResponse struct {
	Id *string `json:"id,omitempty" url:"id,omitempty"`
	// An ordered list of ranked documents
	Results []*RerankResponseResultsItem `json:"results,omitempty" url:"results,omitempty"`
	Meta    *ApiMeta                     `json:"meta,omitempty" url:"meta,omitempty"`
	// contains filtered or unexported fields
}

func (*RerankResponse) GetExtraProperties added in v2.8.2

func (r *RerankResponse) GetExtraProperties() map[string]interface{}

func (*RerankResponse) GetId added in v2.12.4

func (r *RerankResponse) GetId() *string

func (*RerankResponse) GetMeta added in v2.12.4

func (r *RerankResponse) GetMeta() *ApiMeta

func (*RerankResponse) GetResults added in v2.12.4

func (r *RerankResponse) GetResults() []*RerankResponseResultsItem

func (*RerankResponse) String

func (r *RerankResponse) String() string

func (*RerankResponse) UnmarshalJSON

func (r *RerankResponse) UnmarshalJSON(data []byte) error

type RerankResponseResultsItem

type RerankResponseResultsItem struct {
	// If `return_documents` is set as `false` this will return none, if `true` it will return the documents passed in
	Document *RerankResponseResultsItemDocument `json:"document,omitempty" url:"document,omitempty"`
	// Corresponds to the index in the original list of documents to which the ranked document belongs. (i.e. if the first value in the `results` object has an `index` value of 3, it means in the list of documents passed in, the document at `index=3` had the highest relevance)
	Index int `json:"index" url:"index"`
	// Relevance scores are normalized to be in the range `[0, 1]`. Scores close to `1` indicate a high relevance to the query, and scores closer to `0` indicate low relevance. It is not accurate to assume a score of 0.9 means the document is 2x more relevant than a document with a score of 0.45
	RelevanceScore float64 `json:"relevance_score" url:"relevance_score"`
	// contains filtered or unexported fields
}

func (*RerankResponseResultsItem) GetDocument added in v2.12.4

func (*RerankResponseResultsItem) GetExtraProperties added in v2.8.2

func (r *RerankResponseResultsItem) GetExtraProperties() map[string]interface{}

func (*RerankResponseResultsItem) GetIndex added in v2.12.4

func (r *RerankResponseResultsItem) GetIndex() int

func (*RerankResponseResultsItem) GetRelevanceScore added in v2.12.4

func (r *RerankResponseResultsItem) GetRelevanceScore() float64

func (*RerankResponseResultsItem) String

func (r *RerankResponseResultsItem) String() string

func (*RerankResponseResultsItem) UnmarshalJSON

func (r *RerankResponseResultsItem) UnmarshalJSON(data []byte) error

type RerankResponseResultsItemDocument

type RerankResponseResultsItemDocument struct {
	// The text of the document to rerank
	Text string `json:"text" url:"text"`
	// contains filtered or unexported fields
}

If `return_documents` is set as `false` this will return none, if `true` it will return the documents passed in

func (*RerankResponseResultsItemDocument) GetExtraProperties added in v2.8.2

func (r *RerankResponseResultsItemDocument) GetExtraProperties() map[string]interface{}

func (*RerankResponseResultsItemDocument) GetText added in v2.12.4

func (*RerankResponseResultsItemDocument) String

func (*RerankResponseResultsItemDocument) UnmarshalJSON

func (r *RerankResponseResultsItemDocument) UnmarshalJSON(data []byte) error

type RerankerDataMetrics added in v2.6.0

type RerankerDataMetrics struct {
	// The number of training queries.
	NumTrainQueries *int64 `json:"num_train_queries,omitempty" url:"num_train_queries,omitempty"`
	// The sum of all relevant passages of valid training examples.
	NumTrainRelevantPassages *int64 `json:"num_train_relevant_passages,omitempty" url:"num_train_relevant_passages,omitempty"`
	// The sum of all hard negatives of valid training examples.
	NumTrainHardNegatives *int64 `json:"num_train_hard_negatives,omitempty" url:"num_train_hard_negatives,omitempty"`
	// The number of evaluation queries.
	NumEvalQueries *int64 `json:"num_eval_queries,omitempty" url:"num_eval_queries,omitempty"`
	// The sum of all relevant passages of valid eval examples.
	NumEvalRelevantPassages *int64 `json:"num_eval_relevant_passages,omitempty" url:"num_eval_relevant_passages,omitempty"`
	// The sum of all hard negatives of valid eval examples.
	NumEvalHardNegatives *int64 `json:"num_eval_hard_negatives,omitempty" url:"num_eval_hard_negatives,omitempty"`
	// contains filtered or unexported fields
}

func (*RerankerDataMetrics) GetExtraProperties added in v2.8.2

func (r *RerankerDataMetrics) GetExtraProperties() map[string]interface{}

func (*RerankerDataMetrics) GetNumEvalHardNegatives added in v2.12.4

func (r *RerankerDataMetrics) GetNumEvalHardNegatives() *int64

func (*RerankerDataMetrics) GetNumEvalQueries added in v2.12.4

func (r *RerankerDataMetrics) GetNumEvalQueries() *int64

func (*RerankerDataMetrics) GetNumEvalRelevantPassages added in v2.12.4

func (r *RerankerDataMetrics) GetNumEvalRelevantPassages() *int64

func (*RerankerDataMetrics) GetNumTrainHardNegatives added in v2.12.4

func (r *RerankerDataMetrics) GetNumTrainHardNegatives() *int64

func (*RerankerDataMetrics) GetNumTrainQueries added in v2.12.4

func (r *RerankerDataMetrics) GetNumTrainQueries() *int64

func (*RerankerDataMetrics) GetNumTrainRelevantPassages added in v2.12.4

func (r *RerankerDataMetrics) GetNumTrainRelevantPassages() *int64

func (*RerankerDataMetrics) String added in v2.6.0

func (r *RerankerDataMetrics) String() string

func (*RerankerDataMetrics) UnmarshalJSON added in v2.6.0

func (r *RerankerDataMetrics) UnmarshalJSON(data []byte) error

type ResponseFormat added in v2.10.0

type ResponseFormat struct {
	Type       string
	Text       *TextResponseFormat
	JsonObject *JsonResponseFormat
}

Configuration for forcing the model output to adhere to the specified format. Supported on [Command R 03-2024](https://docs.cohere.com/docs/command-r), [Command R+ 04-2024](https://docs.cohere.com/docs/command-r-plus) and newer models.

The model can be forced into outputting JSON objects (with up to 5 levels of nesting) by setting `{ "type": "json_object" }`.

A [JSON Schema](https://json-schema.org/) can optionally be provided, to ensure a specific structure.

**Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length. **Limitation**: The parameter is not supported in RAG mode (when any of `connectors`, `documents`, `tools`, `tool_results` are provided).

func (*ResponseFormat) Accept added in v2.10.0

func (r *ResponseFormat) Accept(visitor ResponseFormatVisitor) error

func (*ResponseFormat) GetJsonObject added in v2.12.4

func (r *ResponseFormat) GetJsonObject() *JsonResponseFormat

func (*ResponseFormat) GetText added in v2.12.4

func (r *ResponseFormat) GetText() *TextResponseFormat

func (*ResponseFormat) GetType added in v2.12.4

func (r *ResponseFormat) GetType() string

func (ResponseFormat) MarshalJSON added in v2.10.0

func (r ResponseFormat) MarshalJSON() ([]byte, error)

func (*ResponseFormat) UnmarshalJSON added in v2.10.0

func (r *ResponseFormat) UnmarshalJSON(data []byte) error

type ResponseFormatV2 added in v2.12.0

type ResponseFormatV2 struct {
	Type       string
	Text       *TextResponseFormatV2
	JsonObject *JsonResponseFormatV2
}

Configuration for forcing the model output to adhere to the specified format. Supported on [Command R](https://docs.cohere.com/v2/docs/command-r), [Command R+](https://docs.cohere.com/v2/docs/command-r-plus) and newer models.

The model can be forced into outputting JSON objects by setting `{ "type": "json_object" }`.

A [JSON Schema](https://json-schema.org/) can optionally be provided, to ensure a specific structure.

**Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: _"Generate a JSON ..."_) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length.

**Note**: When `json_schema` is not specified, the generated object can have up to 5 layers of nesting.

**Limitation**: The parameter is not supported when used in combinations with the `documents` or `tools` parameters.

func (*ResponseFormatV2) Accept added in v2.12.0

func (r *ResponseFormatV2) Accept(visitor ResponseFormatV2Visitor) error

func (*ResponseFormatV2) GetJsonObject added in v2.12.4

func (r *ResponseFormatV2) GetJsonObject() *JsonResponseFormatV2

func (*ResponseFormatV2) GetText added in v2.12.4

func (r *ResponseFormatV2) GetText() *TextResponseFormatV2

func (*ResponseFormatV2) GetType added in v2.12.4

func (r *ResponseFormatV2) GetType() string

func (ResponseFormatV2) MarshalJSON added in v2.12.0

func (r ResponseFormatV2) MarshalJSON() ([]byte, error)

func (*ResponseFormatV2) UnmarshalJSON added in v2.12.0

func (r *ResponseFormatV2) UnmarshalJSON(data []byte) error

type ResponseFormatV2Visitor added in v2.12.0

type ResponseFormatV2Visitor interface {
	VisitText(*TextResponseFormatV2) error
	VisitJsonObject(*JsonResponseFormatV2) error
}

type ResponseFormatVisitor added in v2.10.0

type ResponseFormatVisitor interface {
	VisitText(*TextResponseFormat) error
	VisitJsonObject(*JsonResponseFormat) error
}

type ServiceUnavailableError added in v2.7.0

type ServiceUnavailableError struct {
	*core.APIError
	Body interface{}
}

This error is returned when the service is unavailable. This could be due to:

  • Too many users trying to access the service at the same time

func (*ServiceUnavailableError) MarshalJSON added in v2.7.0

func (s *ServiceUnavailableError) MarshalJSON() ([]byte, error)

func (*ServiceUnavailableError) UnmarshalJSON added in v2.7.0

func (s *ServiceUnavailableError) UnmarshalJSON(data []byte) error

func (*ServiceUnavailableError) Unwrap added in v2.7.0

func (s *ServiceUnavailableError) Unwrap() error

type SingleGeneration

type SingleGeneration struct {
	Id   string `json:"id" url:"id"`
	Text string `json:"text" url:"text"`
	// Refers to the nth generation. Only present when `num_generations` is greater than zero.
	Index      *int     `json:"index,omitempty" url:"index,omitempty"`
	Likelihood *float64 `json:"likelihood,omitempty" url:"likelihood,omitempty"`
	// Only returned if `return_likelihoods` is set to `GENERATION` or `ALL`. The likelihood refers to the average log-likelihood of the entire specified string, which is useful for [evaluating the performance of your model](likelihood-eval), especially if you've created a [custom model](https://docs.cohere.com/docs/training-custom-models). Individual token likelihoods provide the log-likelihood of each token. The first token will not have a likelihood.
	TokenLikelihoods []*SingleGenerationTokenLikelihoodsItem `json:"token_likelihoods,omitempty" url:"token_likelihoods,omitempty"`
	// contains filtered or unexported fields
}

func (*SingleGeneration) GetExtraProperties added in v2.8.2

func (s *SingleGeneration) GetExtraProperties() map[string]interface{}

func (*SingleGeneration) GetId added in v2.12.4

func (s *SingleGeneration) GetId() string

func (*SingleGeneration) GetIndex added in v2.12.4

func (s *SingleGeneration) GetIndex() *int

func (*SingleGeneration) GetLikelihood added in v2.12.4

func (s *SingleGeneration) GetLikelihood() *float64

func (*SingleGeneration) GetText added in v2.12.4

func (s *SingleGeneration) GetText() string

func (*SingleGeneration) GetTokenLikelihoods added in v2.12.4

func (s *SingleGeneration) GetTokenLikelihoods() []*SingleGenerationTokenLikelihoodsItem

func (*SingleGeneration) String

func (s *SingleGeneration) String() string

func (*SingleGeneration) UnmarshalJSON

func (s *SingleGeneration) UnmarshalJSON(data []byte) error

type SingleGenerationInStream

type SingleGenerationInStream struct {
	Id string `json:"id" url:"id"`
	// Full text of the generation.
	Text string `json:"text" url:"text"`
	// Refers to the nth generation. Only present when `num_generations` is greater than zero.
	Index        *int         `json:"index,omitempty" url:"index,omitempty"`
	FinishReason FinishReason `json:"finish_reason" url:"finish_reason"`
	// contains filtered or unexported fields
}

func (*SingleGenerationInStream) GetExtraProperties added in v2.8.2

func (s *SingleGenerationInStream) GetExtraProperties() map[string]interface{}

func (*SingleGenerationInStream) GetFinishReason added in v2.12.4

func (s *SingleGenerationInStream) GetFinishReason() FinishReason

func (*SingleGenerationInStream) GetId added in v2.12.4

func (s *SingleGenerationInStream) GetId() string

func (*SingleGenerationInStream) GetIndex added in v2.12.4

func (s *SingleGenerationInStream) GetIndex() *int

func (*SingleGenerationInStream) GetText added in v2.12.4

func (s *SingleGenerationInStream) GetText() string

func (*SingleGenerationInStream) String

func (s *SingleGenerationInStream) String() string

func (*SingleGenerationInStream) UnmarshalJSON

func (s *SingleGenerationInStream) UnmarshalJSON(data []byte) error

type SingleGenerationTokenLikelihoodsItem

type SingleGenerationTokenLikelihoodsItem struct {
	Token      string  `json:"token" url:"token"`
	Likelihood float64 `json:"likelihood" url:"likelihood"`
	// contains filtered or unexported fields
}

func (*SingleGenerationTokenLikelihoodsItem) GetExtraProperties added in v2.8.2

func (s *SingleGenerationTokenLikelihoodsItem) GetExtraProperties() map[string]interface{}

func (*SingleGenerationTokenLikelihoodsItem) GetLikelihood added in v2.12.4

func (s *SingleGenerationTokenLikelihoodsItem) GetLikelihood() float64

func (*SingleGenerationTokenLikelihoodsItem) GetToken added in v2.12.4

func (*SingleGenerationTokenLikelihoodsItem) String

func (*SingleGenerationTokenLikelihoodsItem) UnmarshalJSON

func (s *SingleGenerationTokenLikelihoodsItem) UnmarshalJSON(data []byte) error

type Source added in v2.12.0

type Source struct {
	Type     string
	Tool     *ToolSource
	Document *DocumentSource
}

A source object containing information about the source of the data cited.

func (*Source) Accept added in v2.12.0

func (s *Source) Accept(visitor SourceVisitor) error

func (*Source) GetDocument added in v2.12.4

func (s *Source) GetDocument() *DocumentSource

func (*Source) GetTool added in v2.12.4

func (s *Source) GetTool() *ToolSource

func (*Source) GetType added in v2.12.4

func (s *Source) GetType() string

func (Source) MarshalJSON added in v2.12.0

func (s Source) MarshalJSON() ([]byte, error)

func (*Source) UnmarshalJSON added in v2.12.0

func (s *Source) UnmarshalJSON(data []byte) error

type SourceVisitor added in v2.12.0

type SourceVisitor interface {
	VisitTool(*ToolSource) error
	VisitDocument(*DocumentSource) error
}

type StreamedChatResponse

type StreamedChatResponse struct {
	EventType               string
	StreamStart             *ChatStreamStartEvent
	SearchQueriesGeneration *ChatSearchQueriesGenerationEvent
	SearchResults           *ChatSearchResultsEvent
	TextGeneration          *ChatTextGenerationEvent
	CitationGeneration      *ChatCitationGenerationEvent
	ToolCallsGeneration     *ChatToolCallsGenerationEvent
	StreamEnd               *ChatStreamEndEvent
	ToolCallsChunk          *ChatToolCallsChunkEvent
	Debug                   *ChatDebugEvent
}

StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request).

func (*StreamedChatResponse) Accept

func (*StreamedChatResponse) GetCitationGeneration added in v2.12.4

func (s *StreamedChatResponse) GetCitationGeneration() *ChatCitationGenerationEvent

func (*StreamedChatResponse) GetDebug added in v2.12.4

func (s *StreamedChatResponse) GetDebug() *ChatDebugEvent

func (*StreamedChatResponse) GetEventType added in v2.12.4

func (s *StreamedChatResponse) GetEventType() string

func (*StreamedChatResponse) GetSearchQueriesGeneration added in v2.12.4

func (s *StreamedChatResponse) GetSearchQueriesGeneration() *ChatSearchQueriesGenerationEvent

func (*StreamedChatResponse) GetSearchResults added in v2.12.4

func (s *StreamedChatResponse) GetSearchResults() *ChatSearchResultsEvent

func (*StreamedChatResponse) GetStreamEnd added in v2.12.4

func (s *StreamedChatResponse) GetStreamEnd() *ChatStreamEndEvent

func (*StreamedChatResponse) GetStreamStart added in v2.12.4

func (s *StreamedChatResponse) GetStreamStart() *ChatStreamStartEvent

func (*StreamedChatResponse) GetTextGeneration added in v2.12.4

func (s *StreamedChatResponse) GetTextGeneration() *ChatTextGenerationEvent

func (*StreamedChatResponse) GetToolCallsChunk added in v2.12.4

func (s *StreamedChatResponse) GetToolCallsChunk() *ChatToolCallsChunkEvent

func (*StreamedChatResponse) GetToolCallsGeneration added in v2.12.4

func (s *StreamedChatResponse) GetToolCallsGeneration() *ChatToolCallsGenerationEvent

func (StreamedChatResponse) MarshalJSON

func (s StreamedChatResponse) MarshalJSON() ([]byte, error)

func (*StreamedChatResponse) UnmarshalJSON

func (s *StreamedChatResponse) UnmarshalJSON(data []byte) error

type StreamedChatResponseV2 added in v2.12.0

type StreamedChatResponseV2 struct {
	Type          string
	MessageStart  *ChatMessageStartEvent
	ContentStart  *ChatContentStartEvent
	ContentDelta  *ChatContentDeltaEvent
	ContentEnd    *ChatContentEndEvent
	ToolPlanDelta *ChatToolPlanDeltaEvent
	ToolCallStart *ChatToolCallStartEvent
	ToolCallDelta *ChatToolCallDeltaEvent
	ToolCallEnd   *ChatToolCallEndEvent
	CitationStart *CitationStartEvent
	CitationEnd   *CitationEndEvent
	MessageEnd    *ChatMessageEndEvent
	Debug         *ChatDebugEvent
}

StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request).

func (*StreamedChatResponseV2) Accept added in v2.12.0

func (*StreamedChatResponseV2) GetCitationEnd added in v2.12.4

func (s *StreamedChatResponseV2) GetCitationEnd() *CitationEndEvent

func (*StreamedChatResponseV2) GetCitationStart added in v2.12.4

func (s *StreamedChatResponseV2) GetCitationStart() *CitationStartEvent

func (*StreamedChatResponseV2) GetContentDelta added in v2.12.4

func (s *StreamedChatResponseV2) GetContentDelta() *ChatContentDeltaEvent

func (*StreamedChatResponseV2) GetContentEnd added in v2.12.4

func (s *StreamedChatResponseV2) GetContentEnd() *ChatContentEndEvent

func (*StreamedChatResponseV2) GetContentStart added in v2.12.4

func (s *StreamedChatResponseV2) GetContentStart() *ChatContentStartEvent

func (*StreamedChatResponseV2) GetDebug added in v2.12.4

func (s *StreamedChatResponseV2) GetDebug() *ChatDebugEvent

func (*StreamedChatResponseV2) GetMessageEnd added in v2.12.4

func (s *StreamedChatResponseV2) GetMessageEnd() *ChatMessageEndEvent

func (*StreamedChatResponseV2) GetMessageStart added in v2.12.4

func (s *StreamedChatResponseV2) GetMessageStart() *ChatMessageStartEvent

func (*StreamedChatResponseV2) GetToolCallDelta added in v2.12.4

func (s *StreamedChatResponseV2) GetToolCallDelta() *ChatToolCallDeltaEvent

func (*StreamedChatResponseV2) GetToolCallEnd added in v2.12.4

func (s *StreamedChatResponseV2) GetToolCallEnd() *ChatToolCallEndEvent

func (*StreamedChatResponseV2) GetToolCallStart added in v2.12.4

func (s *StreamedChatResponseV2) GetToolCallStart() *ChatToolCallStartEvent

func (*StreamedChatResponseV2) GetToolPlanDelta added in v2.12.4

func (s *StreamedChatResponseV2) GetToolPlanDelta() *ChatToolPlanDeltaEvent

func (*StreamedChatResponseV2) GetType added in v2.12.4

func (s *StreamedChatResponseV2) GetType() string

func (StreamedChatResponseV2) MarshalJSON added in v2.12.0

func (s StreamedChatResponseV2) MarshalJSON() ([]byte, error)

func (*StreamedChatResponseV2) UnmarshalJSON added in v2.12.0

func (s *StreamedChatResponseV2) UnmarshalJSON(data []byte) error

type StreamedChatResponseV2Visitor added in v2.12.0

type StreamedChatResponseV2Visitor interface {
	VisitMessageStart(*ChatMessageStartEvent) error
	VisitContentStart(*ChatContentStartEvent) error
	VisitContentDelta(*ChatContentDeltaEvent) error
	VisitContentEnd(*ChatContentEndEvent) error
	VisitToolPlanDelta(*ChatToolPlanDeltaEvent) error
	VisitToolCallStart(*ChatToolCallStartEvent) error
	VisitToolCallDelta(*ChatToolCallDeltaEvent) error
	VisitToolCallEnd(*ChatToolCallEndEvent) error
	VisitCitationStart(*CitationStartEvent) error
	VisitCitationEnd(*CitationEndEvent) error
	VisitMessageEnd(*ChatMessageEndEvent) error
	VisitDebug(*ChatDebugEvent) error
}

type StreamedChatResponseVisitor

type StreamedChatResponseVisitor interface {
	VisitStreamStart(*ChatStreamStartEvent) error
	VisitSearchQueriesGeneration(*ChatSearchQueriesGenerationEvent) error
	VisitSearchResults(*ChatSearchResultsEvent) error
	VisitTextGeneration(*ChatTextGenerationEvent) error
	VisitCitationGeneration(*ChatCitationGenerationEvent) error
	VisitToolCallsGeneration(*ChatToolCallsGenerationEvent) error
	VisitStreamEnd(*ChatStreamEndEvent) error
	VisitToolCallsChunk(*ChatToolCallsChunkEvent) error
	VisitDebug(*ChatDebugEvent) error
}

type SummarizeRequest

type SummarizeRequest struct {
	// The text to generate a summary for. Can be up to 100,000 characters long. Currently the only supported language is English.
	Text string `json:"text" url:"-"`
	// One of `short`, `medium`, `long`, or `auto` defaults to `auto`. Indicates the approximate length of the summary. If `auto` is selected, the best option will be picked based on the input text.
	Length *SummarizeRequestLength `json:"length,omitempty" url:"-"`
	// One of `paragraph`, `bullets`, or `auto`, defaults to `auto`. Indicates the style in which the summary will be delivered - in a free form paragraph or in bullet points. If `auto` is selected, the best option will be picked based on the input text.
	Format *SummarizeRequestFormat `json:"format,omitempty" url:"-"`
	// The identifier of the model to generate the summary with. Currently available models are `command` (default), `command-nightly` (experimental), `command-light`, and `command-light-nightly` (experimental). Smaller, "light" models are faster, while larger models will perform better.
	Model *string `json:"model,omitempty" url:"-"`
	// One of `low`, `medium`, `high`, or `auto`, defaults to `auto`. Controls how close to the original text the summary is. `high` extractiveness summaries will lean towards reusing sentences verbatim, while `low` extractiveness summaries will tend to paraphrase more. If `auto` is selected, the best option will be picked based on the input text.
	Extractiveness *SummarizeRequestExtractiveness `json:"extractiveness,omitempty" url:"-"`
	// Ranges from 0 to 5. Controls the randomness of the output. Lower values tend to generate more “predictable” output, while higher values tend to generate more “creative” output. The sweet spot is typically between 0 and 1.
	Temperature *float64 `json:"temperature,omitempty" url:"-"`
	// A free-form instruction for modifying how the summaries get generated. Should complete the sentence "Generate a summary _". Eg. "focusing on the next steps" or "written by Yoda"
	AdditionalCommand *string `json:"additional_command,omitempty" url:"-"`
}

type SummarizeRequestExtractiveness

type SummarizeRequestExtractiveness string

One of `low`, `medium`, `high`, or `auto`, defaults to `auto`. Controls how close to the original text the summary is. `high` extractiveness summaries will lean towards reusing sentences verbatim, while `low` extractiveness summaries will tend to paraphrase more. If `auto` is selected, the best option will be picked based on the input text.

const (
	SummarizeRequestExtractivenessLow    SummarizeRequestExtractiveness = "low"
	SummarizeRequestExtractivenessMedium SummarizeRequestExtractiveness = "medium"
	SummarizeRequestExtractivenessHigh   SummarizeRequestExtractiveness = "high"
)

func NewSummarizeRequestExtractivenessFromString

func NewSummarizeRequestExtractivenessFromString(s string) (SummarizeRequestExtractiveness, error)

func (SummarizeRequestExtractiveness) Ptr

type SummarizeRequestFormat

type SummarizeRequestFormat string

One of `paragraph`, `bullets`, or `auto`, defaults to `auto`. Indicates the style in which the summary will be delivered - in a free form paragraph or in bullet points. If `auto` is selected, the best option will be picked based on the input text.

const (
	SummarizeRequestFormatParagraph SummarizeRequestFormat = "paragraph"
	SummarizeRequestFormatBullets   SummarizeRequestFormat = "bullets"
)

func NewSummarizeRequestFormatFromString

func NewSummarizeRequestFormatFromString(s string) (SummarizeRequestFormat, error)

func (SummarizeRequestFormat) Ptr

type SummarizeRequestLength

type SummarizeRequestLength string

One of `short`, `medium`, `long`, or `auto` defaults to `auto`. Indicates the approximate length of the summary. If `auto` is selected, the best option will be picked based on the input text.

const (
	SummarizeRequestLengthShort  SummarizeRequestLength = "short"
	SummarizeRequestLengthMedium SummarizeRequestLength = "medium"
	SummarizeRequestLengthLong   SummarizeRequestLength = "long"
)

func NewSummarizeRequestLengthFromString

func NewSummarizeRequestLengthFromString(s string) (SummarizeRequestLength, error)

func (SummarizeRequestLength) Ptr

type SummarizeResponse

type SummarizeResponse struct {
	// Generated ID for the summary
	Id *string `json:"id,omitempty" url:"id,omitempty"`
	// Generated summary for the text
	Summary *string  `json:"summary,omitempty" url:"summary,omitempty"`
	Meta    *ApiMeta `json:"meta,omitempty" url:"meta,omitempty"`
	// contains filtered or unexported fields
}

func (*SummarizeResponse) GetExtraProperties added in v2.8.2

func (s *SummarizeResponse) GetExtraProperties() map[string]interface{}

func (*SummarizeResponse) GetId added in v2.12.4

func (s *SummarizeResponse) GetId() *string

func (*SummarizeResponse) GetMeta added in v2.12.4

func (s *SummarizeResponse) GetMeta() *ApiMeta

func (*SummarizeResponse) GetSummary added in v2.12.4

func (s *SummarizeResponse) GetSummary() *string

func (*SummarizeResponse) String

func (s *SummarizeResponse) String() string

func (*SummarizeResponse) UnmarshalJSON

func (s *SummarizeResponse) UnmarshalJSON(data []byte) error

type SystemMessage added in v2.12.0

type SystemMessage struct {
	Content *SystemMessageContent `json:"content,omitempty" url:"content,omitempty"`
	// contains filtered or unexported fields
}

A message from the system.

func (*SystemMessage) GetContent added in v2.12.4

func (s *SystemMessage) GetContent() *SystemMessageContent

func (*SystemMessage) GetExtraProperties added in v2.12.0

func (s *SystemMessage) GetExtraProperties() map[string]interface{}

func (*SystemMessage) String added in v2.12.0

func (s *SystemMessage) String() string

func (*SystemMessage) UnmarshalJSON added in v2.12.0

func (s *SystemMessage) UnmarshalJSON(data []byte) error

type SystemMessageContent added in v2.12.0

type SystemMessageContent struct {
	String                       string
	SystemMessageContentItemList []*SystemMessageContentItem
	// contains filtered or unexported fields
}

func (*SystemMessageContent) Accept added in v2.12.0

func (*SystemMessageContent) GetString added in v2.12.4

func (s *SystemMessageContent) GetString() string

func (*SystemMessageContent) GetSystemMessageContentItemList added in v2.12.4

func (s *SystemMessageContent) GetSystemMessageContentItemList() []*SystemMessageContentItem

func (SystemMessageContent) MarshalJSON added in v2.12.0

func (s SystemMessageContent) MarshalJSON() ([]byte, error)

func (*SystemMessageContent) UnmarshalJSON added in v2.12.0

func (s *SystemMessageContent) UnmarshalJSON(data []byte) error

type SystemMessageContentItem added in v2.12.0

type SystemMessageContentItem struct {
	Type string
	Text *TextContent
}

func (*SystemMessageContentItem) Accept added in v2.12.0

func (*SystemMessageContentItem) GetText added in v2.12.4

func (s *SystemMessageContentItem) GetText() *TextContent

func (*SystemMessageContentItem) GetType added in v2.12.4

func (s *SystemMessageContentItem) GetType() string

func (SystemMessageContentItem) MarshalJSON added in v2.12.0

func (s SystemMessageContentItem) MarshalJSON() ([]byte, error)

func (*SystemMessageContentItem) UnmarshalJSON added in v2.12.0

func (s *SystemMessageContentItem) UnmarshalJSON(data []byte) error

type SystemMessageContentItemVisitor added in v2.12.0

type SystemMessageContentItemVisitor interface {
	VisitText(*TextContent) error
}

type SystemMessageContentVisitor added in v2.12.0

type SystemMessageContentVisitor interface {
	VisitString(string) error
	VisitSystemMessageContentItemList([]*SystemMessageContentItem) error
}

type TextContent added in v2.12.0

type TextContent struct {
	Text string `json:"text" url:"text"`
	// contains filtered or unexported fields
}

Text content of the message.

func (*TextContent) GetExtraProperties added in v2.12.0

func (t *TextContent) GetExtraProperties() map[string]interface{}

func (*TextContent) GetText added in v2.12.4

func (t *TextContent) GetText() string

func (*TextContent) String added in v2.12.0

func (t *TextContent) String() string

func (*TextContent) UnmarshalJSON added in v2.12.0

func (t *TextContent) UnmarshalJSON(data []byte) error

type TextResponseFormat added in v2.10.0

type TextResponseFormat struct {
	// contains filtered or unexported fields
}

func (*TextResponseFormat) GetExtraProperties added in v2.10.0

func (t *TextResponseFormat) GetExtraProperties() map[string]interface{}

func (*TextResponseFormat) String added in v2.10.0

func (t *TextResponseFormat) String() string

func (*TextResponseFormat) UnmarshalJSON added in v2.10.0

func (t *TextResponseFormat) UnmarshalJSON(data []byte) error

type TextResponseFormatV2 added in v2.12.0

type TextResponseFormatV2 struct {
	// contains filtered or unexported fields
}

func (*TextResponseFormatV2) GetExtraProperties added in v2.12.0

func (t *TextResponseFormatV2) GetExtraProperties() map[string]interface{}

func (*TextResponseFormatV2) String added in v2.12.0

func (t *TextResponseFormatV2) String() string

func (*TextResponseFormatV2) UnmarshalJSON added in v2.12.0

func (t *TextResponseFormatV2) UnmarshalJSON(data []byte) error

type TokenizeRequest

type TokenizeRequest struct {
	// The string to be tokenized, the minimum text length is 1 character, and the maximum text length is 65536 characters.
	Text string `json:"text" url:"-"`
	// An optional parameter to provide the model name. This will ensure that the tokenization uses the tokenizer used by that model.
	Model string `json:"model" url:"-"`
}

type TokenizeResponse

type TokenizeResponse struct {
	// An array of tokens, where each token is an integer.
	Tokens       []int    `json:"tokens,omitempty" url:"tokens,omitempty"`
	TokenStrings []string `json:"token_strings,omitempty" url:"token_strings,omitempty"`
	Meta         *ApiMeta `json:"meta,omitempty" url:"meta,omitempty"`
	// contains filtered or unexported fields
}

func (*TokenizeResponse) GetExtraProperties added in v2.8.2

func (t *TokenizeResponse) GetExtraProperties() map[string]interface{}

func (*TokenizeResponse) GetMeta added in v2.12.4

func (t *TokenizeResponse) GetMeta() *ApiMeta

func (*TokenizeResponse) GetTokenStrings added in v2.12.4

func (t *TokenizeResponse) GetTokenStrings() []string

func (*TokenizeResponse) GetTokens added in v2.12.4

func (t *TokenizeResponse) GetTokens() []int

func (*TokenizeResponse) String

func (t *TokenizeResponse) String() string

func (*TokenizeResponse) UnmarshalJSON

func (t *TokenizeResponse) UnmarshalJSON(data []byte) error

type TooManyRequestsError added in v2.6.0

type TooManyRequestsError struct {
	*core.APIError
	Body interface{}
}

Too many requests

func (*TooManyRequestsError) MarshalJSON added in v2.6.0

func (t *TooManyRequestsError) MarshalJSON() ([]byte, error)

func (*TooManyRequestsError) UnmarshalJSON added in v2.6.0

func (t *TooManyRequestsError) UnmarshalJSON(data []byte) error

func (*TooManyRequestsError) Unwrap added in v2.6.0

func (t *TooManyRequestsError) Unwrap() error

type Tool added in v2.6.0

type Tool struct {
	// The name of the tool to be called. Valid names contain only the characters `a-z`, `A-Z`, `0-9`, `_` and must not begin with a digit.
	Name string `json:"name" url:"name"`
	// The description of what the tool does, the model uses the description to choose when and how to call the function.
	Description string `json:"description" url:"description"`
	// The input parameters of the tool. Accepts a dictionary where the key is the name of the parameter and the value is the parameter spec. Valid parameter names contain only the characters `a-z`, `A-Z`, `0-9`, `_` and must not begin with a digit.
	// “`
	//
	//	{
	//	  "my_param": {
	//	    "description": <string>,
	//	    "type": <string>, // any python data type, such as 'str', 'bool'
	//	    "required": <boolean>
	//	  }
	//	}
	//
	// “`
	ParameterDefinitions map[string]*ToolParameterDefinitionsValue `json:"parameter_definitions,omitempty" url:"parameter_definitions,omitempty"`
	// contains filtered or unexported fields
}

func (*Tool) GetDescription added in v2.12.4

func (t *Tool) GetDescription() string

func (*Tool) GetExtraProperties added in v2.8.2

func (t *Tool) GetExtraProperties() map[string]interface{}

func (*Tool) GetName added in v2.12.4

func (t *Tool) GetName() string

func (*Tool) GetParameterDefinitions added in v2.12.4

func (t *Tool) GetParameterDefinitions() map[string]*ToolParameterDefinitionsValue

func (*Tool) String added in v2.6.0

func (t *Tool) String() string

func (*Tool) UnmarshalJSON added in v2.6.0

func (t *Tool) UnmarshalJSON(data []byte) error

type ToolCall added in v2.6.0

type ToolCall struct {
	// Name of the tool to call.
	Name string `json:"name" url:"name"`
	// The name and value of the parameters to use when invoking a tool.
	Parameters map[string]interface{} `json:"parameters,omitempty" url:"parameters,omitempty"`
	// contains filtered or unexported fields
}

Contains the tool calls generated by the model. Use it to invoke your tools.

func (*ToolCall) GetExtraProperties added in v2.8.2

func (t *ToolCall) GetExtraProperties() map[string]interface{}

func (*ToolCall) GetName added in v2.12.4

func (t *ToolCall) GetName() string

func (*ToolCall) GetParameters added in v2.12.4

func (t *ToolCall) GetParameters() map[string]interface{}

func (*ToolCall) String added in v2.6.0

func (t *ToolCall) String() string

func (*ToolCall) UnmarshalJSON added in v2.6.0

func (t *ToolCall) UnmarshalJSON(data []byte) error

type ToolCallDelta added in v2.8.2

type ToolCallDelta struct {
	// Name of the tool call
	Name *string `json:"name,omitempty" url:"name,omitempty"`
	// Index of the tool call generated
	Index *float64 `json:"index,omitempty" url:"index,omitempty"`
	// Chunk of the tool parameters
	Parameters *string `json:"parameters,omitempty" url:"parameters,omitempty"`
	// Chunk of the tool plan text
	Text *string `json:"text,omitempty" url:"text,omitempty"`
	// contains filtered or unexported fields
}

Contains the chunk of the tool call generation in the stream.

func (*ToolCallDelta) GetExtraProperties added in v2.8.2

func (t *ToolCallDelta) GetExtraProperties() map[string]interface{}

func (*ToolCallDelta) GetIndex added in v2.12.4

func (t *ToolCallDelta) GetIndex() *float64

func (*ToolCallDelta) GetName added in v2.12.4

func (t *ToolCallDelta) GetName() *string

func (*ToolCallDelta) GetParameters added in v2.12.4

func (t *ToolCallDelta) GetParameters() *string

func (*ToolCallDelta) GetText added in v2.12.4

func (t *ToolCallDelta) GetText() *string

func (*ToolCallDelta) String added in v2.8.2

func (t *ToolCallDelta) String() string

func (*ToolCallDelta) UnmarshalJSON added in v2.8.2

func (t *ToolCallDelta) UnmarshalJSON(data []byte) error

type ToolCallV2 added in v2.12.0

type ToolCallV2 struct {
	Id       *string             `json:"id,omitempty" url:"id,omitempty"`
	Type     *string             `json:"type,omitempty" url:"type,omitempty"`
	Function *ToolCallV2Function `json:"function,omitempty" url:"function,omitempty"`
	// contains filtered or unexported fields
}

An array of tool calls to be made.

func (*ToolCallV2) GetExtraProperties added in v2.12.0

func (t *ToolCallV2) GetExtraProperties() map[string]interface{}

func (*ToolCallV2) GetFunction added in v2.12.4

func (t *ToolCallV2) GetFunction() *ToolCallV2Function

func (*ToolCallV2) GetId added in v2.12.4

func (t *ToolCallV2) GetId() *string

func (*ToolCallV2) String added in v2.12.0

func (t *ToolCallV2) String() string

func (*ToolCallV2) UnmarshalJSON added in v2.12.0

func (t *ToolCallV2) UnmarshalJSON(data []byte) error

type ToolCallV2Function added in v2.12.0

type ToolCallV2Function struct {
	Name      *string `json:"name,omitempty" url:"name,omitempty"`
	Arguments *string `json:"arguments,omitempty" url:"arguments,omitempty"`
	// contains filtered or unexported fields
}

func (*ToolCallV2Function) GetArguments added in v2.12.4

func (t *ToolCallV2Function) GetArguments() *string

func (*ToolCallV2Function) GetExtraProperties added in v2.12.0

func (t *ToolCallV2Function) GetExtraProperties() map[string]interface{}

func (*ToolCallV2Function) GetName added in v2.12.4

func (t *ToolCallV2Function) GetName() *string

func (*ToolCallV2Function) String added in v2.12.0

func (t *ToolCallV2Function) String() string

func (*ToolCallV2Function) UnmarshalJSON added in v2.12.0

func (t *ToolCallV2Function) UnmarshalJSON(data []byte) error

type ToolContent added in v2.12.0

type ToolContent struct {
	Type     string
	Text     *TextContent
	Document *DocumentContent
}

A content block which contains information about the content of a tool result

func (*ToolContent) Accept added in v2.12.0

func (t *ToolContent) Accept(visitor ToolContentVisitor) error

func (*ToolContent) GetDocument added in v2.12.4

func (t *ToolContent) GetDocument() *DocumentContent

func (*ToolContent) GetText added in v2.12.4

func (t *ToolContent) GetText() *TextContent

func (*ToolContent) GetType added in v2.12.4

func (t *ToolContent) GetType() string

func (ToolContent) MarshalJSON added in v2.12.0

func (t ToolContent) MarshalJSON() ([]byte, error)

func (*ToolContent) UnmarshalJSON added in v2.12.0

func (t *ToolContent) UnmarshalJSON(data []byte) error

type ToolContentVisitor added in v2.12.0

type ToolContentVisitor interface {
	VisitText(*TextContent) error
	VisitDocument(*DocumentContent) error
}

type ToolMessage added in v2.8.0

type ToolMessage struct {
	ToolResults []*ToolResult `json:"tool_results,omitempty" url:"tool_results,omitempty"`
	// contains filtered or unexported fields
}

Represents tool result in the chat history.

func (*ToolMessage) GetExtraProperties added in v2.8.2

func (t *ToolMessage) GetExtraProperties() map[string]interface{}

func (*ToolMessage) GetToolResults added in v2.12.4

func (t *ToolMessage) GetToolResults() []*ToolResult

func (*ToolMessage) String added in v2.8.0

func (t *ToolMessage) String() string

func (*ToolMessage) UnmarshalJSON added in v2.8.0

func (t *ToolMessage) UnmarshalJSON(data []byte) error

type ToolMessageV2 added in v2.12.0

type ToolMessageV2 struct {
	// The id of the associated tool call that has provided the given content
	ToolCallId string `json:"tool_call_id" url:"tool_call_id"`
	// Outputs from a tool. The content should formatted as a JSON object string, or a list of tool content blocks
	Content *ToolMessageV2Content `json:"content,omitempty" url:"content,omitempty"`
	// contains filtered or unexported fields
}

A message with Tool outputs.

func (*ToolMessageV2) GetContent added in v2.12.4

func (t *ToolMessageV2) GetContent() *ToolMessageV2Content

func (*ToolMessageV2) GetExtraProperties added in v2.12.0

func (t *ToolMessageV2) GetExtraProperties() map[string]interface{}

func (*ToolMessageV2) GetToolCallId added in v2.12.4

func (t *ToolMessageV2) GetToolCallId() string

func (*ToolMessageV2) String added in v2.12.0

func (t *ToolMessageV2) String() string

func (*ToolMessageV2) UnmarshalJSON added in v2.12.0

func (t *ToolMessageV2) UnmarshalJSON(data []byte) error

type ToolMessageV2Content added in v2.12.0

type ToolMessageV2Content struct {
	String          string
	ToolContentList []*ToolContent
	// contains filtered or unexported fields
}

Outputs from a tool. The content should formatted as a JSON object string, or a list of tool content blocks

func (*ToolMessageV2Content) Accept added in v2.12.0

func (*ToolMessageV2Content) GetString added in v2.12.4

func (t *ToolMessageV2Content) GetString() string

func (*ToolMessageV2Content) GetToolContentList added in v2.12.4

func (t *ToolMessageV2Content) GetToolContentList() []*ToolContent

func (ToolMessageV2Content) MarshalJSON added in v2.12.0

func (t ToolMessageV2Content) MarshalJSON() ([]byte, error)

func (*ToolMessageV2Content) UnmarshalJSON added in v2.12.0

func (t *ToolMessageV2Content) UnmarshalJSON(data []byte) error

type ToolMessageV2ContentVisitor added in v2.12.0

type ToolMessageV2ContentVisitor interface {
	VisitString(string) error
	VisitToolContentList([]*ToolContent) error
}

type ToolParameterDefinitionsValue added in v2.6.0

type ToolParameterDefinitionsValue struct {
	// The description of the parameter.
	Description *string `json:"description,omitempty" url:"description,omitempty"`
	// The type of the parameter. Must be a valid Python type.
	Type string `json:"type" url:"type"`
	// Denotes whether the parameter is always present (required) or not. Defaults to not required.
	Required *bool `json:"required,omitempty" url:"required,omitempty"`
	// contains filtered or unexported fields
}

func (*ToolParameterDefinitionsValue) GetDescription added in v2.12.4

func (t *ToolParameterDefinitionsValue) GetDescription() *string

func (*ToolParameterDefinitionsValue) GetExtraProperties added in v2.8.2

func (t *ToolParameterDefinitionsValue) GetExtraProperties() map[string]interface{}

func (*ToolParameterDefinitionsValue) GetRequired added in v2.12.4

func (t *ToolParameterDefinitionsValue) GetRequired() *bool

func (*ToolParameterDefinitionsValue) GetType added in v2.12.4

func (*ToolParameterDefinitionsValue) String added in v2.6.0

func (*ToolParameterDefinitionsValue) UnmarshalJSON added in v2.6.0

func (t *ToolParameterDefinitionsValue) UnmarshalJSON(data []byte) error

type ToolResult added in v2.8.0

type ToolResult struct {
	Call    *ToolCall                `json:"call,omitempty" url:"call,omitempty"`
	Outputs []map[string]interface{} `json:"outputs,omitempty" url:"outputs,omitempty"`
	// contains filtered or unexported fields
}

func (*ToolResult) GetCall added in v2.12.4

func (t *ToolResult) GetCall() *ToolCall

func (*ToolResult) GetExtraProperties added in v2.8.2

func (t *ToolResult) GetExtraProperties() map[string]interface{}

func (*ToolResult) GetOutputs added in v2.12.4

func (t *ToolResult) GetOutputs() []map[string]interface{}

func (*ToolResult) String added in v2.8.0

func (t *ToolResult) String() string

func (*ToolResult) UnmarshalJSON added in v2.8.0

func (t *ToolResult) UnmarshalJSON(data []byte) error

type ToolSource added in v2.12.0

type ToolSource struct {
	// The unique identifier of the document
	Id         *string                `json:"id,omitempty" url:"id,omitempty"`
	ToolOutput map[string]interface{} `json:"tool_output,omitempty" url:"tool_output,omitempty"`
	// contains filtered or unexported fields
}

func (*ToolSource) GetExtraProperties added in v2.12.0

func (t *ToolSource) GetExtraProperties() map[string]interface{}

func (*ToolSource) GetId added in v2.12.4

func (t *ToolSource) GetId() *string

func (*ToolSource) GetToolOutput added in v2.12.4

func (t *ToolSource) GetToolOutput() map[string]interface{}

func (*ToolSource) String added in v2.12.0

func (t *ToolSource) String() string

func (*ToolSource) UnmarshalJSON added in v2.12.0

func (t *ToolSource) UnmarshalJSON(data []byte) error

type ToolV2 added in v2.12.0

type ToolV2 struct {
	Type *string `json:"type,omitempty" url:"type,omitempty"`
	// The function to be executed.
	Function *ToolV2Function `json:"function,omitempty" url:"function,omitempty"`
	// contains filtered or unexported fields
}

func (*ToolV2) GetExtraProperties added in v2.12.0

func (t *ToolV2) GetExtraProperties() map[string]interface{}

func (*ToolV2) GetFunction added in v2.12.4

func (t *ToolV2) GetFunction() *ToolV2Function

func (*ToolV2) String added in v2.12.0

func (t *ToolV2) String() string

func (*ToolV2) UnmarshalJSON added in v2.12.0

func (t *ToolV2) UnmarshalJSON(data []byte) error

type ToolV2Function added in v2.12.0

type ToolV2Function struct {
	// The name of the function.
	Name *string `json:"name,omitempty" url:"name,omitempty"`
	// The description of the function.
	Description *string `json:"description,omitempty" url:"description,omitempty"`
	// The parameters of the function as a JSON schema.
	Parameters map[string]interface{} `json:"parameters,omitempty" url:"parameters,omitempty"`
	// contains filtered or unexported fields
}

The function to be executed.

func (*ToolV2Function) GetDescription added in v2.12.4

func (t *ToolV2Function) GetDescription() *string

func (*ToolV2Function) GetExtraProperties added in v2.12.0

func (t *ToolV2Function) GetExtraProperties() map[string]interface{}

func (*ToolV2Function) GetName added in v2.12.4

func (t *ToolV2Function) GetName() *string

func (*ToolV2Function) GetParameters added in v2.12.4

func (t *ToolV2Function) GetParameters() map[string]interface{}

func (*ToolV2Function) String added in v2.12.0

func (t *ToolV2Function) String() string

func (*ToolV2Function) UnmarshalJSON added in v2.12.0

func (t *ToolV2Function) UnmarshalJSON(data []byte) error

type UnauthorizedError added in v2.7.0

type UnauthorizedError struct {
	*core.APIError
	Body interface{}
}

This error indicates that the operation attempted to be performed is not allowed. This could be because:

  • The api token is invalid
  • The user does not have the necessary permissions

func (*UnauthorizedError) MarshalJSON added in v2.7.0

func (u *UnauthorizedError) MarshalJSON() ([]byte, error)

func (*UnauthorizedError) UnmarshalJSON added in v2.7.0

func (u *UnauthorizedError) UnmarshalJSON(data []byte) error

func (*UnauthorizedError) Unwrap added in v2.7.0

func (u *UnauthorizedError) Unwrap() error

type UnprocessableEntityError added in v2.8.2

type UnprocessableEntityError struct {
	*core.APIError
	Body interface{}
}

This error is returned when the request is not well formed. This could be because:

  • JSON is invalid
  • The request is missing required fields
  • The request contains an invalid combination of fields

func (*UnprocessableEntityError) MarshalJSON added in v2.8.2

func (u *UnprocessableEntityError) MarshalJSON() ([]byte, error)

func (*UnprocessableEntityError) UnmarshalJSON added in v2.8.2

func (u *UnprocessableEntityError) UnmarshalJSON(data []byte) error

func (*UnprocessableEntityError) Unwrap added in v2.8.2

func (u *UnprocessableEntityError) Unwrap() error

type UpdateConnectorRequest added in v2.5.0

type UpdateConnectorRequest struct {
	// A human-readable name for the connector.
	Name *string `json:"name,omitempty" url:"-"`
	// The URL of the connector that will be used to search for documents.
	Url *string `json:"url,omitempty" url:"-"`
	// A list of fields to exclude from the prompt (fields remain in the document).
	Excludes []string `json:"excludes,omitempty" url:"-"`
	// The OAuth 2.0 configuration for the connector. Cannot be specified if service_auth is specified.
	Oauth             *CreateConnectorOAuth `json:"oauth,omitempty" url:"-"`
	Active            *bool                 `json:"active,omitempty" url:"-"`
	ContinueOnFailure *bool                 `json:"continue_on_failure,omitempty" url:"-"`
	// The service to service authentication configuration for the connector. Cannot be specified if oauth is specified.
	ServiceAuth *CreateConnectorServiceAuth `json:"service_auth,omitempty" url:"-"`
}

type UpdateConnectorResponse added in v2.5.0

type UpdateConnectorResponse struct {
	Connector *Connector `json:"connector,omitempty" url:"connector,omitempty"`
	// contains filtered or unexported fields
}

func (*UpdateConnectorResponse) GetConnector added in v2.12.4

func (u *UpdateConnectorResponse) GetConnector() *Connector

func (*UpdateConnectorResponse) GetExtraProperties added in v2.8.2

func (u *UpdateConnectorResponse) GetExtraProperties() map[string]interface{}

func (*UpdateConnectorResponse) String added in v2.5.0

func (u *UpdateConnectorResponse) String() string

func (*UpdateConnectorResponse) UnmarshalJSON added in v2.5.0

func (u *UpdateConnectorResponse) UnmarshalJSON(data []byte) error

type Usage added in v2.12.0

type Usage struct {
	BilledUnits *UsageBilledUnits `json:"billed_units,omitempty" url:"billed_units,omitempty"`
	Tokens      *UsageTokens      `json:"tokens,omitempty" url:"tokens,omitempty"`
	// contains filtered or unexported fields
}

func (*Usage) GetBilledUnits added in v2.12.4

func (u *Usage) GetBilledUnits() *UsageBilledUnits

func (*Usage) GetExtraProperties added in v2.12.0

func (u *Usage) GetExtraProperties() map[string]interface{}

func (*Usage) GetTokens added in v2.12.4

func (u *Usage) GetTokens() *UsageTokens

func (*Usage) String added in v2.12.0

func (u *Usage) String() string

func (*Usage) UnmarshalJSON added in v2.12.0

func (u *Usage) UnmarshalJSON(data []byte) error

type UsageBilledUnits added in v2.12.0

type UsageBilledUnits struct {
	// The number of billed input tokens.
	InputTokens *float64 `json:"input_tokens,omitempty" url:"input_tokens,omitempty"`
	// The number of billed output tokens.
	OutputTokens *float64 `json:"output_tokens,omitempty" url:"output_tokens,omitempty"`
	// The number of billed search units.
	SearchUnits *float64 `json:"search_units,omitempty" url:"search_units,omitempty"`
	// The number of billed classifications units.
	Classifications *float64 `json:"classifications,omitempty" url:"classifications,omitempty"`
	// contains filtered or unexported fields
}

func (*UsageBilledUnits) GetClassifications added in v2.12.4

func (u *UsageBilledUnits) GetClassifications() *float64

func (*UsageBilledUnits) GetExtraProperties added in v2.12.0

func (u *UsageBilledUnits) GetExtraProperties() map[string]interface{}

func (*UsageBilledUnits) GetInputTokens added in v2.12.4

func (u *UsageBilledUnits) GetInputTokens() *float64

func (*UsageBilledUnits) GetOutputTokens added in v2.12.4

func (u *UsageBilledUnits) GetOutputTokens() *float64

func (*UsageBilledUnits) GetSearchUnits added in v2.12.4

func (u *UsageBilledUnits) GetSearchUnits() *float64

func (*UsageBilledUnits) String added in v2.12.0

func (u *UsageBilledUnits) String() string

func (*UsageBilledUnits) UnmarshalJSON added in v2.12.0

func (u *UsageBilledUnits) UnmarshalJSON(data []byte) error

type UsageTokens added in v2.12.0

type UsageTokens struct {
	// The number of tokens used as input to the model.
	InputTokens *float64 `json:"input_tokens,omitempty" url:"input_tokens,omitempty"`
	// The number of tokens produced by the model.
	OutputTokens *float64 `json:"output_tokens,omitempty" url:"output_tokens,omitempty"`
	// contains filtered or unexported fields
}

func (*UsageTokens) GetExtraProperties added in v2.12.0

func (u *UsageTokens) GetExtraProperties() map[string]interface{}

func (*UsageTokens) GetInputTokens added in v2.12.4

func (u *UsageTokens) GetInputTokens() *float64

func (*UsageTokens) GetOutputTokens added in v2.12.4

func (u *UsageTokens) GetOutputTokens() *float64

func (*UsageTokens) String added in v2.12.0

func (u *UsageTokens) String() string

func (*UsageTokens) UnmarshalJSON added in v2.12.0

func (u *UsageTokens) UnmarshalJSON(data []byte) error

type UserMessage added in v2.12.0

type UserMessage struct {
	// The content of the message. This can be a string or a list of content blocks.
	// If a string is provided, it will be treated as a text content block.
	Content *UserMessageContent `json:"content,omitempty" url:"content,omitempty"`
	// contains filtered or unexported fields
}

A message from the user.

func (*UserMessage) GetContent added in v2.12.4

func (u *UserMessage) GetContent() *UserMessageContent

func (*UserMessage) GetExtraProperties added in v2.12.0

func (u *UserMessage) GetExtraProperties() map[string]interface{}

func (*UserMessage) String added in v2.12.0

func (u *UserMessage) String() string

func (*UserMessage) UnmarshalJSON added in v2.12.0

func (u *UserMessage) UnmarshalJSON(data []byte) error

type UserMessageContent added in v2.12.0

type UserMessageContent struct {
	String      string
	ContentList []*Content
	// contains filtered or unexported fields
}

The content of the message. This can be a string or a list of content blocks. If a string is provided, it will be treated as a text content block.

func (*UserMessageContent) Accept added in v2.12.0

func (*UserMessageContent) GetContentList added in v2.12.4

func (u *UserMessageContent) GetContentList() []*Content

func (*UserMessageContent) GetString added in v2.12.4

func (u *UserMessageContent) GetString() string

func (UserMessageContent) MarshalJSON added in v2.12.0

func (u UserMessageContent) MarshalJSON() ([]byte, error)

func (*UserMessageContent) UnmarshalJSON added in v2.12.0

func (u *UserMessageContent) UnmarshalJSON(data []byte) error

type UserMessageContentVisitor added in v2.12.0

type UserMessageContentVisitor interface {
	VisitString(string) error
	VisitContentList([]*Content) error
}

type V2ChatRequest added in v2.12.0

type V2ChatRequest struct {
	// Defaults to `false`.
	//
	// When `true`, the response will be a SSE stream of events. The final event will contain the complete response, and will have an `event_type` of `"stream-end"`.
	//
	// Streaming is beneficial for user interfaces that render the contents of the response piece by piece, as it gets generated.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	//
	// The name of a compatible [Cohere model](https://docs.cohere.com/v2/docs/models) (such as command-r or command-r-plus) or the ID of a [fine-tuned](https://docs.cohere.com/v2/docs/chat-fine-tuning) model.
	Model    string       `json:"model" url:"-"`
	Messages ChatMessages `json:"messages,omitempty" url:"-"`
	// A list of available tools (functions) that the model may suggest invoking before producing a text response.
	//
	// When `tools` is passed (without `tool_results`), the `text` content in the response will be empty and the `tool_calls` field in the response will be populated with a list of tool calls that need to be made. If no calls need to be made, the `tool_calls` array will be empty.
	Tools []*ToolV2 `json:"tools,omitempty" url:"-"`
	// When set to `true`, tool calls in the Assistant message will be forced to follow the tool definition strictly. Learn more in the [Structured Outputs (Tools) guide](https://docs.cohere.com/docs/structured-outputs-json#structured-outputs-tools).
	//
	// **Note**: The first few requests with a new set of tools will take longer to process.
	StrictTools *bool `json:"strict_tools,omitempty" url:"-"`
	// A list of relevant documents that the model can cite to generate a more accurate reply. Each document is either a string or document object with content and metadata.
	Documents       []*V2ChatRequestDocumentsItem `json:"documents,omitempty" url:"-"`
	CitationOptions *CitationOptions              `json:"citation_options,omitempty" url:"-"`
	ResponseFormat  *ResponseFormatV2             `json:"response_format,omitempty" url:"-"`
	// Used to select the [safety instruction](https://docs.cohere.com/v2/docs/safety-modes) inserted into the prompt. Defaults to `CONTEXTUAL`.
	// When `OFF` is specified, the safety instruction will be omitted.
	//
	// Safety modes are not yet configurable in combination with `tools`, `tool_results` and `documents` parameters.
	//
	// **Note**: This parameter is only compatible with models [Command R 08-2024](https://docs.cohere.com/v2/docs/command-r#august-2024-release), [Command R+ 08-2024](https://docs.cohere.com/v2/docs/command-r-plus#august-2024-release) and newer.
	//
	// **Note**: `command-r7b-12-2024` only supports `"CONTEXTUAL"` and `"STRICT"` modes.
	SafetyMode *V2ChatRequestSafetyMode `json:"safety_mode,omitempty" url:"-"`
	// The maximum number of tokens the model will generate as part of the response.
	//
	// **Note**: Setting a low value may result in incomplete generations.
	MaxTokens *int `json:"max_tokens,omitempty" url:"-"`
	// A list of up to 5 strings that the model will use to stop generation. If the model generates a string that matches any of the strings in the list, it will stop generating tokens and return the generated text up to that point not including the stop sequence.
	StopSequences []string `json:"stop_sequences,omitempty" url:"-"`
	// Defaults to `0.3`.
	//
	// A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations.
	//
	// Randomness can be further maximized by increasing the  value of the `p` parameter.
	Temperature *float64 `json:"temperature,omitempty" url:"-"`
	// If specified, the backend will make a best effort to sample tokens
	// deterministically, such that repeated requests with the same
	// seed and parameters should return the same result. However,
	// determinism cannot be totally guaranteed.
	Seed *int `json:"seed,omitempty" url:"-"`
	// Defaults to `0.0`, min value of `0.0`, max value of `1.0`.
	// Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.
	FrequencyPenalty *float64 `json:"frequency_penalty,omitempty" url:"-"`
	// Defaults to `0.0`, min value of `0.0`, max value of `1.0`.
	// Used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.
	PresencePenalty *float64 `json:"presence_penalty,omitempty" url:"-"`
	// Ensures that only the top `k` most likely tokens are considered for generation at each step. When `k` is set to `0`, k-sampling is disabled.
	// Defaults to `0`, min value of `0`, max value of `500`.
	K *float64 `json:"k,omitempty" url:"-"`
	// Ensures that only the most likely tokens, with total probability mass of `p`, are considered for generation at each step. If both `k` and `p` are enabled, `p` acts after `k`.
	// Defaults to `0.75`. min value of `0.01`, max value of `0.99`.
	P *float64 `json:"p,omitempty" url:"-"`
	// Whether to return the prompt in the response.
	ReturnPrompt *bool `json:"return_prompt,omitempty" url:"-"`
	// Defaults to `false`. When set to `true`, the log probabilities of the generated tokens will be included in the response.
	Logprobs *bool `json:"logprobs,omitempty" url:"-"`
	// contains filtered or unexported fields
}

func (*V2ChatRequest) MarshalJSON added in v2.12.0

func (v *V2ChatRequest) MarshalJSON() ([]byte, error)

func (*V2ChatRequest) Stream added in v2.12.0

func (v *V2ChatRequest) Stream() bool

func (*V2ChatRequest) UnmarshalJSON added in v2.12.0

func (v *V2ChatRequest) UnmarshalJSON(data []byte) error

type V2ChatRequestDocumentsItem added in v2.12.0

type V2ChatRequestDocumentsItem struct {
	String   string
	Document *Document
	// contains filtered or unexported fields
}

func (*V2ChatRequestDocumentsItem) Accept added in v2.12.0

func (*V2ChatRequestDocumentsItem) GetDocument added in v2.12.4

func (v *V2ChatRequestDocumentsItem) GetDocument() *Document

func (*V2ChatRequestDocumentsItem) GetString added in v2.12.4

func (v *V2ChatRequestDocumentsItem) GetString() string

func (V2ChatRequestDocumentsItem) MarshalJSON added in v2.12.0

func (v V2ChatRequestDocumentsItem) MarshalJSON() ([]byte, error)

func (*V2ChatRequestDocumentsItem) UnmarshalJSON added in v2.12.0

func (v *V2ChatRequestDocumentsItem) UnmarshalJSON(data []byte) error

type V2ChatRequestDocumentsItemVisitor added in v2.12.0

type V2ChatRequestDocumentsItemVisitor interface {
	VisitString(string) error
	VisitDocument(*Document) error
}

type V2ChatRequestSafetyMode added in v2.12.0

type V2ChatRequestSafetyMode string

Used to select the [safety instruction](https://docs.cohere.com/v2/docs/safety-modes) inserted into the prompt. Defaults to `CONTEXTUAL`. When `OFF` is specified, the safety instruction will be omitted.

Safety modes are not yet configurable in combination with `tools`, `tool_results` and `documents` parameters.

**Note**: This parameter is only compatible with models [Command R 08-2024](https://docs.cohere.com/v2/docs/command-r#august-2024-release), [Command R+ 08-2024](https://docs.cohere.com/v2/docs/command-r-plus#august-2024-release) and newer.

**Note**: `command-r7b-12-2024` only supports `"CONTEXTUAL"` and `"STRICT"` modes.

const (
	V2ChatRequestSafetyModeContextual V2ChatRequestSafetyMode = "CONTEXTUAL"
	V2ChatRequestSafetyModeStrict     V2ChatRequestSafetyMode = "STRICT"
	V2ChatRequestSafetyModeOff        V2ChatRequestSafetyMode = "OFF"
)

func NewV2ChatRequestSafetyModeFromString added in v2.12.0

func NewV2ChatRequestSafetyModeFromString(s string) (V2ChatRequestSafetyMode, error)

func (V2ChatRequestSafetyMode) Ptr added in v2.12.0

type V2ChatStreamRequest added in v2.12.0

type V2ChatStreamRequest struct {
	// Defaults to `false`.
	//
	// When `true`, the response will be a SSE stream of events. The final event will contain the complete response, and will have an `event_type` of `"stream-end"`.
	//
	// Streaming is beneficial for user interfaces that render the contents of the response piece by piece, as it gets generated.
	//
	// Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
	//
	// The name of a compatible [Cohere model](https://docs.cohere.com/v2/docs/models) (such as command-r or command-r-plus) or the ID of a [fine-tuned](https://docs.cohere.com/v2/docs/chat-fine-tuning) model.
	Model    string       `json:"model" url:"-"`
	Messages ChatMessages `json:"messages,omitempty" url:"-"`
	// A list of available tools (functions) that the model may suggest invoking before producing a text response.
	//
	// When `tools` is passed (without `tool_results`), the `text` content in the response will be empty and the `tool_calls` field in the response will be populated with a list of tool calls that need to be made. If no calls need to be made, the `tool_calls` array will be empty.
	Tools []*ToolV2 `json:"tools,omitempty" url:"-"`
	// When set to `true`, tool calls in the Assistant message will be forced to follow the tool definition strictly. Learn more in the [Structured Outputs (Tools) guide](https://docs.cohere.com/docs/structured-outputs-json#structured-outputs-tools).
	//
	// **Note**: The first few requests with a new set of tools will take longer to process.
	StrictTools *bool `json:"strict_tools,omitempty" url:"-"`
	// A list of relevant documents that the model can cite to generate a more accurate reply. Each document is either a string or document object with content and metadata.
	Documents       []*V2ChatStreamRequestDocumentsItem `json:"documents,omitempty" url:"-"`
	CitationOptions *CitationOptions                    `json:"citation_options,omitempty" url:"-"`
	ResponseFormat  *ResponseFormatV2                   `json:"response_format,omitempty" url:"-"`
	// Used to select the [safety instruction](https://docs.cohere.com/v2/docs/safety-modes) inserted into the prompt. Defaults to `CONTEXTUAL`.
	// When `OFF` is specified, the safety instruction will be omitted.
	//
	// Safety modes are not yet configurable in combination with `tools`, `tool_results` and `documents` parameters.
	//
	// **Note**: This parameter is only compatible with models [Command R 08-2024](https://docs.cohere.com/v2/docs/command-r#august-2024-release), [Command R+ 08-2024](https://docs.cohere.com/v2/docs/command-r-plus#august-2024-release) and newer.
	//
	// **Note**: `command-r7b-12-2024` only supports `"CONTEXTUAL"` and `"STRICT"` modes.
	SafetyMode *V2ChatStreamRequestSafetyMode `json:"safety_mode,omitempty" url:"-"`
	// The maximum number of tokens the model will generate as part of the response.
	//
	// **Note**: Setting a low value may result in incomplete generations.
	MaxTokens *int `json:"max_tokens,omitempty" url:"-"`
	// A list of up to 5 strings that the model will use to stop generation. If the model generates a string that matches any of the strings in the list, it will stop generating tokens and return the generated text up to that point not including the stop sequence.
	StopSequences []string `json:"stop_sequences,omitempty" url:"-"`
	// Defaults to `0.3`.
	//
	// A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations.
	//
	// Randomness can be further maximized by increasing the  value of the `p` parameter.
	Temperature *float64 `json:"temperature,omitempty" url:"-"`
	// If specified, the backend will make a best effort to sample tokens
	// deterministically, such that repeated requests with the same
	// seed and parameters should return the same result. However,
	// determinism cannot be totally guaranteed.
	Seed *int `json:"seed,omitempty" url:"-"`
	// Defaults to `0.0`, min value of `0.0`, max value of `1.0`.
	// Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.
	FrequencyPenalty *float64 `json:"frequency_penalty,omitempty" url:"-"`
	// Defaults to `0.0`, min value of `0.0`, max value of `1.0`.
	// Used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.
	PresencePenalty *float64 `json:"presence_penalty,omitempty" url:"-"`
	// Ensures that only the top `k` most likely tokens are considered for generation at each step. When `k` is set to `0`, k-sampling is disabled.
	// Defaults to `0`, min value of `0`, max value of `500`.
	K *float64 `json:"k,omitempty" url:"-"`
	// Ensures that only the most likely tokens, with total probability mass of `p`, are considered for generation at each step. If both `k` and `p` are enabled, `p` acts after `k`.
	// Defaults to `0.75`. min value of `0.01`, max value of `0.99`.
	P *float64 `json:"p,omitempty" url:"-"`
	// Whether to return the prompt in the response.
	ReturnPrompt *bool `json:"return_prompt,omitempty" url:"-"`
	// Defaults to `false`. When set to `true`, the log probabilities of the generated tokens will be included in the response.
	Logprobs *bool `json:"logprobs,omitempty" url:"-"`
	// contains filtered or unexported fields
}

func (*V2ChatStreamRequest) MarshalJSON added in v2.12.0

func (v *V2ChatStreamRequest) MarshalJSON() ([]byte, error)

func (*V2ChatStreamRequest) Stream added in v2.12.0

func (v *V2ChatStreamRequest) Stream() bool

func (*V2ChatStreamRequest) UnmarshalJSON added in v2.12.0

func (v *V2ChatStreamRequest) UnmarshalJSON(data []byte) error

type V2ChatStreamRequestDocumentsItem added in v2.12.0

type V2ChatStreamRequestDocumentsItem struct {
	String   string
	Document *Document
	// contains filtered or unexported fields
}

func (*V2ChatStreamRequestDocumentsItem) Accept added in v2.12.0

func (*V2ChatStreamRequestDocumentsItem) GetDocument added in v2.12.4

func (v *V2ChatStreamRequestDocumentsItem) GetDocument() *Document

func (*V2ChatStreamRequestDocumentsItem) GetString added in v2.12.4

func (V2ChatStreamRequestDocumentsItem) MarshalJSON added in v2.12.0

func (v V2ChatStreamRequestDocumentsItem) MarshalJSON() ([]byte, error)

func (*V2ChatStreamRequestDocumentsItem) UnmarshalJSON added in v2.12.0

func (v *V2ChatStreamRequestDocumentsItem) UnmarshalJSON(data []byte) error

type V2ChatStreamRequestDocumentsItemVisitor added in v2.12.0

type V2ChatStreamRequestDocumentsItemVisitor interface {
	VisitString(string) error
	VisitDocument(*Document) error
}

type V2ChatStreamRequestSafetyMode added in v2.12.0

type V2ChatStreamRequestSafetyMode string

Used to select the [safety instruction](https://docs.cohere.com/v2/docs/safety-modes) inserted into the prompt. Defaults to `CONTEXTUAL`. When `OFF` is specified, the safety instruction will be omitted.

Safety modes are not yet configurable in combination with `tools`, `tool_results` and `documents` parameters.

**Note**: This parameter is only compatible with models [Command R 08-2024](https://docs.cohere.com/v2/docs/command-r#august-2024-release), [Command R+ 08-2024](https://docs.cohere.com/v2/docs/command-r-plus#august-2024-release) and newer.

**Note**: `command-r7b-12-2024` only supports `"CONTEXTUAL"` and `"STRICT"` modes.

const (
	V2ChatStreamRequestSafetyModeContextual V2ChatStreamRequestSafetyMode = "CONTEXTUAL"
	V2ChatStreamRequestSafetyModeStrict     V2ChatStreamRequestSafetyMode = "STRICT"
	V2ChatStreamRequestSafetyModeOff        V2ChatStreamRequestSafetyMode = "OFF"
)

func NewV2ChatStreamRequestSafetyModeFromString added in v2.12.0

func NewV2ChatStreamRequestSafetyModeFromString(s string) (V2ChatStreamRequestSafetyMode, error)

func (V2ChatStreamRequestSafetyMode) Ptr added in v2.12.0

type V2EmbedRequest added in v2.12.0

type V2EmbedRequest struct {
	// An array of strings for the model to embed. Maximum number of texts per call is `96`. We recommend reducing the length of each text to be under `512` tokens for optimal quality.
	Texts []string `json:"texts,omitempty" url:"-"`
	// An array of image data URIs for the model to embed. Maximum number of images per call is `1`.
	//
	// The image must be a valid [data URI](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data). The image must be in either `image/jpeg` or `image/png` format and has a maximum size of 5MB.
	Images []string `json:"images,omitempty" url:"-"`
	// Defaults to embed-english-v2.0
	//
	// The identifier of the model. Smaller "light" models are faster, while larger models will perform better. [Custom models](https://docs.cohere.com/docs/training-custom-models) can also be supplied with their full ID.
	//
	// Available models and corresponding embedding dimensions:
	//
	// * `embed-english-v3.0`  1024
	// * `embed-multilingual-v3.0`  1024
	// * `embed-english-light-v3.0`  384
	// * `embed-multilingual-light-v3.0`  384
	//
	// * `embed-english-v2.0`  4096
	// * `embed-english-light-v2.0`  1024
	// * `embed-multilingual-v2.0`  768
	Model     string         `json:"model" url:"-"`
	InputType EmbedInputType `json:"input_type" url:"-"`
	// Specifies the types of embeddings you want to get back. Can be one or more of the following types.
	//
	// * `"float"`: Use this when you want to get back the default float embeddings. Valid for all models.
	// * `"int8"`: Use this when you want to get back signed int8 embeddings. Valid for only v3 models.
	// * `"uint8"`: Use this when you want to get back unsigned int8 embeddings. Valid for only v3 models.
	// * `"binary"`: Use this when you want to get back signed binary embeddings. Valid for only v3 models.
	// * `"ubinary"`: Use this when you want to get back unsigned binary embeddings. Valid for only v3 models.
	EmbeddingTypes []EmbeddingType `json:"embedding_types,omitempty" url:"-"`
	// One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length.
	//
	// Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.
	//
	// If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.
	Truncate *V2EmbedRequestTruncate `json:"truncate,omitempty" url:"-"`
}

type V2EmbedRequestTruncate added in v2.12.0

type V2EmbedRequestTruncate string

One of `NONE|START|END` to specify how the API will handle inputs longer than the maximum token length.

Passing `START` will discard the start of the input. `END` will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model.

If `NONE` is selected, when the input exceeds the maximum input token length an error will be returned.

const (
	V2EmbedRequestTruncateNone  V2EmbedRequestTruncate = "NONE"
	V2EmbedRequestTruncateStart V2EmbedRequestTruncate = "START"
	V2EmbedRequestTruncateEnd   V2EmbedRequestTruncate = "END"
)

func NewV2EmbedRequestTruncateFromString added in v2.12.0

func NewV2EmbedRequestTruncateFromString(s string) (V2EmbedRequestTruncate, error)

func (V2EmbedRequestTruncate) Ptr added in v2.12.0

type V2RerankRequest added in v2.12.0

type V2RerankRequest struct {
	// The identifier of the model to use, eg `rerank-v3.5`.
	Model string `json:"model" url:"-"`
	// The search query
	Query string `json:"query" url:"-"`
	// A list of texts that will be compared to the `query`.
	// For optimal performance we recommend against sending more than 1,000 documents in a single request.
	//
	// **Note**: long documents will automatically be truncated to the value of `max_tokens_per_doc`.
	//
	// **Note**: structured data should be formatted as YAML strings for best performance.
	Documents []string `json:"documents,omitempty" url:"-"`
	// Limits the number of returned rerank results to the specified value. If not passed, all the rerank results will be returned.
	TopN *int `json:"top_n,omitempty" url:"-"`
	// - If false, returns results without the doc text - the api will return a list of {index, relevance score} where index is inferred from the list passed into the request.
	// - If true, returns results with the doc text passed in - the api will return an ordered list of {index, text, relevance score} where index + text refers to the list passed into the request.
	ReturnDocuments *bool `json:"return_documents,omitempty" url:"-"`
	// Defaults to `4096`. Long documents will be automatically truncated to the specified number of tokens.
	MaxTokensPerDoc *int `json:"max_tokens_per_doc,omitempty" url:"-"`
}

type V2RerankResponse added in v2.12.0

type V2RerankResponse struct {
	Id *string `json:"id,omitempty" url:"id,omitempty"`
	// An ordered list of ranked documents
	Results []*V2RerankResponseResultsItem `json:"results,omitempty" url:"results,omitempty"`
	Meta    *ApiMeta                       `json:"meta,omitempty" url:"meta,omitempty"`
	// contains filtered or unexported fields
}

func (*V2RerankResponse) GetExtraProperties added in v2.12.0

func (v *V2RerankResponse) GetExtraProperties() map[string]interface{}

func (*V2RerankResponse) GetId added in v2.12.4

func (v *V2RerankResponse) GetId() *string

func (*V2RerankResponse) GetMeta added in v2.12.4

func (v *V2RerankResponse) GetMeta() *ApiMeta

func (*V2RerankResponse) GetResults added in v2.12.4

func (v *V2RerankResponse) GetResults() []*V2RerankResponseResultsItem

func (*V2RerankResponse) String added in v2.12.0

func (v *V2RerankResponse) String() string

func (*V2RerankResponse) UnmarshalJSON added in v2.12.0

func (v *V2RerankResponse) UnmarshalJSON(data []byte) error

type V2RerankResponseResultsItem added in v2.12.0

type V2RerankResponseResultsItem struct {
	// If `return_documents` is set as `false` this will return none, if `true` it will return the documents passed in
	Document *V2RerankResponseResultsItemDocument `json:"document,omitempty" url:"document,omitempty"`
	// Corresponds to the index in the original list of documents to which the ranked document belongs. (i.e. if the first value in the `results` object has an `index` value of 3, it means in the list of documents passed in, the document at `index=3` had the highest relevance)
	Index int `json:"index" url:"index"`
	// Relevance scores are normalized to be in the range `[0, 1]`. Scores close to `1` indicate a high relevance to the query, and scores closer to `0` indicate low relevance. It is not accurate to assume a score of 0.9 means the document is 2x more relevant than a document with a score of 0.45
	RelevanceScore float64 `json:"relevance_score" url:"relevance_score"`
	// contains filtered or unexported fields
}

func (*V2RerankResponseResultsItem) GetDocument added in v2.12.4

func (*V2RerankResponseResultsItem) GetExtraProperties added in v2.12.0

func (v *V2RerankResponseResultsItem) GetExtraProperties() map[string]interface{}

func (*V2RerankResponseResultsItem) GetIndex added in v2.12.4

func (v *V2RerankResponseResultsItem) GetIndex() int

func (*V2RerankResponseResultsItem) GetRelevanceScore added in v2.12.4

func (v *V2RerankResponseResultsItem) GetRelevanceScore() float64

func (*V2RerankResponseResultsItem) String added in v2.12.0

func (v *V2RerankResponseResultsItem) String() string

func (*V2RerankResponseResultsItem) UnmarshalJSON added in v2.12.0

func (v *V2RerankResponseResultsItem) UnmarshalJSON(data []byte) error

type V2RerankResponseResultsItemDocument added in v2.12.0

type V2RerankResponseResultsItemDocument struct {
	// The text of the document to rerank
	Text string `json:"text" url:"text"`
	// contains filtered or unexported fields
}

If `return_documents` is set as `false` this will return none, if `true` it will return the documents passed in

func (*V2RerankResponseResultsItemDocument) GetExtraProperties added in v2.12.0

func (v *V2RerankResponseResultsItemDocument) GetExtraProperties() map[string]interface{}

func (*V2RerankResponseResultsItemDocument) GetText added in v2.12.4

func (*V2RerankResponseResultsItemDocument) String added in v2.12.0

func (*V2RerankResponseResultsItemDocument) UnmarshalJSON added in v2.12.0

func (v *V2RerankResponseResultsItemDocument) UnmarshalJSON(data []byte) error

Directories

Path Synopsis
Finetuning API (Beta)
Finetuning API (Beta)

Jump to

Keyboard shortcuts

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