mistral_common.protocol.instruct.response
ChatCompletionResponse(**data)
Bases: MistralBase
A chat completion response.
See ChatCompletionRequest for the request.
Attributes:
Name | Type | Description |
---|---|---|
id |
str
|
The id of the response. |
object |
str
|
The object of the response. |
created |
int
|
The creation time of the response. |
model |
str
|
The model of the response. |
choices |
List[ChatCompletionResponseChoice]
|
The choices of the response. |
usage |
UsageInfo
|
The usage of the response. |
Examples:
>>> response = ChatCompletionResponse(
... id="chatcmpl-123",
... object="chat.completion",
... created=1677652288,
... model="mistral-tiny",
... choices=[
... ChatCompletionResponseChoice(index=0, message=DeltaMessage(role="user", content="Hello, world!"))
... ],
... usage=UsageInfo(prompt_tokens=10, total_tokens=20, completion_tokens=10),
... )
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
ChatCompletionResponseChoice(**data)
Bases: MistralBase
A choice in a chat completion.
Attributes:
Name | Type | Description |
---|---|---|
index |
int
|
The index of the choice. |
message |
DeltaMessage
|
The message of the choice. |
finish_reason |
Optional[FinishReason]
|
The finish reason of the choice. |
logprobs |
Optional[ChatCompletionResponseChoiceLogprobs]
|
The log probabilities of the choice. |
Examples:
>>> choice = ChatCompletionResponseChoice(index=0, message=DeltaMessage(role="user", content="Hello, world!"))
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
ChatCompletionResponseChoiceLogprobs(**data)
Bases: MistralBase
Log probabilities for a choice.
Attributes:
Name | Type | Description |
---|---|---|
content |
List[ChatCompletionTokenLogprobs]
|
The log probabilities for the content. |
Examples:
>>> choice_logprobs = ChatCompletionResponseChoiceLogprobs(
... content=[ChatCompletionTokenLogprobs(token="hello", logprob=-0.5, bytes=[104, 101, 108, 108, 111])]
... )
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
ChatCompletionResponseStreamChoice(**data)
Bases: MistralBase
A choice in a chat completion stream response.
Attributes:
Name | Type | Description |
---|---|---|
index |
int
|
The index of the choice. |
delta |
DeltaMessage
|
The delta of the choice. |
finish_reason |
Optional[FinishReason]
|
The finish reason of the choice. |
logprobs |
Optional[ChatCompletionResponseChoiceLogprobs]
|
The log probabilities of the choice. |
Examples:
>>> choice = ChatCompletionResponseStreamChoice(
... index=0, delta=DeltaMessage(role="user", content="Hello, world!")
... )
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
ChatCompletionStreamResponse(**data)
Bases: MistralBase
A chat completion stream response.
See ChatCompletionRequest for the request.
Attributes:
Name | Type | Description |
---|---|---|
id |
str
|
The id of the response. |
object |
str
|
The object of the response. |
created |
int
|
The creation time of the response. |
model |
str
|
The model of the response. |
choices |
List[ChatCompletionResponseStreamChoice]
|
The choices of the response. |
usage |
Optional[UsageInfo]
|
The usage of the response. |
Examples:
>>> response = ChatCompletionStreamResponse(
... id="chatcmpl-123",
... object="chat.completion.chunk",
... created=1677652288,
... model="mistral-tiny",
... choices=[
... ChatCompletionResponseStreamChoice(index=0, delta=DeltaMessage(role="user", content="Hello, world!"))
... ],
... usage=UsageInfo(prompt_tokens=10, total_tokens=20, completion_tokens=10),
... )
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
ChatCompletionTokenLogprobs(**data)
Bases: MistralBase
Log probabilities for a token.
Attributes:
Name | Type | Description |
---|---|---|
token |
str
|
The token. |
logprob |
float
|
The log probability of the token. |
bytes |
List[int]
|
The bytes of the token. |
Examples:
>>> token_logprobs = ChatCompletionTokenLogprobs(token="hello", logprob=-0.5, bytes=[104, 101, 108, 108, 111])
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
DeltaMessage(**data)
Bases: MistralBase
A message in a chat completion.
Attributes:
Name | Type | Description |
---|---|---|
role |
Optional[str]
|
The role of the message. |
content |
Optional[str]
|
The content of the message. |
tool_calls |
Optional[List[ToolCall]]
|
The tool calls in the message. |
Examples:
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
FinishReason
Possible finish reasons.
Attributes:
Name | Type | Description |
---|---|---|
stop |
The model hit a natural stop point or a provided stop sequence. |
|
length |
The maximum number of tokens specified in the request was reached. |
|
model_length |
The model hit its context length limit. |
|
error |
An error occurred during generation. |
|
tool_calls |
The model called a tool. |
Examples: