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

Add stream_options param; add usage in ChatCompletionChunk #248

Merged
merged 1 commit into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading