Skip to content

Commit 0aadd17

Browse files
authored
Add logprobs, and sync other changes (#142)
1 parent 98052b7 commit 0aadd17

File tree

1 file changed

+78
-16
lines changed

1 file changed

+78
-16
lines changed

openapi.yaml

Lines changed: 78 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ paths:
127127
"role": "assistant",
128128
"content": "\n\nHello there, how may I assist you today?",
129129
},
130+
"logprobs": null,
130131
"finish_reason": "stop"
131132
}],
132133
"usage": {
@@ -223,6 +224,7 @@ paths:
223224
"role": "assistant",
224225
"content": "\n\nHello there, how may I assist you today?",
225226
},
227+
"logprobs": null,
226228
"finish_reason": "stop"
227229
}],
228230
"usage": {
@@ -289,19 +291,19 @@ paths:
289291
290292
main();
291293
response: &chat_completion_chunk_example |
292-
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0613", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
294+
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0613", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}]}
293295

294-
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0613", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
296+
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0613", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]}
295297

296-
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0613", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}
298+
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0613", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}]}
297299

298300
....
299301

300-
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0613", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"content":" today"},"finish_reason":null}]}
302+
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0613", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"content":" today"},"logprobs":null,"finish_reason":null}]}
301303

302-
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0613", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"content":"?"},"finish_reason":null}]}
304+
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0613", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}]}
303305

304-
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0613", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
306+
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0613", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]}
305307
- title: Functions
306308
request:
307309
curl: |
@@ -436,7 +438,8 @@ paths:
436438
}
437439
]
438440
},
439-
"finish_reason": "tool_calls",
441+
"logprobs": null,
442+
"finish_reason": "tool_calls"
440443
}
441444
],
442445
"usage": {
@@ -1223,7 +1226,7 @@ paths:
12231226
summary: |
12241227
Upload a file that can be used across various endpoints. The size of all the files uploaded by one organization can be up to 100 GB.
12251228
1226-
The size of individual files can be a maximum of 512 MB. See the [Assistants Tools guide](/docs/assistants/tools) to learn more about the types of files supported. The Fine-tuning API only supports `.jsonl` files.
1229+
The size of individual files can be a maximum of 512 MB or 2 million tokens for Assistants. See the [Assistants Tools guide](/docs/assistants/tools) to learn more about the types of files supported. The Fine-tuning API only supports `.jsonl` files.
12271230
12281231
Please [contact us](https://help.openai.com/) if you need to increase these storage limits.
12291232
requestBody:
@@ -5453,7 +5456,7 @@ components:
54535456
default: null
54545457
nullable: true
54555458
description: &completions_logprobs_description |
5456-
Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.
5459+
Include the log probabilities on the `logprobs` most likely output tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.
54575460

54585461
The maximum value for `logprobs` is 5.
54595462
max_tokens:
@@ -5463,7 +5466,7 @@ components:
54635466
example: 16
54645467
nullable: true
54655468
description: &completions_max_tokens_description |
5466-
The maximum number of [tokens](/tokenizer) to generate in the completion.
5469+
The maximum number of [tokens](/tokenizer) that can be generated in the completion.
54675470

54685471
The token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens.
54695472
n:
@@ -5823,6 +5826,7 @@ components:
58235826
enum: ["function"]
58245827
description: The role of the messages author, in this case `function`.
58255828
content:
5829+
nullable: true
58265830
type: string
58275831
description: The contents of the function message.
58285832
name:
@@ -5835,7 +5839,7 @@ components:
58355839

58365840
FunctionParameters:
58375841
type: object
5838-
description: "The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/text-generation/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.\n\nOmitting `parameters` defines a function with an empty parameter list."
5842+
description: "The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/text-generation/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. \n\nOmitting `parameters` defines a function with an empty parameter list."
58395843
additionalProperties: true
58405844

58415845
ChatCompletionFunctions:
@@ -6109,9 +6113,20 @@ components:
61096113
Modify the likelihood of specified tokens appearing in the completion.
61106114
61116115
Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.
6116+
logprobs:
6117+
description: Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. This option is currently not available on the `gpt-4-vision-preview` model.
6118+
type: boolean
6119+
default: false
6120+
nullable: true
6121+
top_logprobs:
6122+
description: An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used.
6123+
type: integer
6124+
minimum: 0
6125+
maximum: 5
6126+
nullable: true
61126127
max_tokens:
61136128
description: |
6114-
The maximum number of [tokens](/tokenizer) to generate in the chat completion.
6129+
The maximum number of [tokens](/tokenizer) that can be generated in the chat completion.
61156130
61166131
The total length of input tokens and generated tokens is limited by the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens.
61176132
type: integer
@@ -6134,7 +6149,7 @@ components:
61346149
response_format:
61356150
type: object
61366151
description: |
6137-
An object specifying the format that the model must output.
6152+
An object specifying the format that the model must output. Compatible with `gpt-4-1106-preview` and `gpt-3.5-turbo-1106`.
61386153
61396154
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON.
61406155
@@ -6212,7 +6227,7 @@ components:
62126227
`auto` means the model can pick between generating a message or calling a function.
62136228
Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.
62146229
6215-
`none` is the default when no functions are present. `auto`` is the default if functions are present.
6230+
`none` is the default when no functions are present. `auto` is the default if functions are present.
62166231
oneOf:
62176232
- type: string
62186233
description: >
@@ -6253,6 +6268,7 @@ components:
62536268
- finish_reason
62546269
- index
62556270
- message
6271+
- logprobs
62566272
properties:
62576273
finish_reason:
62586274
type: string
@@ -6274,6 +6290,50 @@ components:
62746290
description: The index of the choice in the list of choices.
62756291
message:
62766292
$ref: "#/components/schemas/ChatCompletionResponseMessage"
6293+
logprobs: &chat_completion_response_logprobs
6294+
description: Log probability information for the choice.
6295+
type: object
6296+
nullable: true
6297+
properties:
6298+
content:
6299+
description: A list of message content tokens with log probability information.
6300+
type: array
6301+
items:
6302+
type: object
6303+
properties:
6304+
token: &chat_completion_response_logprobs_token
6305+
description: The token.
6306+
type: string
6307+
logprob: &chat_completion_response_logprobs_token_logprob
6308+
description: The log probability of this token.
6309+
type: number
6310+
bytes: &chat_completion_response_logprobs_bytes
6311+
description: A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
6312+
type: array
6313+
items:
6314+
type: integer
6315+
nullable: true
6316+
top_logprobs:
6317+
description: List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned.
6318+
type: array
6319+
items:
6320+
type: object
6321+
properties:
6322+
token: *chat_completion_response_logprobs_token
6323+
logprob: *chat_completion_response_logprobs_token_logprob
6324+
bytes: *chat_completion_response_logprobs_bytes
6325+
required:
6326+
- token
6327+
- logprob
6328+
- bytes
6329+
required:
6330+
- token
6331+
- logprob
6332+
- bytes
6333+
- top_logprobs
6334+
nullable: true
6335+
required:
6336+
- content
62776337
created:
62786338
type: integer
62796339
description: The Unix timestamp (in seconds) of when the chat completion was created.
@@ -6319,6 +6379,7 @@ components:
63196379
- finish_reason
63206380
- index
63216381
- message
6382+
- logprobs
63226383
properties:
63236384
finish_reason:
63246385
type: string
@@ -6396,6 +6457,7 @@ components:
63966457
properties:
63976458
delta:
63986459
$ref: "#/components/schemas/ChatCompletionStreamResponseDelta"
6460+
logprobs: *chat_completion_response_logprobs
63996461
finish_reason:
64006462
type: string
64016463
description: *chat_completion_finish_reason_description
@@ -8821,7 +8883,7 @@ components:
88218883
description: The identifier of the run step, which can be referenced in API endpoints.
88228884
type: string
88238885
object:
8824-
description: The object type, which is always `thread.run.step``.
8886+
description: The object type, which is always `thread.run.step`.
88258887
type: string
88268888
enum: ["thread.run.step"]
88278889
created_at:
@@ -8939,7 +9001,7 @@ components:
89399001
description: Details of the message creation by the run step.
89409002
properties:
89419003
type:
8942-
description: Always `message_creation``.
9004+
description: Always `message_creation`.
89439005
type: string
89449006
enum: ["message_creation"]
89459007
message_creation:

0 commit comments

Comments
 (0)