Skip to content

Commit

Permalink
feat(api): api update (#3849)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jan 30, 2025
1 parent 7bf754b commit 5af08cf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1493
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-44581b9482743df3b0ea5bd5f20750f379d2d81d73a8d78eb86e525938fca96e.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-45e2bf6da4c3bb8d5a1b7b45606cbb125417f078418c5f0bc542a199cef669a7.yml
34 changes: 33 additions & 1 deletion ai/ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,17 @@ type AIRunResponseObject struct {
Response string `json:"response"`
// An array of tool calls requests made during the response generation
ToolCalls []AIRunResponseObjectToolCall `json:"tool_calls"`
JSON aiRunResponseObjectJSON `json:"-"`
// Usage statistics for the inference request
Usage AIRunResponseObjectUsage `json:"usage"`
JSON aiRunResponseObjectJSON `json:"-"`
}

// aiRunResponseObjectJSON contains the JSON metadata for the struct
// [AIRunResponseObject]
type aiRunResponseObjectJSON struct {
Response apijson.Field
ToolCalls apijson.Field
Usage apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
Expand Down Expand Up @@ -419,6 +422,35 @@ func (r aiRunResponseObjectToolCallJSON) RawJSON() string {
return r.raw
}

// Usage statistics for the inference request
type AIRunResponseObjectUsage struct {
// Total number of tokens in output
CompletionTokens float64 `json:"completion_tokens"`
// Total number of tokens in input
PromptTokens float64 `json:"prompt_tokens"`
// Total number of input and output tokens
TotalTokens float64 `json:"total_tokens"`
JSON aiRunResponseObjectUsageJSON `json:"-"`
}

// aiRunResponseObjectUsageJSON contains the JSON metadata for the struct
// [AIRunResponseObjectUsage]
type aiRunResponseObjectUsageJSON struct {
CompletionTokens apijson.Field
PromptTokens apijson.Field
TotalTokens apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *AIRunResponseObjectUsage) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r aiRunResponseObjectUsageJSON) RawJSON() string {
return r.raw
}

type AIRunResponseTranslation struct {
// The translated text in the target language
TranslatedText string `json:"translated_text"`
Expand Down

0 comments on commit 5af08cf

Please sign in to comment.