lmproto: keep None last in the optional unions

This commit is contained in:
2026-10-07 00:47:20 +08:00
parent c56449bfce
commit 5a7bd55f2d
3 changed files with 19 additions and 19 deletions
+12 -12
View File
@@ -232,24 +232,24 @@ class Response(Struct, omit_defaults=True):
output: list[dict[str, Any]] output: list[dict[str, Any]]
object: Literal["response"] = "response" object: Literal["response"] = "response"
status: ResponseStatus | Unset = UNSET status: ResponseStatus | Unset = UNSET
error: ResponseError | None | Unset = UNSET error: ResponseError | Unset | None = UNSET
incomplete_details: ResponseIncompleteDetails | None | Unset = UNSET incomplete_details: ResponseIncompleteDetails | Unset | None = UNSET
instructions: str | list[dict[str, Any]] | None | Unset = UNSET instructions: str | list[dict[str, Any]] | Unset | None = UNSET
metadata: dict[str, str] | None | Unset = UNSET metadata: dict[str, str] | Unset | None = UNSET
parallel_tool_calls: bool | Unset = UNSET parallel_tool_calls: bool | Unset = UNSET
temperature: float | None | Unset = UNSET temperature: float | Unset | None = UNSET
top_p: float | None | Unset = UNSET top_p: float | Unset | None = UNSET
tools: list[dict[str, Any]] | Unset = UNSET tools: list[dict[str, Any]] | Unset = UNSET
tool_choice: str | dict[str, Any] | Unset = UNSET tool_choice: str | dict[str, Any] | Unset = UNSET
# Prefer loose dict — nested usage details vary by model/API version. # Prefer loose dict — nested usage details vary by model/API version.
usage: dict[str, Any] | None | Unset = UNSET usage: dict[str, Any] | Unset | None = UNSET
previous_response_id: str | None | Unset = UNSET previous_response_id: str | Unset | None = UNSET
service_tier: ServiceTier | None | Unset = UNSET service_tier: ServiceTier | Unset | None = UNSET
truncation: TruncationMode | None | Unset = UNSET truncation: TruncationMode | Unset | None = UNSET
text: dict[str, Any] | Unset = UNSET text: dict[str, Any] | Unset = UNSET
reasoning: dict[str, Any] | None | Unset = UNSET reasoning: dict[str, Any] | Unset | None = UNSET
store: bool | Unset = UNSET store: bool | Unset = UNSET
user: str | None | Unset = UNSET user: str | Unset | None = UNSET
class ResponseDeleted(Struct): class ResponseDeleted(Struct):
@@ -59,7 +59,7 @@ async def read_response_body(resp: object) -> bytes | str | None:
return None return None
def sse_data_payload(line: bytes) -> bytes | None | Literal[False]: def sse_data_payload(line: bytes) -> bytes | Literal[False] | None:
"""Parse one SSE line. """Parse one SSE line.
Returns: Returns:
@@ -67,7 +67,7 @@ type AnyAssistantToolCall = AssistantFunctionToolCall | AssistantCustomToolCall
class AssistantChatMessage(Struct, tag_field="role", tag="assistant"): class AssistantChatMessage(Struct, tag_field="role", tag="assistant"):
# APIs often return content=null when tool_calls are present. # APIs often return content=null when tool_calls are present.
content: str | None | Unset = UNSET content: str | Unset | None = UNSET
name: str | Unset = UNSET name: str | Unset = UNSET
audio: IDObject | Unset = UNSET audio: IDObject | Unset = UNSET
refusal: str | Unset = UNSET refusal: str | Unset = UNSET
@@ -237,8 +237,8 @@ class StreamToolCallDelta(Struct):
class DeltaMessage(Struct): class DeltaMessage(Struct):
role: RoleAssistant | Unset = UNSET role: RoleAssistant | Unset = UNSET
# Providers often send content=null / reasoning_content=null on partial chunks. # Providers often send content=null / reasoning_content=null on partial chunks.
content: str | None | Unset = UNSET content: str | Unset | None = UNSET
reasoning_content: str | None | Unset = UNSET reasoning_content: str | Unset | None = UNSET
# True when reasoning_content is the FULL chain-of-thought (e.g. DeepSeek's # True when reasoning_content is the FULL chain-of-thought (e.g. DeepSeek's
# ``response.reasoning_text.done``), replacing any streamed fragments. # ``response.reasoning_text.done``), replacing any streamed fragments.
reasoning_full: bool | Unset = UNSET reasoning_full: bool | Unset = UNSET
@@ -249,8 +249,8 @@ class ChunkChoice(Struct):
index: int index: int
delta: DeltaMessage delta: DeltaMessage
# APIs often send logprobs=null on stream choices. # APIs often send logprobs=null on stream choices.
logprobs: dict[str, Any] | None | Unset = UNSET logprobs: dict[str, Any] | Unset | None = UNSET
finish_reason: FinishReason | None | Unset = UNSET finish_reason: FinishReason | Unset | None = UNSET
class ChatCompletionChunk(Struct): class ChatCompletionChunk(Struct):
@@ -260,7 +260,7 @@ class ChatCompletionChunk(Struct):
model: str model: str
choices: list[ChunkChoice] choices: list[ChunkChoice]
# Final usage chunk may omit or null usage depending on provider. # Final usage chunk may omit or null usage depending on provider.
usage: dict[str, Any] | None | Unset = UNSET usage: dict[str, Any] | Unset | None = UNSET
class ModelObject(Struct): class ModelObject(Struct):