| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from typing import List |
| 4 |
from itertools import chain |
| 5 |
|
| 6 |
import httpx2 |
| 7 |
|
| 8 |
from .events import ( |
| 9 |
Events, |
| 10 |
AsyncEvents, |
| 11 |
EventsWithRawResponse, |
| 12 |
AsyncEventsWithRawResponse, |
| 13 |
EventsWithStreamingResponse, |
| 14 |
AsyncEventsWithStreamingResponse, |
| 15 |
) |
| 16 |
from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given |
| 17 |
from ....._utils import is_given, path_template, strip_not_given |
| 18 |
from ....._compat import cached_property |
| 19 |
from ....._resource import SyncAPIResource, AsyncAPIResource |
| 20 |
from ....._response import ( |
| 21 |
to_raw_response_wrapper, |
| 22 |
to_streamed_response_wrapper, |
| 23 |
async_to_raw_response_wrapper, |
| 24 |
async_to_streamed_response_wrapper, |
| 25 |
) |
| 26 |
from .....pagination import SyncPageCursor, AsyncPageCursor |
| 27 |
from ....._base_client import AsyncPaginator, make_request_options |
| 28 |
from .....types.anthropic_beta_param import AnthropicBetaParam |
| 29 |
from .....types.beta.sessions.beta_managed_agents_session_thread import BetaManagedAgentsSessionThread |
| 30 |
|
| 31 |
__all__ = ["Threads", "AsyncThreads"] |
| 32 |
|
| 33 |
|
| 34 |
class Threads(SyncAPIResource): |
| 35 |
@cached_property |
| 36 |
def events(self) -> Events: |
| 37 |
return Events(self._client) |
| 38 |
|
| 39 |
@cached_property |
| 40 |
def with_raw_response(self) -> ThreadsWithRawResponse: |
| 41 |
""" |
| 42 |
This property can be used as a prefix for any HTTP method call to return |
| 43 |
the raw response object instead of the parsed content. |
| 44 |
|
| 45 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers |
| 46 |
""" |
| 47 |
return ThreadsWithRawResponse(self) |
| 48 |
|
| 49 |
@cached_property |
| 50 |
def with_streaming_response(self) -> ThreadsWithStreamingResponse: |
| 51 |
""" |
| 52 |
An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 53 |
|
| 54 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response |
| 55 |
""" |
| 56 |
return ThreadsWithStreamingResponse(self) |
| 57 |
|
| 58 |
def retrieve( |
| 59 |
self, |
| 60 |
thread_id: str, |
| 61 |
*, |
| 62 |
session_id: str, |
| 63 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 64 |
workspace_id: str | Omit = omit, |
| 65 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 66 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 67 |
extra_headers: Headers | None = None, |
| 68 |
extra_query: Query | None = None, |
| 69 |
extra_body: Body | None = None, |
| 70 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 71 |
) -> BetaManagedAgentsSessionThread: |
| 72 |
""" |
| 73 |
Get Session Thread |
| 74 |
|
| 75 |
Args: |
| 76 |
betas: Optional header to specify the beta version(s) you want to use. |
| 77 |
|
| 78 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 79 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 80 |
|
| 81 |
Only needed for credentials that can act on more than one Workspace. A |
| 82 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 83 |
match that Workspace. |
| 84 |
|
| 85 |
extra_headers: Send extra headers |
| 86 |
|
| 87 |
extra_query: Add additional query parameters to the request |
| 88 |
|
| 89 |
extra_body: Add additional JSON properties to the request |
| 90 |
|
| 91 |
timeout: Override the client-level default timeout for this request, in seconds |
| 92 |
""" |
| 93 |
if not session_id: |
| 94 |
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") |
| 95 |
if not thread_id: |
| 96 |
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") |
| 97 |
extra_headers = { |
| 98 |
**strip_not_given( |
| 99 |
{ |
| 100 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 101 |
if is_given(betas) |
| 102 |
else not_given, |
| 103 |
"anthropic-workspace-id": workspace_id, |
| 104 |
} |
| 105 |
), |
| 106 |
**(extra_headers or {}), |
| 107 |
} |
| 108 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 109 |
return self._get( |
| 110 |
path_template( |
| 111 |
"/v1/sessions/{session_id}/threads/{thread_id}?beta=true", session_id=session_id, thread_id=thread_id |
| 112 |
), |
| 113 |
options=make_request_options( |
| 114 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 115 |
), |
| 116 |
cast_to=BetaManagedAgentsSessionThread, |
| 117 |
) |
| 118 |
|
| 119 |
def list( |
| 120 |
self, |
| 121 |
session_id: str, |
| 122 |
*, |
| 123 |
limit: int | Omit = omit, |
| 124 |
page: str | Omit = omit, |
| 125 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 126 |
workspace_id: str | Omit = omit, |
| 127 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 128 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 129 |
extra_headers: Headers | None = None, |
| 130 |
extra_query: Query | None = None, |
| 131 |
extra_body: Body | None = None, |
| 132 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 133 |
) -> SyncPageCursor[BetaManagedAgentsSessionThread]: |
| 134 |
"""List Session Threads |
| 135 |
|
| 136 |
Args: |
| 137 |
limit: Maximum results per page. |
| 138 |
|
| 139 |
Defaults to 1000. |
| 140 |
|
| 141 |
page: Opaque pagination cursor from a previous response's `next_page`. Forward-only. |
| 142 |
|
| 143 |
betas: Optional header to specify the beta version(s) you want to use. |
| 144 |
|
| 145 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 146 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 147 |
|
| 148 |
Only needed for credentials that can act on more than one Workspace. A |
| 149 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 150 |
match that Workspace. |
| 151 |
|
| 152 |
extra_headers: Send extra headers |
| 153 |
|
| 154 |
extra_query: Add additional query parameters to the request |
| 155 |
|
| 156 |
extra_body: Add additional JSON properties to the request |
| 157 |
|
| 158 |
timeout: Override the client-level default timeout for this request, in seconds |
| 159 |
""" |
| 160 |
if not session_id: |
| 161 |
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") |
| 162 |
extra_headers = { |
| 163 |
**strip_not_given( |
| 164 |
{ |
| 165 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 166 |
if is_given(betas) |
| 167 |
else not_given, |
| 168 |
"anthropic-workspace-id": workspace_id, |
| 169 |
} |
| 170 |
), |
| 171 |
**(extra_headers or {}), |
| 172 |
} |
| 173 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 174 |
return self._get_api_list( |
| 175 |
path_template("/v1/sessions/{session_id}/threads?beta=true", session_id=session_id), |
| 176 |
page=SyncPageCursor[BetaManagedAgentsSessionThread], |
| 177 |
options=make_request_options( |
| 178 |
extra_headers=extra_headers, |
| 179 |
extra_query=extra_query, |
| 180 |
extra_body=extra_body, |
| 181 |
timeout=timeout, |
| 182 |
query={ |
| 183 |
"limit": limit, |
| 184 |
"page": page, |
| 185 |
}, |
| 186 |
), |
| 187 |
model=BetaManagedAgentsSessionThread, |
| 188 |
) |
| 189 |
|
| 190 |
def archive( |
| 191 |
self, |
| 192 |
thread_id: str, |
| 193 |
*, |
| 194 |
session_id: str, |
| 195 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 196 |
workspace_id: str | Omit = omit, |
| 197 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 198 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 199 |
extra_headers: Headers | None = None, |
| 200 |
extra_query: Query | None = None, |
| 201 |
extra_body: Body | None = None, |
| 202 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 203 |
) -> BetaManagedAgentsSessionThread: |
| 204 |
""" |
| 205 |
Archive Session Thread |
| 206 |
|
| 207 |
Args: |
| 208 |
betas: Optional header to specify the beta version(s) you want to use. |
| 209 |
|
| 210 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 211 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 212 |
|
| 213 |
Only needed for credentials that can act on more than one Workspace. A |
| 214 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 215 |
match that Workspace. |
| 216 |
|
| 217 |
extra_headers: Send extra headers |
| 218 |
|
| 219 |
extra_query: Add additional query parameters to the request |
| 220 |
|
| 221 |
extra_body: Add additional JSON properties to the request |
| 222 |
|
| 223 |
timeout: Override the client-level default timeout for this request, in seconds |
| 224 |
""" |
| 225 |
if not session_id: |
| 226 |
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") |
| 227 |
if not thread_id: |
| 228 |
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") |
| 229 |
extra_headers = { |
| 230 |
**strip_not_given( |
| 231 |
{ |
| 232 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 233 |
if is_given(betas) |
| 234 |
else not_given, |
| 235 |
"anthropic-workspace-id": workspace_id, |
| 236 |
} |
| 237 |
), |
| 238 |
**(extra_headers or {}), |
| 239 |
} |
| 240 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 241 |
return self._post( |
| 242 |
path_template( |
| 243 |
"/v1/sessions/{session_id}/threads/{thread_id}/archive?beta=true", |
| 244 |
session_id=session_id, |
| 245 |
thread_id=thread_id, |
| 246 |
), |
| 247 |
options=make_request_options( |
| 248 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 249 |
), |
| 250 |
cast_to=BetaManagedAgentsSessionThread, |
| 251 |
) |
| 252 |
|
| 253 |
|
| 254 |
class AsyncThreads(AsyncAPIResource): |
| 255 |
@cached_property |
| 256 |
def events(self) -> AsyncEvents: |
| 257 |
return AsyncEvents(self._client) |
| 258 |
|
| 259 |
@cached_property |
| 260 |
def with_raw_response(self) -> AsyncThreadsWithRawResponse: |
| 261 |
""" |
| 262 |
This property can be used as a prefix for any HTTP method call to return |
| 263 |
the raw response object instead of the parsed content. |
| 264 |
|
| 265 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers |
| 266 |
""" |
| 267 |
return AsyncThreadsWithRawResponse(self) |
| 268 |
|
| 269 |
@cached_property |
| 270 |
def with_streaming_response(self) -> AsyncThreadsWithStreamingResponse: |
| 271 |
""" |
| 272 |
An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 273 |
|
| 274 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response |
| 275 |
""" |
| 276 |
return AsyncThreadsWithStreamingResponse(self) |
| 277 |
|
| 278 |
async def retrieve( |
| 279 |
self, |
| 280 |
thread_id: str, |
| 281 |
*, |
| 282 |
session_id: str, |
| 283 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 284 |
workspace_id: str | Omit = omit, |
| 285 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 286 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 287 |
extra_headers: Headers | None = None, |
| 288 |
extra_query: Query | None = None, |
| 289 |
extra_body: Body | None = None, |
| 290 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 291 |
) -> BetaManagedAgentsSessionThread: |
| 292 |
""" |
| 293 |
Get Session Thread |
| 294 |
|
| 295 |
Args: |
| 296 |
betas: Optional header to specify the beta version(s) you want to use. |
| 297 |
|
| 298 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 299 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 300 |
|
| 301 |
Only needed for credentials that can act on more than one Workspace. A |
| 302 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 303 |
match that Workspace. |
| 304 |
|
| 305 |
extra_headers: Send extra headers |
| 306 |
|
| 307 |
extra_query: Add additional query parameters to the request |
| 308 |
|
| 309 |
extra_body: Add additional JSON properties to the request |
| 310 |
|
| 311 |
timeout: Override the client-level default timeout for this request, in seconds |
| 312 |
""" |
| 313 |
if not session_id: |
| 314 |
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") |
| 315 |
if not thread_id: |
| 316 |
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") |
| 317 |
extra_headers = { |
| 318 |
**strip_not_given( |
| 319 |
{ |
| 320 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 321 |
if is_given(betas) |
| 322 |
else not_given, |
| 323 |
"anthropic-workspace-id": workspace_id, |
| 324 |
} |
| 325 |
), |
| 326 |
**(extra_headers or {}), |
| 327 |
} |
| 328 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 329 |
return await self._get( |
| 330 |
path_template( |
| 331 |
"/v1/sessions/{session_id}/threads/{thread_id}?beta=true", session_id=session_id, thread_id=thread_id |
| 332 |
), |
| 333 |
options=make_request_options( |
| 334 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 335 |
), |
| 336 |
cast_to=BetaManagedAgentsSessionThread, |
| 337 |
) |
| 338 |
|
| 339 |
def list( |
| 340 |
self, |
| 341 |
session_id: str, |
| 342 |
*, |
| 343 |
limit: int | Omit = omit, |
| 344 |
page: str | Omit = omit, |
| 345 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 346 |
workspace_id: str | Omit = omit, |
| 347 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 348 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 349 |
extra_headers: Headers | None = None, |
| 350 |
extra_query: Query | None = None, |
| 351 |
extra_body: Body | None = None, |
| 352 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 353 |
) -> AsyncPaginator[BetaManagedAgentsSessionThread, AsyncPageCursor[BetaManagedAgentsSessionThread]]: |
| 354 |
"""List Session Threads |
| 355 |
|
| 356 |
Args: |
| 357 |
limit: Maximum results per page. |
| 358 |
|
| 359 |
Defaults to 1000. |
| 360 |
|
| 361 |
page: Opaque pagination cursor from a previous response's `next_page`. Forward-only. |
| 362 |
|
| 363 |
betas: Optional header to specify the beta version(s) you want to use. |
| 364 |
|
| 365 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 366 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 367 |
|
| 368 |
Only needed for credentials that can act on more than one Workspace. A |
| 369 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 370 |
match that Workspace. |
| 371 |
|
| 372 |
extra_headers: Send extra headers |
| 373 |
|
| 374 |
extra_query: Add additional query parameters to the request |
| 375 |
|
| 376 |
extra_body: Add additional JSON properties to the request |
| 377 |
|
| 378 |
timeout: Override the client-level default timeout for this request, in seconds |
| 379 |
""" |
| 380 |
if not session_id: |
| 381 |
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") |
| 382 |
extra_headers = { |
| 383 |
**strip_not_given( |
| 384 |
{ |
| 385 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 386 |
if is_given(betas) |
| 387 |
else not_given, |
| 388 |
"anthropic-workspace-id": workspace_id, |
| 389 |
} |
| 390 |
), |
| 391 |
**(extra_headers or {}), |
| 392 |
} |
| 393 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 394 |
return self._get_api_list( |
| 395 |
path_template("/v1/sessions/{session_id}/threads?beta=true", session_id=session_id), |
| 396 |
page=AsyncPageCursor[BetaManagedAgentsSessionThread], |
| 397 |
options=make_request_options( |
| 398 |
extra_headers=extra_headers, |
| 399 |
extra_query=extra_query, |
| 400 |
extra_body=extra_body, |
| 401 |
timeout=timeout, |
| 402 |
query={ |
| 403 |
"limit": limit, |
| 404 |
"page": page, |
| 405 |
}, |
| 406 |
), |
| 407 |
model=BetaManagedAgentsSessionThread, |
| 408 |
) |
| 409 |
|
| 410 |
async def archive( |
| 411 |
self, |
| 412 |
thread_id: str, |
| 413 |
*, |
| 414 |
session_id: str, |
| 415 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 416 |
workspace_id: str | Omit = omit, |
| 417 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 418 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 419 |
extra_headers: Headers | None = None, |
| 420 |
extra_query: Query | None = None, |
| 421 |
extra_body: Body | None = None, |
| 422 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 423 |
) -> BetaManagedAgentsSessionThread: |
| 424 |
""" |
| 425 |
Archive Session Thread |
| 426 |
|
| 427 |
Args: |
| 428 |
betas: Optional header to specify the beta version(s) you want to use. |
| 429 |
|
| 430 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 431 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 432 |
|
| 433 |
Only needed for credentials that can act on more than one Workspace. A |
| 434 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 435 |
match that Workspace. |
| 436 |
|
| 437 |
extra_headers: Send extra headers |
| 438 |
|
| 439 |
extra_query: Add additional query parameters to the request |
| 440 |
|
| 441 |
extra_body: Add additional JSON properties to the request |
| 442 |
|
| 443 |
timeout: Override the client-level default timeout for this request, in seconds |
| 444 |
""" |
| 445 |
if not session_id: |
| 446 |
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}") |
| 447 |
if not thread_id: |
| 448 |
raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}") |
| 449 |
extra_headers = { |
| 450 |
**strip_not_given( |
| 451 |
{ |
| 452 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 453 |
if is_given(betas) |
| 454 |
else not_given, |
| 455 |
"anthropic-workspace-id": workspace_id, |
| 456 |
} |
| 457 |
), |
| 458 |
**(extra_headers or {}), |
| 459 |
} |
| 460 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 461 |
return await self._post( |
| 462 |
path_template( |
| 463 |
"/v1/sessions/{session_id}/threads/{thread_id}/archive?beta=true", |
| 464 |
session_id=session_id, |
| 465 |
thread_id=thread_id, |
| 466 |
), |
| 467 |
options=make_request_options( |
| 468 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 469 |
), |
| 470 |
cast_to=BetaManagedAgentsSessionThread, |
| 471 |
) |
| 472 |
|
| 473 |
|
| 474 |
class ThreadsWithRawResponse: |
| 475 |
def __init__(self, threads: Threads) -> None: |
| 476 |
self._threads = threads |
| 477 |
|
| 478 |
self.retrieve = to_raw_response_wrapper( |
| 479 |
threads.retrieve, |
| 480 |
) |
| 481 |
self.list = to_raw_response_wrapper( |
| 482 |
threads.list, |
| 483 |
) |
| 484 |
self.archive = to_raw_response_wrapper( |
| 485 |
threads.archive, |
| 486 |
) |
| 487 |
|
| 488 |
@cached_property |
| 489 |
def events(self) -> EventsWithRawResponse: |
| 490 |
return EventsWithRawResponse(self._threads.events) |
| 491 |
|
| 492 |
|
| 493 |
class AsyncThreadsWithRawResponse: |
| 494 |
def __init__(self, threads: AsyncThreads) -> None: |
| 495 |
self._threads = threads |
| 496 |
|
| 497 |
self.retrieve = async_to_raw_response_wrapper( |
| 498 |
threads.retrieve, |
| 499 |
) |
| 500 |
self.list = async_to_raw_response_wrapper( |
| 501 |
threads.list, |
| 502 |
) |
| 503 |
self.archive = async_to_raw_response_wrapper( |
| 504 |
threads.archive, |
| 505 |
) |
| 506 |
|
| 507 |
@cached_property |
| 508 |
def events(self) -> AsyncEventsWithRawResponse: |
| 509 |
return AsyncEventsWithRawResponse(self._threads.events) |
| 510 |
|
| 511 |
|
| 512 |
class ThreadsWithStreamingResponse: |
| 513 |
def __init__(self, threads: Threads) -> None: |
| 514 |
self._threads = threads |
| 515 |
|
| 516 |
self.retrieve = to_streamed_response_wrapper( |
| 517 |
threads.retrieve, |
| 518 |
) |
| 519 |
self.list = to_streamed_response_wrapper( |
| 520 |
threads.list, |
| 521 |
) |
| 522 |
self.archive = to_streamed_response_wrapper( |
| 523 |
threads.archive, |
| 524 |
) |
| 525 |
|
| 526 |
@cached_property |
| 527 |
def events(self) -> EventsWithStreamingResponse: |
| 528 |
return EventsWithStreamingResponse(self._threads.events) |
| 529 |
|
| 530 |
|
| 531 |
class AsyncThreadsWithStreamingResponse: |
| 532 |
def __init__(self, threads: AsyncThreads) -> None: |
| 533 |
self._threads = threads |
| 534 |
|
| 535 |
self.retrieve = async_to_streamed_response_wrapper( |
| 536 |
threads.retrieve, |
| 537 |
) |
| 538 |
self.list = async_to_streamed_response_wrapper( |
| 539 |
threads.list, |
| 540 |
) |
| 541 |
self.archive = async_to_streamed_response_wrapper( |
| 542 |
threads.archive, |
| 543 |
) |
| 544 |
|
| 545 |
@cached_property |
| 546 |
def events(self) -> AsyncEventsWithStreamingResponse: |
| 547 |
return AsyncEventsWithStreamingResponse(self._threads.events) |