Commit 27ef73fd

stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
2025-03-12 05:44:13
fix(responses): correct reasoning output type (#2181)
1 parent 5a1eded
src/openai/types/responses/__init__.py
@@ -45,6 +45,7 @@ from .response_created_event import ResponseCreatedEvent as ResponseCreatedEvent
 from .response_input_content import ResponseInputContent as ResponseInputContent
 from .response_output_message import ResponseOutputMessage as ResponseOutputMessage
 from .response_output_refusal import ResponseOutputRefusal as ResponseOutputRefusal
+from .response_reasoning_item import ResponseReasoningItem as ResponseReasoningItem
 from .tool_choice_types_param import ToolChoiceTypesParam as ToolChoiceTypesParam
 from .easy_input_message_param import EasyInputMessageParam as EasyInputMessageParam
 from .response_completed_event import ResponseCompletedEvent as ResponseCompletedEvent
@@ -71,6 +72,7 @@ from .response_input_content_param import ResponseInputContentParam as ResponseI
 from .response_refusal_delta_event import ResponseRefusalDeltaEvent as ResponseRefusalDeltaEvent
 from .response_output_message_param import ResponseOutputMessageParam as ResponseOutputMessageParam
 from .response_output_refusal_param import ResponseOutputRefusalParam as ResponseOutputRefusalParam
+from .response_reasoning_item_param import ResponseReasoningItemParam as ResponseReasoningItemParam
 from .response_file_search_tool_call import ResponseFileSearchToolCall as ResponseFileSearchToolCall
 from .response_output_item_done_event import ResponseOutputItemDoneEvent as ResponseOutputItemDoneEvent
 from .response_content_part_done_event import ResponseContentPartDoneEvent as ResponseContentPartDoneEvent
src/openai/types/responses/parsed_response.py
@@ -7,10 +7,10 @@ from ..._utils import PropertyInfo
 from .response import Response
 from ..._models import GenericModel
 from ..._utils._transform import PropertyInfo
-from .response_output_item import Reasoning
 from .response_output_text import ResponseOutputText
 from .response_output_message import ResponseOutputMessage
 from .response_output_refusal import ResponseOutputRefusal
+from .response_reasoning_item import ResponseReasoningItem
 from .response_computer_tool_call import ResponseComputerToolCall
 from .response_function_tool_call import ResponseFunctionToolCall
 from .response_function_web_search import ResponseFunctionWebSearch
@@ -54,7 +54,7 @@ ParsedResponseOutputItem: TypeAlias = Annotated[
         ResponseFileSearchToolCall,
         ResponseFunctionWebSearch,
         ResponseComputerToolCall,
-        Reasoning,
+        ResponseReasoningItem,
     ],
     PropertyInfo(discriminator="type"),
 ]
src/openai/types/responses/response_input_item_param.py
@@ -7,6 +7,7 @@ from typing_extensions import Literal, Required, TypeAlias, TypedDict
 
 from .easy_input_message_param import EasyInputMessageParam
 from .response_output_message_param import ResponseOutputMessageParam
+from .response_reasoning_item_param import ResponseReasoningItemParam
 from .response_computer_tool_call_param import ResponseComputerToolCallParam
 from .response_function_tool_call_param import ResponseFunctionToolCallParam
 from .response_function_web_search_param import ResponseFunctionWebSearchParam
@@ -20,8 +21,6 @@ __all__ = [
     "ComputerCallOutputOutput",
     "ComputerCallOutputAcknowledgedSafetyCheck",
     "FunctionCallOutput",
-    "Reasoning",
-    "ReasoningContent",
     "ItemReference",
 ]
 
@@ -123,34 +122,6 @@ class FunctionCallOutput(TypedDict, total=False):
     """
 
 
-class ReasoningContent(TypedDict, total=False):
-    text: Required[str]
-    """
-    A short summary of the reasoning used by the model when generating the response.
-    """
-
-    type: Required[Literal["reasoning_summary"]]
-    """The type of the object. Always `text`."""
-
-
-class Reasoning(TypedDict, total=False):
-    id: Required[str]
-    """The unique identifier of the reasoning content."""
-
-    content: Required[Iterable[ReasoningContent]]
-    """Reasoning text contents."""
-
-    type: Required[Literal["reasoning"]]
-    """The type of the object. Always `reasoning`."""
-
-    status: Literal["in_progress", "completed", "incomplete"]
-    """The status of the item.
-
-    One of `in_progress`, `completed`, or `incomplete`. Populated when items are
-    returned via API.
-    """
-
-
 class ItemReference(TypedDict, total=False):
     id: Required[str]
     """The ID of the item to reference."""
@@ -169,6 +140,6 @@ ResponseInputItemParam: TypeAlias = Union[
     ResponseFunctionWebSearchParam,
     ResponseFunctionToolCallParam,
     FunctionCallOutput,
-    Reasoning,
+    ResponseReasoningItemParam,
     ItemReference,
 ]
src/openai/types/responses/response_input_param.py
@@ -7,6 +7,7 @@ from typing_extensions import Literal, Required, TypeAlias, TypedDict
 
 from .easy_input_message_param import EasyInputMessageParam
 from .response_output_message_param import ResponseOutputMessageParam
+from .response_reasoning_item_param import ResponseReasoningItemParam
 from .response_computer_tool_call_param import ResponseComputerToolCallParam
 from .response_function_tool_call_param import ResponseFunctionToolCallParam
 from .response_function_web_search_param import ResponseFunctionWebSearchParam
@@ -21,8 +22,6 @@ __all__ = [
     "ComputerCallOutputOutput",
     "ComputerCallOutputAcknowledgedSafetyCheck",
     "FunctionCallOutput",
-    "Reasoning",
-    "ReasoningContent",
     "ItemReference",
 ]
 
@@ -124,34 +123,6 @@ class FunctionCallOutput(TypedDict, total=False):
     """
 
 
-class ReasoningContent(TypedDict, total=False):
-    text: Required[str]
-    """
-    A short summary of the reasoning used by the model when generating the response.
-    """
-
-    type: Required[Literal["reasoning_summary"]]
-    """The type of the object. Always `text`."""
-
-
-class Reasoning(TypedDict, total=False):
-    id: Required[str]
-    """The unique identifier of the reasoning content."""
-
-    content: Required[Iterable[ReasoningContent]]
-    """Reasoning text contents."""
-
-    type: Required[Literal["reasoning"]]
-    """The type of the object. Always `reasoning`."""
-
-    status: Literal["in_progress", "completed", "incomplete"]
-    """The status of the item.
-
-    One of `in_progress`, `completed`, or `incomplete`. Populated when items are
-    returned via API.
-    """
-
-
 class ItemReference(TypedDict, total=False):
     id: Required[str]
     """The ID of the item to reference."""
@@ -170,7 +141,7 @@ ResponseInputItemParam: TypeAlias = Union[
     ResponseFunctionWebSearchParam,
     ResponseFunctionToolCallParam,
     FunctionCallOutput,
-    Reasoning,
+    ResponseReasoningItemParam,
     ItemReference,
 ]
 
src/openai/types/responses/response_output_item.py
@@ -1,46 +1,17 @@
 # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
 
-from typing import List, Union, Optional
-from typing_extensions import Literal, Annotated, TypeAlias
+from typing import Union
+from typing_extensions import Annotated, TypeAlias
 
 from ..._utils import PropertyInfo
-from ..._models import BaseModel
 from .response_output_message import ResponseOutputMessage
+from .response_reasoning_item import ResponseReasoningItem
 from .response_computer_tool_call import ResponseComputerToolCall
 from .response_function_tool_call import ResponseFunctionToolCall
 from .response_function_web_search import ResponseFunctionWebSearch
 from .response_file_search_tool_call import ResponseFileSearchToolCall
 
-__all__ = ["ResponseOutputItem", "Reasoning", "ReasoningContent"]
-
-
-class ReasoningContent(BaseModel):
-    text: str
-    """
-    A short summary of the reasoning used by the model when generating the response.
-    """
-
-    type: Literal["reasoning_summary"]
-    """The type of the object. Always `text`."""
-
-
-class Reasoning(BaseModel):
-    id: str
-    """The unique identifier of the reasoning content."""
-
-    content: List[ReasoningContent]
-    """Reasoning text contents."""
-
-    type: Literal["reasoning"]
-    """The type of the object. Always `reasoning`."""
-
-    status: Optional[Literal["in_progress", "completed", "incomplete"]] = None
-    """The status of the item.
-
-    One of `in_progress`, `completed`, or `incomplete`. Populated when items are
-    returned via API.
-    """
-
+__all__ = ["ResponseOutputItem"]
 
 ResponseOutputItem: TypeAlias = Annotated[
     Union[
@@ -49,7 +20,7 @@ ResponseOutputItem: TypeAlias = Annotated[
         ResponseFunctionToolCall,
         ResponseFunctionWebSearch,
         ResponseComputerToolCall,
-        Reasoning,
+        ResponseReasoningItem,
     ],
     PropertyInfo(discriminator="type"),
 ]
src/openai/types/responses/response_reasoning_item.py
@@ -0,0 +1,36 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import List, Optional
+from typing_extensions import Literal
+
+from ..._models import BaseModel
+
+__all__ = ["ResponseReasoningItem", "Summary"]
+
+
+class Summary(BaseModel):
+    text: str
+    """
+    A short summary of the reasoning used by the model when generating the response.
+    """
+
+    type: Literal["summary_text"]
+    """The type of the object. Always `summary_text`."""
+
+
+class ResponseReasoningItem(BaseModel):
+    id: str
+    """The unique identifier of the reasoning content."""
+
+    summary: List[Summary]
+    """Reasoning text contents."""
+
+    type: Literal["reasoning"]
+    """The type of the object. Always `reasoning`."""
+
+    status: Optional[Literal["in_progress", "completed", "incomplete"]] = None
+    """The status of the item.
+
+    One of `in_progress`, `completed`, or `incomplete`. Populated when items are
+    returned via API.
+    """
src/openai/types/responses/response_reasoning_item_param.py
@@ -0,0 +1,36 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Iterable
+from typing_extensions import Literal, Required, TypedDict
+
+__all__ = ["ResponseReasoningItemParam", "Summary"]
+
+
+class Summary(TypedDict, total=False):
+    text: Required[str]
+    """
+    A short summary of the reasoning used by the model when generating the response.
+    """
+
+    type: Required[Literal["summary_text"]]
+    """The type of the object. Always `summary_text`."""
+
+
+class ResponseReasoningItemParam(TypedDict, total=False):
+    id: Required[str]
+    """The unique identifier of the reasoning content."""
+
+    summary: Required[Iterable[Summary]]
+    """Reasoning text contents."""
+
+    type: Required[Literal["reasoning"]]
+    """The type of the object. Always `reasoning`."""
+
+    status: Literal["in_progress", "completed", "incomplete"]
+    """The status of the item.
+
+    One of `in_progress`, `completed`, or `incomplete`. Populated when items are
+    returned via API.
+    """
.stats.yml
@@ -1,2 +1,2 @@
 configured_endpoints: 81
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-9ce5257763fb30c6e0e1ee2bef7e13baf661511e09572207e528d643da8e16b3.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-c8579861bc21d4d2155a5b9e8e7d54faee8083730673c4d32cbbe573d7fb4116.yml
api.md
@@ -640,6 +640,7 @@ from openai.types.responses import (
     ResponseOutputMessage,
     ResponseOutputRefusal,
     ResponseOutputText,
+    ResponseReasoningItem,
     ResponseRefusalDeltaEvent,
     ResponseRefusalDoneEvent,
     ResponseStatus,