@@ -279,6 +279,40 @@ def build_assistants_delete_thread_request(thread_id: str, **kwargs: Any) -> Htt
279
279
return HttpRequest (method = "DELETE" , url = _url , params = _params , headers = _headers , ** kwargs )
280
280
281
281
282
+ def build_assistants_list_threads_request (
283
+ * ,
284
+ limit : Optional [int ] = None ,
285
+ order : Optional [Union [str , _models .ListSortOrder ]] = None ,
286
+ after : Optional [str ] = None ,
287
+ before : Optional [str ] = None ,
288
+ ** kwargs : Any
289
+ ) -> HttpRequest :
290
+ _headers = case_insensitive_dict (kwargs .pop ("headers" , {}) or {})
291
+ _params = case_insensitive_dict (kwargs .pop ("params" , {}) or {})
292
+
293
+ api_version : str = kwargs .pop ("api_version" , _params .pop ("api-version" , "2025-05-15-preview" ))
294
+ accept = _headers .pop ("Accept" , "application/json" )
295
+
296
+ # Construct URL
297
+ _url = "/threads"
298
+
299
+ # Construct parameters
300
+ _params ["api-version" ] = _SERIALIZER .query ("api_version" , api_version , "str" )
301
+ if limit is not None :
302
+ _params ["limit" ] = _SERIALIZER .query ("limit" , limit , "int" )
303
+ if order is not None :
304
+ _params ["order" ] = _SERIALIZER .query ("order" , order , "str" )
305
+ if after is not None :
306
+ _params ["after" ] = _SERIALIZER .query ("after" , after , "str" )
307
+ if before is not None :
308
+ _params ["before" ] = _SERIALIZER .query ("before" , before , "str" )
309
+
310
+ # Construct headers
311
+ _headers ["Accept" ] = _SERIALIZER .header ("accept" , accept , "str" )
312
+
313
+ return HttpRequest (method = "GET" , url = _url , params = _params , headers = _headers , ** kwargs )
314
+
315
+
282
316
def build_assistants_create_message_request (thread_id : str , ** kwargs : Any ) -> HttpRequest :
283
317
_headers = case_insensitive_dict (kwargs .pop ("headers" , {}) or {})
284
318
_params = case_insensitive_dict (kwargs .pop ("params" , {}) or {})
@@ -2326,6 +2360,92 @@ def delete_thread(self, thread_id: str, **kwargs: Any) -> _models.ThreadDeletion
2326
2360
2327
2361
return deserialized # type: ignore
2328
2362
2363
+ @distributed_trace
2364
+ def list_threads (
2365
+ self ,
2366
+ * ,
2367
+ limit : Optional [int ] = None ,
2368
+ order : Optional [Union [str , _models .ListSortOrder ]] = None ,
2369
+ after : Optional [str ] = None ,
2370
+ before : Optional [str ] = None ,
2371
+ ** kwargs : Any
2372
+ ) -> _models .OpenAIPageableListOfAssistantThread :
2373
+ """Gets a list of threads that were previously created.
2374
+
2375
+ :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and
2376
+ 100, and the default is 20. Default value is None.
2377
+ :paramtype limit: int
2378
+ :keyword order: Sort order by the created_at timestamp of the objects. asc for ascending order
2379
+ and desc for descending order. Known values are: "asc" and "desc". Default value is None.
2380
+ :paramtype order: str or ~azure.ai.assistants.models.ListSortOrder
2381
+ :keyword after: A cursor for use in pagination. after is an object ID that defines your place
2382
+ in the list. For instance, if you make a list request and receive 100 objects, ending with
2383
+ obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the
2384
+ list. Default value is None.
2385
+ :paramtype after: str
2386
+ :keyword before: A cursor for use in pagination. before is an object ID that defines your place
2387
+ in the list. For instance, if you make a list request and receive 100 objects, ending with
2388
+ obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of
2389
+ the list. Default value is None.
2390
+ :paramtype before: str
2391
+ :return: OpenAIPageableListOfAssistantThread. The OpenAIPageableListOfAssistantThread is
2392
+ compatible with MutableMapping
2393
+ :rtype: ~azure.ai.assistants.models.OpenAIPageableListOfAssistantThread
2394
+ :raises ~azure.core.exceptions.HttpResponseError:
2395
+ """
2396
+ error_map : MutableMapping = {
2397
+ 401 : ClientAuthenticationError ,
2398
+ 404 : ResourceNotFoundError ,
2399
+ 409 : ResourceExistsError ,
2400
+ 304 : ResourceNotModifiedError ,
2401
+ }
2402
+ error_map .update (kwargs .pop ("error_map" , {}) or {})
2403
+
2404
+ _headers = kwargs .pop ("headers" , {}) or {}
2405
+ _params = kwargs .pop ("params" , {}) or {}
2406
+
2407
+ cls : ClsType [_models .OpenAIPageableListOfAssistantThread ] = kwargs .pop ("cls" , None )
2408
+
2409
+ _request = build_assistants_list_threads_request (
2410
+ limit = limit ,
2411
+ order = order ,
2412
+ after = after ,
2413
+ before = before ,
2414
+ api_version = self ._config .api_version ,
2415
+ headers = _headers ,
2416
+ params = _params ,
2417
+ )
2418
+ path_format_arguments = {
2419
+ "endpoint" : self ._serialize .url ("self._config.endpoint" , self ._config .endpoint , "str" , skip_quote = True ),
2420
+ }
2421
+ _request .url = self ._client .format_url (_request .url , ** path_format_arguments )
2422
+
2423
+ _stream = kwargs .pop ("stream" , False )
2424
+ pipeline_response : PipelineResponse = self ._client ._pipeline .run ( # pylint: disable=protected-access
2425
+ _request , stream = _stream , ** kwargs
2426
+ )
2427
+
2428
+ response = pipeline_response .http_response
2429
+
2430
+ if response .status_code not in [200 ]:
2431
+ if _stream :
2432
+ try :
2433
+ response .read () # Load the body in memory and close the socket
2434
+ except (StreamConsumedError , StreamClosedError ):
2435
+ pass
2436
+ map_error (status_code = response .status_code , response = response , error_map = error_map )
2437
+ raise HttpResponseError (response = response )
2438
+
2439
+ if _stream :
2440
+ deserialized = response .iter_bytes ()
2441
+ else :
2442
+ deserialized = _deserialize (_models .OpenAIPageableListOfAssistantThread , response .json ())
2443
+
2444
+ if cls :
2445
+ return cls (pipeline_response , deserialized , {}) # type: ignore
2446
+
2447
+ return deserialized # type: ignore
2448
+
2329
2449
@overload
2330
2450
def create_message (
2331
2451
self ,
0 commit comments