Skip to content

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Nov 11, 2024
1 parent f736ded commit 7765aaf
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 13 deletions.
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,9 @@ func (c *Client) Generate(
return response, nil
}

// This endpoint returns text embeddings. An embedding is a list of floating point numbers that captures semantic information about the text that it represents.
// This endpoint returns text and image embeddings. An embedding is a list of floating point numbers that captures semantic information about the content that it represents.
//
// Embeddings can be used to create text classifiers as well as empower semantic search. To learn more about embeddings, see the embedding page.
// Embeddings can be used to create classifiers as well as empower semantic search. To learn more about embeddings, see the embedding page.
//
// If you want to learn more how to use the embedding model, have a look at the [Semantic Search Guide](/docs/semantic-search).
func (c *Client) Embed(
Expand Down
2 changes: 1 addition & 1 deletion connectors/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (c *Client) List(
return response, nil
}

// Creates a new connector. The connector is tested during registration and will cancel registration when the test is unsuccessful. See ['Creating and Deploying a Connector'](https://docs.cohere.com/docs/creating-and-deploying-a-connector) for more information.
// Creates a new connector. The connector is tested during registration and will cancel registration when the test is unsuccessful. See ['Creating and Deploying a Connector'](https://docs.cohere.com/v1/docs/creating-and-deploying-a-connector) for more information.
func (c *Client) Create(
ctx context.Context,
request *v2.CreateConnectorRequest,
Expand Down
2 changes: 1 addition & 1 deletion core/request_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (r *RequestOptions) cloneHeader() http.Header {
headers := r.HTTPHeader.Clone()
headers.Set("X-Fern-Language", "Go")
headers.Set("X-Fern-SDK-Name", "github.com/cohere-ai/cohere-go/v2")
headers.Set("X-Fern-SDK-Version", "v2.12.0")
headers.Set("X-Fern-SDK-Version", "v2.12.1")
return headers
}

Expand Down
125 changes: 118 additions & 7 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type ChatRequest struct {
// - 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/docs/creating-and-deploying-a-connector) one.
// 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).
//
Expand Down Expand Up @@ -293,7 +293,7 @@ type ChatStreamRequest struct {
// - 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/docs/creating-and-deploying-a-connector) one.
// 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).
//
Expand Down Expand Up @@ -864,6 +864,8 @@ func (a *ApiMetaApiVersion) String() string {
}

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.
Expand Down Expand Up @@ -1798,6 +1800,47 @@ func (c *ChatDataMetrics) String() string {
return fmt.Sprintf("%#v", c)
}

type ChatDebugEvent struct {
Prompt *string `json:"prompt,omitempty" url:"prompt,omitempty"`

extraProperties map[string]interface{}
_rawJSON json.RawMessage
}

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

func (c *ChatDebugEvent) UnmarshalJSON(data []byte) error {
type unmarshaler ChatDebugEvent
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*c = ChatDebugEvent(value)

extraProperties, err := core.ExtractExtraProperties(data, *c)
if err != nil {
return err
}
c.extraProperties = extraProperties

c._rawJSON = json.RawMessage(data)
return nil
}

func (c *ChatDebugEvent) String() string {
if len(c._rawJSON) > 0 {
if value, err := core.StringifyJSON(c._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(c); err == nil {
return value
}
return fmt.Sprintf("%#v", c)
}

// 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
Expand Down Expand Up @@ -5022,7 +5065,9 @@ type EmbedByTypeResponse struct {
Embeddings *EmbedByTypeResponseEmbeddings `json:"embeddings,omitempty" url:"embeddings,omitempty"`
// The text entries for which embeddings were returned.
Texts []string `json:"texts,omitempty" url:"texts,omitempty"`
Meta *ApiMeta `json:"meta,omitempty" url:"meta,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"`

extraProperties map[string]interface{}
_rawJSON json.RawMessage
Expand Down Expand Up @@ -5119,7 +5164,9 @@ type EmbedFloatsResponse struct {
Embeddings [][]float64 `json:"embeddings,omitempty" url:"embeddings,omitempty"`
// The text entries for which embeddings were returned.
Texts []string `json:"texts,omitempty" url:"texts,omitempty"`
Meta *ApiMeta `json:"meta,omitempty" url:"meta,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"`

extraProperties map[string]interface{}
_rawJSON json.RawMessage
Expand Down Expand Up @@ -6127,6 +6174,54 @@ func (g *GetModelResponse) String() string {
return fmt.Sprintf("%#v", g)
}

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"`

extraProperties map[string]interface{}
_rawJSON json.RawMessage
}

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

func (i *Image) UnmarshalJSON(data []byte) error {
type unmarshaler Image
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*i = Image(value)

extraProperties, err := core.ExtractExtraProperties(data, *i)
if err != nil {
return err
}
i.extraProperties = extraProperties

i._rawJSON = json.RawMessage(data)
return nil
}

func (i *Image) String() string {
if len(i._rawJSON) > 0 {
if value, err := core.StringifyJSON(i._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(i); err == nil {
return value
}
return fmt.Sprintf("%#v", i)
}

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](/docs/structured-outputs-json#schema-constraints) for more information.
// Example (required name and age object):
Expand Down Expand Up @@ -6636,6 +6731,8 @@ type NonStreamedChatResponse struct {
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.
Expand Down Expand Up @@ -7391,6 +7488,7 @@ type StreamedChatResponse struct {
ToolCallsGeneration *ChatToolCallsGenerationEvent
StreamEnd *ChatStreamEndEvent
ToolCallsChunk *ChatToolCallsChunkEvent
Debug *ChatDebugEvent
}

func (s *StreamedChatResponse) UnmarshalJSON(data []byte) error {
Expand Down Expand Up @@ -7453,6 +7551,12 @@ func (s *StreamedChatResponse) UnmarshalJSON(data []byte) error {
return err
}
s.ToolCallsChunk = value
case "debug":
value := new(ChatDebugEvent)
if err := json.Unmarshal(data, &value); err != nil {
return err
}
s.Debug = value
}
return nil
}
Expand Down Expand Up @@ -7482,6 +7586,9 @@ func (s StreamedChatResponse) MarshalJSON() ([]byte, error) {
if s.ToolCallsChunk != nil {
return core.MarshalJSONWithExtraProperty(s.ToolCallsChunk, "event_type", "tool-calls-chunk")
}
if s.Debug != nil {
return core.MarshalJSONWithExtraProperty(s.Debug, "event_type", "debug")
}
return nil, fmt.Errorf("type %T does not define a non-empty union type", s)
}

Expand All @@ -7494,6 +7601,7 @@ type StreamedChatResponseVisitor interface {
VisitToolCallsGeneration(*ChatToolCallsGenerationEvent) error
VisitStreamEnd(*ChatStreamEndEvent) error
VisitToolCallsChunk(*ChatToolCallsChunkEvent) error
VisitDebug(*ChatDebugEvent) error
}

func (s *StreamedChatResponse) Accept(visitor StreamedChatResponseVisitor) error {
Expand Down Expand Up @@ -7521,6 +7629,9 @@ func (s *StreamedChatResponse) Accept(visitor StreamedChatResponseVisitor) error
if s.ToolCallsChunk != nil {
return visitor.VisitToolCallsChunk(s.ToolCallsChunk)
}
if s.Debug != nil {
return visitor.VisitDebug(s.Debug)
}
return fmt.Errorf("type %T does not define a non-empty union type", s)
}

Expand Down Expand Up @@ -8506,11 +8617,11 @@ func (t *ToolMessage) String() string {
return fmt.Sprintf("%#v", t)
}

// A message from the system.
// A message with Tool outputs.
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"`
// A single or list of outputs from a tool. The content should formatted as a JSON object string, or a list of tool content blocks
// 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"`

extraProperties map[string]interface{}
Expand Down Expand Up @@ -8551,7 +8662,7 @@ func (t *ToolMessageV2) String() string {
return fmt.Sprintf("%#v", t)
}

// A single or list of outputs from a tool. The content should formatted as a JSON object string, or a list of tool content blocks
// Outputs from a tool. The content should formatted as a JSON object string, or a list of tool content blocks
type ToolMessageV2Content struct {
String string
ToolContentList []*ToolContent
Expand Down
4 changes: 2 additions & 2 deletions v2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewClient(opts ...option.RequestOption) *Client {
}
}

// Generates a message from the model in response to a provided conversation. To learn more about the features of the Chat API follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api).
// Generates a text response to a user message and streams it down, token by token. To learn how to use the Chat API with streaming follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api).
//
// Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2) for instructions on moving from API v1 to API v2.
func (c *Client) ChatStream(
Expand Down Expand Up @@ -168,7 +168,7 @@ func (c *Client) ChatStream(
)
}

// Generates a message from the model in response to a provided conversation. To learn more about the features of the Chat API follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api).
// Generates a text response to a user message and streams it down, token by token. To learn how to use the Chat API with streaming follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api).
//
// Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2) for instructions on moving from API v1 to API v2.
func (c *Client) Chat(
Expand Down

0 comments on commit 7765aaf

Please sign in to comment.