From 9bc52d4b1f33053f09ec50105194c03e33d6c2a8 Mon Sep 17 00:00:00 2001 From: Steve Coffey Date: Thu, 18 Jan 2024 18:29:16 -0800 Subject: [PATCH 1/4] update openapi spec to add usage to run/runstep --- openapi.yaml | 80 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 8 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 244b86d8..535eb386 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -3638,7 +3638,8 @@ paths: "instructions": "You are a helpful assistant.", "tools": [], "file_ids": [], - "metadata": {} + "metadata": {}, + "usage": null } /threads/{thread_id}/runs: @@ -3747,7 +3748,12 @@ paths: "file-abc123", "file-abc456" ], - "metadata": {} + "metadata": {}, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 + } }, { "id": "run_abc456", @@ -3773,7 +3779,12 @@ paths: "file-abc123", "file-abc456" ], - "metadata": {} + "metadata": {}, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 + } } ], "first_id": "run_abc123", @@ -3869,7 +3880,8 @@ paths: "file-abc123", "file-abc456" ], - "metadata": {} + "metadata": {}, + "usage": null } /threads/{thread_id}/runs/{run_id}: @@ -3958,7 +3970,12 @@ paths: "file-abc123", "file-abc456" ], - "metadata": {} + "metadata": {}, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 + } } post: operationId: modifyRun @@ -4065,6 +4082,11 @@ paths: ], "metadata": { "user_id": "user_abc123" + }, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 } } @@ -4204,7 +4226,8 @@ paths: } ], "file_ids": [], - "metadata": {} + "metadata": {}, + "usage": null } /threads/{thread_id}/runs/{run_id}/cancel: @@ -4291,7 +4314,8 @@ paths: } ], "file_ids": [], - "metadata": {} + "metadata": {}, + "usage": null } /threads/{thread_id}/runs/{run_id}/steps: @@ -4401,6 +4425,11 @@ paths: "message_creation": { "message_id": "msg_abc123" } + }, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 } } ], @@ -4497,6 +4526,11 @@ paths: "message_creation": { "message_id": "msg_abc123" } + }, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 } } @@ -7179,6 +7213,25 @@ components: - completion_tokens - total_tokens + AssistantsCompletionUsage: + type: object + description: Usage statistics for a [Run](/docs/api-reference/runs/object) or [RunStep](rdocs/api-reference/runs/step-object) object. If the parent resources is still pending, this value will be null. + properties: + completion_tokens: + type: integer + description: Number of tokens in the used in the parent Run or RunStep. + prompt_tokens: + type: integer + description: Number of prompt tokens used in the parent Run or RunStep. + total_tokens: + type: integer + description: Total number of tokens used (prompt + completion). + required: + - prompt_tokens + - completion_tokens + - total_tokens + nullable: true + AssistantObject: type: object title: Assistant @@ -7555,6 +7608,8 @@ components: type: object x-oaiTypeLabel: map nullable: true + usage: + $ref: "#/components/schemas/AssistantsCompletionUsage" required: - id - object @@ -7574,6 +7629,7 @@ components: - tools - file_ids - metadata + - usage x-oaiMeta: name: The run object beta: true @@ -7595,7 +7651,12 @@ components: "instructions": null, "tools": [{"type": "retrieval"}, {"type": "code_interpreter"}], "file_ids": [], - "metadata": {} + "metadata": {}, + "usage": { + "prompt_tokens": 123, + "completion_tokens": 456, + "total_tokens": 579 + } } CreateRunRequest: type: object @@ -8217,6 +8278,8 @@ components: type: object x-oaiTypeLabel: map nullable: true + usage: + $ref: "#/components/schemas/AssistantsCompletionUsage" required: - id - object @@ -8233,6 +8296,7 @@ components: - failed_at - completed_at - metadata + - usage x-oaiMeta: name: The run step object beta: true From 9cd77a4177be188f9cd66b13a841a855cadedf5c Mon Sep 17 00:00:00 2001 From: Steve Coffey Date: Thu, 18 Jan 2024 18:31:38 -0800 Subject: [PATCH 2/4] fixup! update openapi spec to add usage to run/runstep --- openapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi.yaml b/openapi.yaml index 535eb386..3115dc6a 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7215,7 +7215,7 @@ components: AssistantsCompletionUsage: type: object - description: Usage statistics for a [Run](/docs/api-reference/runs/object) or [RunStep](rdocs/api-reference/runs/step-object) object. If the parent resources is still pending, this value will be null. + description: Usage statistics for a [Run](/docs/api-reference/runs/object) or [RunStep](rdocs/api-reference/runs/step-object) object. If the parent resource is still pending, this value will be null. properties: completion_tokens: type: integer From 6744821721897803c134ebd03e667c4a87eb6c4a Mon Sep 17 00:00:00 2001 From: Steve Coffey Date: Thu, 18 Jan 2024 23:02:18 -0800 Subject: [PATCH 3/4] sync api docs from onboard --- openapi.yaml | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 3115dc6a..6b223fa5 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7212,17 +7212,36 @@ components: - prompt_tokens - completion_tokens - total_tokens + - + RunCompletionUsage: + type: object + description: 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.). + properties: + completion_tokens: + type: integer + description: Number of tokens used in the used in the parent Run. + prompt_tokens: + type: integer + description: Number of prompt tokens used in the parent Run. + total_tokens: + type: integer + description: Total number of tokens used (prompt + completion). + required: + - prompt_tokens + - completion_tokens + - total_tokens + nullable: true - AssistantsCompletionUsage: + RunStepCompletionUsage: type: object - description: Usage statistics for a [Run](/docs/api-reference/runs/object) or [RunStep](rdocs/api-reference/runs/step-object) object. If the parent resource is still pending, this value will be null. + description: Usage statistics related to the run step. This value will be null while the run step is in progress. properties: completion_tokens: type: integer - description: Number of tokens in the used in the parent Run or RunStep. + description: Number of tokens used in the used in the parent RunStep. prompt_tokens: type: integer - description: Number of prompt tokens used in the parent Run or RunStep. + description: Number of prompt tokens used in the parent RunStep. total_tokens: type: integer description: Total number of tokens used (prompt + completion). @@ -7609,7 +7628,7 @@ components: x-oaiTypeLabel: map nullable: true usage: - $ref: "#/components/schemas/AssistantsCompletionUsage" + $ref: "#/components/schemas/RunCompletionUsage" required: - id - object @@ -8279,7 +8298,7 @@ components: x-oaiTypeLabel: map nullable: true usage: - $ref: "#/components/schemas/AssistantsCompletionUsage" + $ref: "#/components/schemas/RunStepCompletionUsage" required: - id - object From 969556e2721e1e1892d67196949cc00bcdad1d3d Mon Sep 17 00:00:00 2001 From: Steve Coffey Date: Fri, 19 Jan 2024 09:51:30 -0800 Subject: [PATCH 4/4] sync docs from onboard --- openapi.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 6b223fa5..6709cdbc 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7212,17 +7212,17 @@ components: - prompt_tokens - completion_tokens - total_tokens - - + RunCompletionUsage: type: object - description: 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.). + description: 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.). properties: completion_tokens: type: integer - description: Number of tokens used in the used in the parent Run. + description: Number of completion tokens used over the course of the run. prompt_tokens: type: integer - description: Number of prompt tokens used in the parent Run. + description: Number of prompt tokens used over the course of the run. total_tokens: type: integer description: Total number of tokens used (prompt + completion). @@ -7234,14 +7234,14 @@ components: RunStepCompletionUsage: type: object - description: Usage statistics related to the run step. This value will be null while the run step is in progress. + description: Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. properties: completion_tokens: type: integer - description: Number of tokens used in the used in the parent RunStep. + description: Number of completion tokens used over the course of the run step. prompt_tokens: type: integer - description: Number of prompt tokens used in the parent RunStep. + description: Number of prompt tokens used over the course of the run step. total_tokens: type: integer description: Total number of tokens used (prompt + completion).