88
99from __future__ import annotations
1010
11- from typing import Any , List , Union , Iterable , cast
11+ from typing import Any , List , Iterable , cast
1212from typing_extensions import Literal
1313
1414import httpx
1515
16- from ..._types import Body , Query , Headers , NotGiven , not_given
16+ from ..._types import Body , Omit , Query , Headers , NotGiven , omit , not_given
1717from ..._utils import maybe_transform , async_maybe_transform
1818from ..._compat import cached_property
1919from ..._resource import SyncAPIResource , AsyncAPIResource
2323 async_to_raw_response_wrapper ,
2424 async_to_streamed_response_wrapper ,
2525)
26- from ..._base_client import make_request_options
26+ from ...pagination import SyncOpenAICursorPage , AsyncOpenAICursorPage
27+ from ..._base_client import AsyncPaginator , make_request_options
2728from ...types .conversations import item_list_params , item_create_params
2829from ...types .conversations .item_get_response import ItemGetResponse
2930from ...types .conversations .item_list_response import ItemListResponse
@@ -94,29 +95,28 @@ def list(
9495 self ,
9596 conversation_id : str ,
9697 * ,
97- after : Union [str , object ],
98- include : Union [
99- List [
100- Literal [
101- "code_interpreter_call.outputs" ,
102- "computer_call_output.output.image_url" ,
103- "file_search_call.results" ,
104- "message.input_image.image_url" ,
105- "message.output_text.logprobs" ,
106- "reasoning.encrypted_content" ,
107- ]
108- ],
109- object ,
110- ],
111- limit : Union [int , object ],
112- order : Union [Literal ["asc" , "desc" ], object ],
98+ after : str | Omit = omit ,
99+ include : List [
100+ Literal [
101+ "web_search_call.action.sources" ,
102+ "code_interpreter_call.outputs" ,
103+ "computer_call_output.output.image_url" ,
104+ "file_search_call.results" ,
105+ "message.input_image.image_url" ,
106+ "message.output_text.logprobs" ,
107+ "reasoning.encrypted_content" ,
108+ ]
109+ ]
110+ | Omit = omit ,
111+ limit : int | Omit = omit ,
112+ order : Literal ["asc" , "desc" ] | Omit = omit ,
113113 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
114114 # The extra values given here take precedence over values defined on the client or passed to this method.
115115 extra_headers : Headers | None = None ,
116116 extra_query : Query | None = None ,
117117 extra_body : Body | None = None ,
118118 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
119- ) -> ItemListResponse :
119+ ) -> SyncOpenAICursorPage [ ItemListResponse ] :
120120 """List items.
121121
122122 List items in the conversation.
@@ -140,8 +140,9 @@ def list(
140140 """
141141 if not conversation_id :
142142 raise ValueError (f"Expected a non-empty value for `conversation_id` but received { conversation_id !r} " )
143- return self ._get (
143+ return self ._get_api_list (
144144 f"/v1/conversations/{ conversation_id } /items" ,
145+ page = SyncOpenAICursorPage [ItemListResponse ],
145146 options = make_request_options (
146147 extra_headers = extra_headers ,
147148 extra_query = extra_query ,
@@ -157,7 +158,7 @@ def list(
157158 item_list_params .ItemListParams ,
158159 ),
159160 ),
160- cast_to = ItemListResponse ,
161+ model = cast ( Any , ItemListResponse ), # Union types cannot be passed in as arguments in the type system
161162 )
162163
163164 def get (
@@ -259,33 +260,32 @@ async def create(
259260 cast_to = ItemCreateResponse ,
260261 )
261262
262- async def list (
263+ def list (
263264 self ,
264265 conversation_id : str ,
265266 * ,
266- after : Union [str , object ],
267- include : Union [
268- List [
269- Literal [
270- "code_interpreter_call.outputs" ,
271- "computer_call_output.output.image_url" ,
272- "file_search_call.results" ,
273- "message.input_image.image_url" ,
274- "message.output_text.logprobs" ,
275- "reasoning.encrypted_content" ,
276- ]
277- ],
278- object ,
279- ],
280- limit : Union [int , object ],
281- order : Union [Literal ["asc" , "desc" ], object ],
267+ after : str | Omit = omit ,
268+ include : List [
269+ Literal [
270+ "web_search_call.action.sources" ,
271+ "code_interpreter_call.outputs" ,
272+ "computer_call_output.output.image_url" ,
273+ "file_search_call.results" ,
274+ "message.input_image.image_url" ,
275+ "message.output_text.logprobs" ,
276+ "reasoning.encrypted_content" ,
277+ ]
278+ ]
279+ | Omit = omit ,
280+ limit : int | Omit = omit ,
281+ order : Literal ["asc" , "desc" ] | Omit = omit ,
282282 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
283283 # The extra values given here take precedence over values defined on the client or passed to this method.
284284 extra_headers : Headers | None = None ,
285285 extra_query : Query | None = None ,
286286 extra_body : Body | None = None ,
287287 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
288- ) -> ItemListResponse :
288+ ) -> AsyncPaginator [ ItemListResponse , AsyncOpenAICursorPage [ ItemListResponse ]] :
289289 """List items.
290290
291291 List items in the conversation.
@@ -309,14 +309,15 @@ async def list(
309309 """
310310 if not conversation_id :
311311 raise ValueError (f"Expected a non-empty value for `conversation_id` but received { conversation_id !r} " )
312- return await self ._get (
312+ return self ._get_api_list (
313313 f"/v1/conversations/{ conversation_id } /items" ,
314+ page = AsyncOpenAICursorPage [ItemListResponse ],
314315 options = make_request_options (
315316 extra_headers = extra_headers ,
316317 extra_query = extra_query ,
317318 extra_body = extra_body ,
318319 timeout = timeout ,
319- query = await async_maybe_transform (
320+ query = maybe_transform (
320321 {
321322 "after" : after ,
322323 "include" : include ,
@@ -326,7 +327,7 @@ async def list(
326327 item_list_params .ItemListParams ,
327328 ),
328329 ),
329- cast_to = ItemListResponse ,
330+ model = cast ( Any , ItemListResponse ), # Union types cannot be passed in as arguments in the type system
330331 )
331332
332333 async def get (
0 commit comments