Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added usage models for run and runStep #28864

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions specification/ai/OpenAI.Assistants/run_steps/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,31 @@ model RunStep {
@doc("The Unix timestamp, in seconds, representing when this failed.")
failedAt: utcDateTime | null;

#suppress "@azure-tools/typespec-azure-core/no-nullable" "OpenAI uses explicit nullability, distinct from optionality"
@doc("Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`.")
@added(ServiceApiVersions.vFuturePlaceholder)
usage: RunStepCompletionUsage | null;

...RequiredNullableMetadata;
}

@doc("Usage statistics related to the run step.")
@added(ServiceApiVersions.vFuturePlaceholder)
model RunStepCompletionUsage {

@doc("Number of completion tokens used over the course of the run step.")
@encodedName("application/json", "completion_tokens")
completionTokens: int64;

@doc("Number of prompt tokens used over the course of the run step.")
@encodedName("application/json", "prompt_tokens")
promptTokens: int64;

@doc("Total number of tokens used (prompt + completion).")
@encodedName("application/json", "total_tokens")
totalTokens: int64;
}

@doc("The possible types of run steps.")
@added(ServiceApiVersions.v2024_02_15_preview)
union RunStepType {
Expand Down
22 changes: 22 additions & 0 deletions specification/ai/OpenAI.Assistants/runs/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,31 @@ model ThreadRun {
@doc("The Unix timestamp, in seconds, representing when this failed.")
failedAt: utcDateTime | null;

#suppress "@azure-tools/typespec-azure-core/no-nullable" "OpenAI uses explicit nullability, distinct from optionality"
@doc("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.).")
@added(ServiceApiVersions.vFuturePlaceholder)
usage: RunCompletionUsage | null;

...RequiredNullableMetadata;
}

@doc("Usage statistics related to the run.")
@added(ServiceApiVersions.vFuturePlaceholder)
model RunCompletionUsage {

@doc("Number of completion tokens used over the course of the run.")
@encodedName("application/json", "completion_tokens")
completionTokens: int64;

@doc("Number of prompt tokens used over the course of the run.")
@encodedName("application/json", "prompt_tokens")
promptTokens: int64;

@doc("Total number of tokens used (prompt + completion).")
@encodedName("application/json", "total_tokens")
totalTokens: int64;
}

@doc("The details used when creating a new run of an assistant thread.")
@added(ServiceApiVersions.v2024_02_15_preview)
model CreateRunOptions {
Expand Down