Skip to content

Commit

Permalink
feat(api): add usage to runs and run steps (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Jan 20, 2024
1 parent c4f8a36 commit 3caa416
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/resources/beta/threads/runs/runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ export interface Run {
* this run.
*/
tools: Array<Run.AssistantToolsCode | Run.AssistantToolsRetrieval | Run.AssistantToolsFunction>;

/**
* Usage statistics related to the run. This value will be `null` if the run is not
* in a terminal state (i.e. `in_progress`, `queued`, etc.).
*/
usage: Run.Usage | null;
}

export namespace Run {
Expand Down Expand Up @@ -332,6 +338,27 @@ export namespace Run {
*/
type: 'function';
}

/**
* Usage statistics related to the run. This value will be `null` if the run is not
* in a terminal state (i.e. `in_progress`, `queued`, etc.).
*/
export interface Usage {
/**
* Number of completion tokens used over the course of the run.
*/
completion_tokens: number;

/**
* Number of prompt tokens used over the course of the run.
*/
prompt_tokens: number;

/**
* Total number of tokens used (prompt + completion).
*/
total_tokens: number;
}
}

export interface RunCreateParams {
Expand Down
27 changes: 27 additions & 0 deletions src/resources/beta/threads/runs/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ export interface RunStep {
* The type of run step, which can be either `message_creation` or `tool_calls`.
*/
type: 'message_creation' | 'tool_calls';

/**
* Usage statistics related to the run step. This value will be `null` while the
* run step's status is `in_progress`.
*/
usage: RunStep.Usage | null;
}

export namespace RunStep {
Expand All @@ -318,6 +324,27 @@ export namespace RunStep {
*/
message: string;
}

/**
* Usage statistics related to the run step. This value will be `null` while the
* run step's status is `in_progress`.
*/
export interface Usage {
/**
* Number of completion tokens used over the course of the run step.
*/
completion_tokens: number;

/**
* Number of prompt tokens used over the course of the run step.
*/
prompt_tokens: number;

/**
* Total number of tokens used (prompt + completion).
*/
total_tokens: number;
}
}

/**
Expand Down

0 comments on commit 3caa416

Please sign in to comment.