chat_completion_chunk
Classes:
Name | Description |
---|---|
ChatCompletionChunk |
|
Choice |
|
ChoiceDelta |
|
ChoiceDeltaFunctionCall |
|
ChoiceDeltaToolCall |
|
ChoiceDeltaToolCallFunction |
|
ChoiceLogprobs |
|
ChatCompletionChunk
Attributes:
Name | Type | Description |
---|---|---|
choices |
List[Choice]
|
A list of chat completion choices. |
created |
int
|
The Unix timestamp (in seconds) of when the chat completion was created. |
id |
str
|
A unique identifier for the chat completion. Each chunk has the same ID. |
model |
str
|
The model to generate the completion. |
object |
Literal['chat.completion.chunk']
|
The object type, which is always |
system_fingerprint |
Optional[str]
|
This fingerprint represents the backend configuration that the model runs with. |
choices
instance-attribute
A list of chat completion choices.
Can be more than one if n
is greater than 1.
created
instance-attribute
created: int
The Unix timestamp (in seconds) of when the chat completion was created.
Each chunk has the same timestamp.
id
instance-attribute
id: str
A unique identifier for the chat completion. Each chunk has the same ID.
object
instance-attribute
The object type, which is always chat.completion.chunk
.
system_fingerprint
class-attribute
instance-attribute
This fingerprint represents the backend configuration that the model runs with.
Can be used in conjunction with the seed
request parameter to understand when
backend changes have been made that might impact determinism.
Choice
Attributes:
Name | Type | Description |
---|---|---|
delta |
ChoiceDelta
|
A chat completion delta generated by streamed model responses. |
finish_reason |
Optional[Literal['stop', 'length', 'tool_calls', 'content_filter', 'function_call']]
|
The reason the model stopped generating tokens. |
index |
int
|
The index of the choice in the list of choices. |
logprobs |
Optional[ChoiceLogprobs]
|
Log probability information for the choice. |
delta
instance-attribute
delta: ChoiceDelta
A chat completion delta generated by streamed model responses.
finish_reason
class-attribute
instance-attribute
finish_reason: Optional[
Literal[
"stop",
"length",
"tool_calls",
"content_filter",
"function_call",
]
] = None
The reason the model stopped generating tokens.
This will be stop
if the model hit a natural stop point or a provided stop
sequence, length
if the maximum number of tokens specified in the request was
reached, content_filter
if content was omitted due to a flag from our content
filters, tool_calls
if the model called a tool, or function_call
(deprecated) if the model called a function.
logprobs
class-attribute
instance-attribute
logprobs: Optional[ChoiceLogprobs] = None
Log probability information for the choice.
ChoiceDelta
Attributes:
Name | Type | Description |
---|---|---|
content |
Optional[str]
|
The contents of the chunk message. |
function_call |
Optional[ChoiceDeltaFunctionCall]
|
Deprecated and replaced by |
role |
Optional[Literal['system', 'user', 'assistant', 'tool']]
|
The role of the author of this message. |
tool_calls |
Optional[List[ChoiceDeltaToolCall]]
|
|
content
class-attribute
instance-attribute
The contents of the chunk message.
function_call
class-attribute
instance-attribute
function_call: Optional[ChoiceDeltaFunctionCall] = None
Deprecated and replaced by tool_calls
.
The name and arguments of a function that should be called, as generated by the model.
role
class-attribute
instance-attribute
role: Optional[
Literal["system", "user", "assistant", "tool"]
] = None
The role of the author of this message.
tool_calls
class-attribute
instance-attribute
tool_calls: Optional[List[ChoiceDeltaToolCall]] = None
ChoiceDeltaFunctionCall
Attributes:
Name | Type | Description |
---|---|---|
arguments |
Optional[str]
|
The arguments to call the function with, as generated by the model in JSON |
name |
Optional[str]
|
The name of the function to call. |
arguments
class-attribute
instance-attribute
The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
ChoiceDeltaToolCall
Attributes:
Name | Type | Description |
---|---|---|
function |
Optional[ChoiceDeltaToolCallFunction]
|
|
id |
Optional[str]
|
The ID of the tool call. |
index |
int
|
|
type |
Optional[Literal['function']]
|
The type of the tool. Currently, only |
type
class-attribute
instance-attribute
type: Optional[Literal['function']] = None
The type of the tool. Currently, only function
is supported.
ChoiceDeltaToolCallFunction
Attributes:
Name | Type | Description |
---|---|---|
arguments |
Optional[str]
|
The arguments to call the function with, as generated by the model in JSON |
name |
Optional[str]
|
The name of the function to call. |
arguments
class-attribute
instance-attribute
The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
ChoiceLogprobs
Attributes:
Name | Type | Description |
---|---|---|
content |
Optional[List[ChatCompletionTokenLogprob]]
|
A list of message content tokens with log probability information. |
content
class-attribute
instance-attribute
content: Optional[List[ChatCompletionTokenLogprob]] = None
A list of message content tokens with log probability information.