Skip to content

Commit d8737cb

Browse files
stainless-botmegamanics
authored andcommitted
feat: add None default value to nullable response properties (openai#1043)
1 parent cbf9a2e commit d8737cb

14 files changed

+39
-39
lines changed

Diff for: src/openai/_exceptions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class APIError(OpenAIError):
4040
If there was no response associated with this error then it will be `None`.
4141
"""
4242

43-
code: Optional[str]
44-
param: Optional[str]
43+
code: Optional[str] = None
44+
param: Optional[str] = None
4545
type: Optional[str]
4646

4747
def __init__(self, message: str, request: httpx.Request, *, body: object | None) -> None:

Diff for: src/openai/types/beta/assistant.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Assistant(BaseModel):
3737
created_at: int
3838
"""The Unix timestamp (in seconds) for when the assistant was created."""
3939

40-
description: Optional[str]
40+
description: Optional[str] = None
4141
"""The description of the assistant. The maximum length is 512 characters."""
4242

4343
file_ids: List[str]
@@ -47,13 +47,13 @@ class Assistant(BaseModel):
4747
assistant. Files are ordered by their creation date in ascending order.
4848
"""
4949

50-
instructions: Optional[str]
50+
instructions: Optional[str] = None
5151
"""The system instructions that the assistant uses.
5252
5353
The maximum length is 32768 characters.
5454
"""
5555

56-
metadata: Optional[builtins.object]
56+
metadata: Optional[builtins.object] = None
5757
"""Set of 16 key-value pairs that can be attached to an object.
5858
5959
This can be useful for storing additional information about the object in a
@@ -71,7 +71,7 @@ class Assistant(BaseModel):
7171
descriptions of them.
7272
"""
7373

74-
name: Optional[str]
74+
name: Optional[str] = None
7575
"""The name of the assistant. The maximum length is 256 characters."""
7676

7777
object: Literal["assistant"]

Diff for: src/openai/types/beta/thread.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Thread(BaseModel):
1616
created_at: int
1717
"""The Unix timestamp (in seconds) for when the thread was created."""
1818

19-
metadata: Optional[builtins.object]
19+
metadata: Optional[builtins.object] = None
2020
"""Set of 16 key-value pairs that can be attached to an object.
2121
2222
This can be useful for storing additional information about the object in a

Diff for: src/openai/types/beta/threads/run.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ class Run(BaseModel):
7272
execution of this run.
7373
"""
7474

75-
cancelled_at: Optional[int]
75+
cancelled_at: Optional[int] = None
7676
"""The Unix timestamp (in seconds) for when the run was cancelled."""
7777

78-
completed_at: Optional[int]
78+
completed_at: Optional[int] = None
7979
"""The Unix timestamp (in seconds) for when the run was completed."""
8080

8181
created_at: int
@@ -84,7 +84,7 @@ class Run(BaseModel):
8484
expires_at: int
8585
"""The Unix timestamp (in seconds) for when the run will expire."""
8686

87-
failed_at: Optional[int]
87+
failed_at: Optional[int] = None
8888
"""The Unix timestamp (in seconds) for when the run failed."""
8989

9090
file_ids: List[str]
@@ -101,10 +101,10 @@ class Run(BaseModel):
101101
this run.
102102
"""
103103

104-
last_error: Optional[LastError]
104+
last_error: Optional[LastError] = None
105105
"""The last error associated with this run. Will be `null` if there are no errors."""
106106

107-
metadata: Optional[builtins.object]
107+
metadata: Optional[builtins.object] = None
108108
"""Set of 16 key-value pairs that can be attached to an object.
109109
110110
This can be useful for storing additional information about the object in a
@@ -122,13 +122,13 @@ class Run(BaseModel):
122122
object: Literal["thread.run"]
123123
"""The object type, which is always `thread.run`."""
124124

125-
required_action: Optional[RequiredAction]
125+
required_action: Optional[RequiredAction] = None
126126
"""Details on the action required to continue the run.
127127
128128
Will be `null` if no action is required.
129129
"""
130130

131-
started_at: Optional[int]
131+
started_at: Optional[int] = None
132132
"""The Unix timestamp (in seconds) for when the run was started."""
133133

134134
status: Literal[

Diff for: src/openai/types/beta/threads/runs/function_tool_call.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Function(BaseModel):
1515
name: str
1616
"""The name of the function."""
1717

18-
output: Optional[str]
18+
output: Optional[str] = None
1919
"""The output of the function.
2020
2121
This will be `null` if the outputs have not been

Diff for: src/openai/types/beta/threads/runs/run_step.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,31 @@ class RunStep(BaseModel):
3333
associated with the run step.
3434
"""
3535

36-
cancelled_at: Optional[int]
36+
cancelled_at: Optional[int] = None
3737
"""The Unix timestamp (in seconds) for when the run step was cancelled."""
3838

39-
completed_at: Optional[int]
39+
completed_at: Optional[int] = None
4040
"""The Unix timestamp (in seconds) for when the run step completed."""
4141

4242
created_at: int
4343
"""The Unix timestamp (in seconds) for when the run step was created."""
4444

45-
expired_at: Optional[int]
45+
expired_at: Optional[int] = None
4646
"""The Unix timestamp (in seconds) for when the run step expired.
4747
4848
A step is considered expired if the parent run is expired.
4949
"""
5050

51-
failed_at: Optional[int]
51+
failed_at: Optional[int] = None
5252
"""The Unix timestamp (in seconds) for when the run step failed."""
5353

54-
last_error: Optional[LastError]
54+
last_error: Optional[LastError] = None
5555
"""The last error associated with this run step.
5656
5757
Will be `null` if there are no errors.
5858
"""
5959

60-
metadata: Optional[builtins.object]
60+
metadata: Optional[builtins.object] = None
6161
"""Set of 16 key-value pairs that can be attached to an object.
6262
6363
This can be useful for storing additional information about the object in a

Diff for: src/openai/types/beta/threads/thread_message.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ThreadMessage(BaseModel):
1717
id: str
1818
"""The identifier, which can be referenced in API endpoints."""
1919

20-
assistant_id: Optional[str]
20+
assistant_id: Optional[str] = None
2121
"""
2222
If applicable, the ID of the
2323
[assistant](https://platform.openai.com/docs/api-reference/assistants) that
@@ -37,7 +37,7 @@ class ThreadMessage(BaseModel):
3737
that can access files. A maximum of 10 files can be attached to a message.
3838
"""
3939

40-
metadata: Optional[builtins.object]
40+
metadata: Optional[builtins.object] = None
4141
"""Set of 16 key-value pairs that can be attached to an object.
4242
4343
This can be useful for storing additional information about the object in a
@@ -51,7 +51,7 @@ class ThreadMessage(BaseModel):
5151
role: Literal["user", "assistant"]
5252
"""The entity that produced the message. One of `user` or `assistant`."""
5353

54-
run_id: Optional[str]
54+
run_id: Optional[str] = None
5555
"""
5656
If applicable, the ID of the
5757
[run](https://platform.openai.com/docs/api-reference/runs) associated with the

Diff for: src/openai/types/chat/chat_completion.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
class ChoiceLogprobs(BaseModel):
15-
content: Optional[List[ChatCompletionTokenLogprob]]
15+
content: Optional[List[ChatCompletionTokenLogprob]] = None
1616
"""A list of message content tokens with log probability information."""
1717

1818

@@ -30,7 +30,7 @@ class Choice(BaseModel):
3030
index: int
3131
"""The index of the choice in the list of choices."""
3232

33-
logprobs: Optional[ChoiceLogprobs]
33+
logprobs: Optional[ChoiceLogprobs] = None
3434
"""Log probability information for the choice."""
3535

3636
message: ChatCompletionMessage

Diff for: src/openai/types/chat/chat_completion_chunk.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ class ChoiceDelta(BaseModel):
7373

7474

7575
class ChoiceLogprobs(BaseModel):
76-
content: Optional[List[ChatCompletionTokenLogprob]]
76+
content: Optional[List[ChatCompletionTokenLogprob]] = None
7777
"""A list of message content tokens with log probability information."""
7878

7979

8080
class Choice(BaseModel):
8181
delta: ChoiceDelta
8282
"""A chat completion delta generated by streamed model responses."""
8383

84-
finish_reason: Optional[Literal["stop", "length", "tool_calls", "content_filter", "function_call"]]
84+
finish_reason: Optional[Literal["stop", "length", "tool_calls", "content_filter", "function_call"]] = None
8585
"""The reason the model stopped generating tokens.
8686
8787
This will be `stop` if the model hit a natural stop point or a provided stop

Diff for: src/openai/types/chat/chat_completion_message.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class FunctionCall(BaseModel):
2323

2424

2525
class ChatCompletionMessage(BaseModel):
26-
content: Optional[str]
26+
content: Optional[str] = None
2727
"""The contents of the message."""
2828

2929
role: Literal["assistant"]

Diff for: src/openai/types/chat/chat_completion_token_logprob.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class TopLogprob(BaseModel):
1111
token: str
1212
"""The token."""
1313

14-
bytes: Optional[List[int]]
14+
bytes: Optional[List[int]] = None
1515
"""A list of integers representing the UTF-8 bytes representation of the token.
1616
1717
Useful in instances where characters are represented by multiple tokens and
@@ -27,7 +27,7 @@ class ChatCompletionTokenLogprob(BaseModel):
2727
token: str
2828
"""The token."""
2929

30-
bytes: Optional[List[int]]
30+
bytes: Optional[List[int]] = None
3131
"""A list of integers representing the UTF-8 bytes representation of the token.
3232
3333
Useful in instances where characters are represented by multiple tokens and

Diff for: src/openai/types/completion_choice.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ class CompletionChoice(BaseModel):
3030

3131
index: int
3232

33-
logprobs: Optional[Logprobs]
33+
logprobs: Optional[Logprobs] = None
3434

3535
text: str

Diff for: src/openai/types/fine_tune.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class FineTune(BaseModel):
5050
created_at: int
5151
"""The Unix timestamp (in seconds) for when the fine-tuning job was created."""
5252

53-
fine_tuned_model: Optional[str]
53+
fine_tuned_model: Optional[str] = None
5454
"""The name of the fine-tuned model that is being created."""
5555

5656
hyperparams: Hyperparams

Diff for: src/openai/types/fine_tuning/fine_tuning_job.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Error(BaseModel):
1515
message: str
1616
"""A human-readable error message."""
1717

18-
param: Optional[str]
18+
param: Optional[str] = None
1919
"""The parameter that was invalid, usually `training_file` or `validation_file`.
2020
2121
This field will be null if the failure was not parameter-specific.
@@ -39,19 +39,19 @@ class FineTuningJob(BaseModel):
3939
created_at: int
4040
"""The Unix timestamp (in seconds) for when the fine-tuning job was created."""
4141

42-
error: Optional[Error]
42+
error: Optional[Error] = None
4343
"""
4444
For fine-tuning jobs that have `failed`, this will contain more information on
4545
the cause of the failure.
4646
"""
4747

48-
fine_tuned_model: Optional[str]
48+
fine_tuned_model: Optional[str] = None
4949
"""The name of the fine-tuned model that is being created.
5050
5151
The value will be null if the fine-tuning job is still running.
5252
"""
5353

54-
finished_at: Optional[int]
54+
finished_at: Optional[int] = None
5555
"""The Unix timestamp (in seconds) for when the fine-tuning job was finished.
5656
5757
The value will be null if the fine-tuning job is still running.
@@ -86,7 +86,7 @@ class FineTuningJob(BaseModel):
8686
`validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`.
8787
"""
8888

89-
trained_tokens: Optional[int]
89+
trained_tokens: Optional[int] = None
9090
"""The total number of billable tokens processed by this fine-tuning job.
9191
9292
The value will be null if the fine-tuning job is still running.
@@ -99,7 +99,7 @@ class FineTuningJob(BaseModel):
9999
[Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents).
100100
"""
101101

102-
validation_file: Optional[str]
102+
validation_file: Optional[str] = None
103103
"""The file ID used for validation.
104104
105105
You can retrieve the validation results with the

0 commit comments

Comments
 (0)