Skip to content

Commit

Permalink
Merge pull request #248 from openai/brianz/stream-options-2
Browse files Browse the repository at this point in the history
Add stream_options param; add usage in ChatCompletionChunk
  • Loading branch information
brianz-openai authored May 6, 2024
2 parents 25d9dac + 3bbc26b commit b4d127c
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7212,6 +7212,8 @@ components:
type: boolean
nullable: true
default: false
stream_options:
$ref: "#/components/schemas/ChatCompletionStreamOptions"
suffix:
description: |
The suffix that comes after a completion of inserted text.
Expand Down Expand Up @@ -7697,6 +7699,18 @@ components:
- tool
- function

ChatCompletionStreamOptions:
description: |
Options for streaming response. Only set this when you set `stream: true`.
type: object
nullable: true
default: null
properties:
include_usage:
type: boolean
description: |
If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.
ChatCompletionResponseMessage:
type: object
description: A chat completion message generated by the model.
Expand Down Expand Up @@ -7891,6 +7905,8 @@ components:
type: boolean
nullable: true
default: false
stream_options:
$ref: "#/components/schemas/ChatCompletionStreamOptions"
temperature:
type: number
minimum: 0
Expand Down Expand Up @@ -8150,7 +8166,9 @@ components:
description: A unique identifier for the chat completion. Each chunk has the same ID.
choices:
type: array
description: A list of chat completion choices. Can be more than one if `n` is greater than 1.
description: |
A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the
last chunk if you set `stream_options: {"include_usage": true}`.
items:
type: object
required:
Expand Down Expand Up @@ -8191,6 +8209,25 @@ components:
type: string
description: The object type, which is always `chat.completion.chunk`.
enum: [chat.completion.chunk]
usage:
type: object
description: |
An optional field that will only be present when you set `stream_options: {"include_usage": true}` in your request.
When present, it contains a null value except for the last chunk which contains the token usage statistics for the entire request.
properties:
completion_tokens:
type: integer
description: Number of tokens in the generated completion.
prompt_tokens:
type: integer
description: Number of tokens in the prompt.
total_tokens:
type: integer
description: Total number of tokens used in the request (prompt + completion).
required:
- prompt_tokens
- completion_tokens
- total_tokens
required:
- choices
- created
Expand Down

0 comments on commit b4d127c

Please sign in to comment.