Skip to content

fix(types): improve responses type names #2224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 81
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-f763c1a35c8b9b02f1e31b9b2e09e21f98bfe8413e5079c86cbb07da2dd7779b.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-f3bce04386c4fcfd5037e0477fbaa39010003fd1558eb5185fe4a71dd6a05fdd.yml
8 changes: 7 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ from openai.types.responses import (
ResponseCodeInterpreterToolCall,
ResponseCompletedEvent,
ResponseComputerToolCall,
ResponseComputerToolCallOutputItem,
ResponseComputerToolCallOutputScreenshot,
ResponseContent,
ResponseContentPartAddedEvent,
ResponseContentPartDoneEvent,
Expand All @@ -605,6 +607,8 @@ from openai.types.responses import (
ResponseFunctionCallArgumentsDeltaEvent,
ResponseFunctionCallArgumentsDoneEvent,
ResponseFunctionToolCall,
ResponseFunctionToolCallItem,
ResponseFunctionToolCallOutputItem,
ResponseFunctionWebSearch,
ResponseInProgressEvent,
ResponseIncludable,
Expand All @@ -616,7 +620,9 @@ from openai.types.responses import (
ResponseInputImage,
ResponseInputItem,
ResponseInputMessageContentList,
ResponseInputMessageItem,
ResponseInputText,
ResponseItem,
ResponseOutputAudio,
ResponseOutputItem,
ResponseOutputItemAddedEvent,
Expand Down Expand Up @@ -661,4 +667,4 @@ from openai.types.responses import ResponseItemList

Methods:

- <code title="get /responses/{response_id}/input_items">client.responses.input_items.<a href="./src/openai/resources/responses/input_items.py">list</a>(response_id, \*\*<a href="src/openai/types/responses/input_item_list_params.py">params</a>) -> SyncCursorPage[Data]</code>
- <code title="get /responses/{response_id}/input_items">client.responses.input_items.<a href="./src/openai/resources/responses/input_items.py">list</a>(response_id, \*\*<a href="src/openai/types/responses/input_item_list_params.py">params</a>) -> <a href="./src/openai/types/responses/response_item.py">SyncCursorPage[ResponseItem]</a></code>
14 changes: 7 additions & 7 deletions src/openai/resources/responses/input_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ...pagination import SyncCursorPage, AsyncCursorPage
from ..._base_client import AsyncPaginator, make_request_options
from ...types.responses import input_item_list_params
from ...types.responses.response_item_list import Data
from ...types.responses.response_item import ResponseItem

__all__ = ["InputItems", "AsyncInputItems"]

Expand Down Expand Up @@ -55,7 +55,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncCursorPage[Data]:
) -> SyncCursorPage[ResponseItem]:
"""
Returns a list of input items for a given response.

Expand Down Expand Up @@ -84,7 +84,7 @@ def list(
raise ValueError(f"Expected a non-empty value for `response_id` but received {response_id!r}")
return self._get_api_list(
f"/responses/{response_id}/input_items",
page=SyncCursorPage[Data],
page=SyncCursorPage[ResponseItem],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand All @@ -100,7 +100,7 @@ def list(
input_item_list_params.InputItemListParams,
),
),
model=cast(Any, Data), # Union types cannot be passed in as arguments in the type system
model=cast(Any, ResponseItem), # Union types cannot be passed in as arguments in the type system
)


Expand Down Expand Up @@ -138,7 +138,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[Data, AsyncCursorPage[Data]]:
) -> AsyncPaginator[ResponseItem, AsyncCursorPage[ResponseItem]]:
"""
Returns a list of input items for a given response.

Expand Down Expand Up @@ -167,7 +167,7 @@ def list(
raise ValueError(f"Expected a non-empty value for `response_id` but received {response_id!r}")
return self._get_api_list(
f"/responses/{response_id}/input_items",
page=AsyncCursorPage[Data],
page=AsyncCursorPage[ResponseItem],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand All @@ -183,7 +183,7 @@ def list(
input_item_list_params.InputItemListParams,
),
),
model=cast(Any, Data), # Union types cannot be passed in as arguments in the type system
model=cast(Any, ResponseItem), # Union types cannot be passed in as arguments in the type system
)


Expand Down
15 changes: 15 additions & 0 deletions src/openai/types/responses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .tool_param import ToolParam as ToolParam
from .computer_tool import ComputerTool as ComputerTool
from .function_tool import FunctionTool as FunctionTool
from .response_item import ResponseItem as ResponseItem
from .response_error import ResponseError as ResponseError
from .response_usage import ResponseUsage as ResponseUsage
from .response_status import ResponseStatus as ResponseStatus
Expand Down Expand Up @@ -58,6 +59,7 @@
from .response_computer_tool_call import ResponseComputerToolCall as ResponseComputerToolCall
from .response_format_text_config import ResponseFormatTextConfig as ResponseFormatTextConfig
from .response_function_tool_call import ResponseFunctionToolCall as ResponseFunctionToolCall
from .response_input_message_item import ResponseInputMessageItem as ResponseInputMessageItem
from .response_refusal_done_event import ResponseRefusalDoneEvent as ResponseRefusalDoneEvent
from .response_function_web_search import ResponseFunctionWebSearch as ResponseFunctionWebSearch
from .response_input_content_param import ResponseInputContentParam as ResponseInputContentParam
Expand All @@ -68,6 +70,7 @@
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
from .response_function_tool_call_item import ResponseFunctionToolCallItem as ResponseFunctionToolCallItem
from .response_output_item_added_event import ResponseOutputItemAddedEvent as ResponseOutputItemAddedEvent
from .response_computer_tool_call_param import ResponseComputerToolCallParam as ResponseComputerToolCallParam
from .response_content_part_added_event import ResponseContentPartAddedEvent as ResponseContentPartAddedEvent
Expand All @@ -82,9 +85,15 @@
from .response_audio_transcript_delta_event import (
ResponseAudioTranscriptDeltaEvent as ResponseAudioTranscriptDeltaEvent,
)
from .response_computer_tool_call_output_item import (
ResponseComputerToolCallOutputItem as ResponseComputerToolCallOutputItem,
)
from .response_format_text_json_schema_config import (
ResponseFormatTextJSONSchemaConfig as ResponseFormatTextJSONSchemaConfig,
)
from .response_function_tool_call_output_item import (
ResponseFunctionToolCallOutputItem as ResponseFunctionToolCallOutputItem,
)
from .response_web_search_call_completed_event import (
ResponseWebSearchCallCompletedEvent as ResponseWebSearchCallCompletedEvent,
)
Expand Down Expand Up @@ -112,6 +121,9 @@
from .response_function_call_arguments_delta_event import (
ResponseFunctionCallArgumentsDeltaEvent as ResponseFunctionCallArgumentsDeltaEvent,
)
from .response_computer_tool_call_output_screenshot import (
ResponseComputerToolCallOutputScreenshot as ResponseComputerToolCallOutputScreenshot,
)
from .response_format_text_json_schema_config_param import (
ResponseFormatTextJSONSchemaConfigParam as ResponseFormatTextJSONSchemaConfigParam,
)
Expand All @@ -130,3 +142,6 @@
from .response_code_interpreter_call_interpreting_event import (
ResponseCodeInterpreterCallInterpretingEvent as ResponseCodeInterpreterCallInterpretingEvent,
)
from .response_computer_tool_call_output_screenshot_param import (
ResponseComputerToolCallOutputScreenshotParam as ResponseComputerToolCallOutputScreenshotParam,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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
from .response_computer_tool_call_output_screenshot import ResponseComputerToolCallOutputScreenshot

__all__ = ["ResponseComputerToolCallOutputItem", "AcknowledgedSafetyCheck"]


class AcknowledgedSafetyCheck(BaseModel):
id: str
"""The ID of the pending safety check."""

code: str
"""The type of the pending safety check."""

message: str
"""Details about the pending safety check."""


class ResponseComputerToolCallOutputItem(BaseModel):
id: str
"""The unique ID of the computer call tool output."""

call_id: str
"""The ID of the computer tool call that produced the output."""

output: ResponseComputerToolCallOutputScreenshot
"""A computer screenshot image used with the computer use tool."""

type: Literal["computer_call_output"]
"""The type of the computer tool call output. Always `computer_call_output`."""

acknowledged_safety_checks: Optional[List[AcknowledgedSafetyCheck]] = None
"""
The safety checks reported by the API that have been acknowledged by the
developer.
"""

status: Optional[Literal["in_progress", "completed", "incomplete"]] = None
"""The status of the message input.

One of `in_progress`, `completed`, or `incomplete`. Populated when input items
are returned via API.
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Optional
from typing_extensions import Literal

from ..._models import BaseModel

__all__ = ["ResponseComputerToolCallOutputScreenshot"]


class ResponseComputerToolCallOutputScreenshot(BaseModel):
type: Literal["computer_screenshot"]
"""Specifies the event type.

For a computer screenshot, this property is always set to `computer_screenshot`.
"""

file_id: Optional[str] = None
"""The identifier of an uploaded file that contains the screenshot."""

image_url: Optional[str] = None
"""The URL of the screenshot image."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing_extensions import Literal, Required, TypedDict

__all__ = ["ResponseComputerToolCallOutputScreenshotParam"]


class ResponseComputerToolCallOutputScreenshotParam(TypedDict, total=False):
type: Required[Literal["computer_screenshot"]]
"""Specifies the event type.

For a computer screenshot, this property is always set to `computer_screenshot`.
"""

file_id: str
"""The identifier of an uploaded file that contains the screenshot."""

image_url: str
"""The URL of the screenshot image."""
11 changes: 11 additions & 0 deletions src/openai/types/responses/response_function_tool_call_item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.


from .response_function_tool_call import ResponseFunctionToolCall

__all__ = ["ResponseFunctionToolCallItem"]


class ResponseFunctionToolCallItem(ResponseFunctionToolCall):
id: str # type: ignore
"""The unique ID of the function call tool output."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Optional
from typing_extensions import Literal

from ..._models import BaseModel

__all__ = ["ResponseFunctionToolCallOutputItem"]


class ResponseFunctionToolCallOutputItem(BaseModel):
id: str
"""The unique ID of the function call tool output."""

call_id: str
"""The unique ID of the function tool call generated by the model."""

output: str
"""A JSON string of the output of the function tool call."""

type: Literal["function_call_output"]
"""The type of the function tool call output. Always `function_call_output`."""

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.
"""
18 changes: 2 additions & 16 deletions src/openai/types/responses/response_input_item_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
from .response_function_web_search_param import ResponseFunctionWebSearchParam
from .response_file_search_tool_call_param import ResponseFileSearchToolCallParam
from .response_input_message_content_list_param import ResponseInputMessageContentListParam
from .response_computer_tool_call_output_screenshot_param import ResponseComputerToolCallOutputScreenshotParam

__all__ = [
"ResponseInputItemParam",
"Message",
"ComputerCallOutput",
"ComputerCallOutputOutput",
"ComputerCallOutputAcknowledgedSafetyCheck",
"FunctionCallOutput",
"ItemReference",
Expand Down Expand Up @@ -46,20 +46,6 @@ class Message(TypedDict, total=False):
"""The type of the message input. Always set to `message`."""


class ComputerCallOutputOutput(TypedDict, total=False):
type: Required[Literal["computer_screenshot"]]
"""Specifies the event type.

For a computer screenshot, this property is always set to `computer_screenshot`.
"""

file_id: str
"""The identifier of an uploaded file that contains the screenshot."""

image_url: str
"""The URL of the screenshot image."""


class ComputerCallOutputAcknowledgedSafetyCheck(TypedDict, total=False):
id: Required[str]
"""The ID of the pending safety check."""
Expand All @@ -75,7 +61,7 @@ class ComputerCallOutput(TypedDict, total=False):
call_id: Required[str]
"""The ID of the computer tool call that produced the output."""

output: Required[ComputerCallOutputOutput]
output: Required[ResponseComputerToolCallOutputScreenshotParam]
"""A computer screenshot image used with the computer use tool."""

type: Required[Literal["computer_call_output"]]
Expand Down
33 changes: 33 additions & 0 deletions src/openai/types/responses/response_input_message_item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Optional
from typing_extensions import Literal

from ..._models import BaseModel
from .response_input_message_content_list import ResponseInputMessageContentList

__all__ = ["ResponseInputMessageItem"]


class ResponseInputMessageItem(BaseModel):
id: str
"""The unique ID of the message input."""

content: ResponseInputMessageContentList
"""
A list of one or many input items to the model, containing different content
types.
"""

role: Literal["user", "system", "developer"]
"""The role of the message input. One of `user`, `system`, or `developer`."""

status: Optional[Literal["in_progress", "completed", "incomplete"]] = None
"""The status of item.

One of `in_progress`, `completed`, or `incomplete`. Populated when items are
returned via API.
"""

type: Optional[Literal["message"]] = None
"""The type of the message input. Always set to `message`."""
Loading