messages.py 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. from __future__ import annotations
  3. import typing_extensions
  4. from typing import Union, Iterable, Optional
  5. from typing_extensions import Literal
  6. import httpx
  7. from .... import _legacy_response
  8. from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
  9. from ...._utils import maybe_transform, async_maybe_transform
  10. from ...._compat import cached_property
  11. from ...._resource import SyncAPIResource, AsyncAPIResource
  12. from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
  13. from ....pagination import SyncCursorPage, AsyncCursorPage
  14. from ...._base_client import (
  15. AsyncPaginator,
  16. make_request_options,
  17. )
  18. from ....types.beta.threads import message_list_params, message_create_params, message_update_params
  19. from ....types.beta.threads.message import Message
  20. from ....types.shared_params.metadata import Metadata
  21. from ....types.beta.threads.message_deleted import MessageDeleted
  22. from ....types.beta.threads.message_content_part_param import MessageContentPartParam
  23. __all__ = ["Messages", "AsyncMessages"]
  24. class Messages(SyncAPIResource):
  25. @cached_property
  26. def with_raw_response(self) -> MessagesWithRawResponse:
  27. """
  28. This property can be used as a prefix for any HTTP method call to return
  29. the raw response object instead of the parsed content.
  30. For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
  31. """
  32. return MessagesWithRawResponse(self)
  33. @cached_property
  34. def with_streaming_response(self) -> MessagesWithStreamingResponse:
  35. """
  36. An alternative to `.with_raw_response` that doesn't eagerly read the response body.
  37. For more information, see https://www.github.com/openai/openai-python#with_streaming_response
  38. """
  39. return MessagesWithStreamingResponse(self)
  40. @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
  41. def create(
  42. self,
  43. thread_id: str,
  44. *,
  45. content: Union[str, Iterable[MessageContentPartParam]],
  46. role: Literal["user", "assistant"],
  47. attachments: Optional[Iterable[message_create_params.Attachment]] | Omit = omit,
  48. metadata: Optional[Metadata] | Omit = omit,
  49. # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
  50. # The extra values given here take precedence over values defined on the client or passed to this method.
  51. extra_headers: Headers | None = None,
  52. extra_query: Query | None = None,
  53. extra_body: Body | None = None,
  54. timeout: float | httpx.Timeout | None | NotGiven = not_given,
  55. ) -> Message:
  56. """
  57. Create a message.
  58. Args:
  59. content: The text contents of the message.
  60. role:
  61. The role of the entity that is creating the message. Allowed values include:
  62. - `user`: Indicates the message is sent by an actual user and should be used in
  63. most cases to represent user-generated messages.
  64. - `assistant`: Indicates the message is generated by the assistant. Use this
  65. value to insert messages from the assistant into the conversation.
  66. attachments: A list of files attached to the message, and the tools they should be added to.
  67. metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
  68. for storing additional information about the object in a structured format, and
  69. querying for objects via API or the dashboard.
  70. Keys are strings with a maximum length of 64 characters. Values are strings with
  71. a maximum length of 512 characters.
  72. extra_headers: Send extra headers
  73. extra_query: Add additional query parameters to the request
  74. extra_body: Add additional JSON properties to the request
  75. timeout: Override the client-level default timeout for this request, in seconds
  76. """
  77. if not thread_id:
  78. raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
  79. extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
  80. return self._post(
  81. f"/threads/{thread_id}/messages",
  82. body=maybe_transform(
  83. {
  84. "content": content,
  85. "role": role,
  86. "attachments": attachments,
  87. "metadata": metadata,
  88. },
  89. message_create_params.MessageCreateParams,
  90. ),
  91. options=make_request_options(
  92. extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
  93. ),
  94. cast_to=Message,
  95. )
  96. @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
  97. def retrieve(
  98. self,
  99. message_id: str,
  100. *,
  101. thread_id: str,
  102. # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
  103. # The extra values given here take precedence over values defined on the client or passed to this method.
  104. extra_headers: Headers | None = None,
  105. extra_query: Query | None = None,
  106. extra_body: Body | None = None,
  107. timeout: float | httpx.Timeout | None | NotGiven = not_given,
  108. ) -> Message:
  109. """
  110. Retrieve a message.
  111. Args:
  112. extra_headers: Send extra headers
  113. extra_query: Add additional query parameters to the request
  114. extra_body: Add additional JSON properties to the request
  115. timeout: Override the client-level default timeout for this request, in seconds
  116. """
  117. if not thread_id:
  118. raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
  119. if not message_id:
  120. raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
  121. extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
  122. return self._get(
  123. f"/threads/{thread_id}/messages/{message_id}",
  124. options=make_request_options(
  125. extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
  126. ),
  127. cast_to=Message,
  128. )
  129. @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
  130. def update(
  131. self,
  132. message_id: str,
  133. *,
  134. thread_id: str,
  135. metadata: Optional[Metadata] | Omit = omit,
  136. # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
  137. # The extra values given here take precedence over values defined on the client or passed to this method.
  138. extra_headers: Headers | None = None,
  139. extra_query: Query | None = None,
  140. extra_body: Body | None = None,
  141. timeout: float | httpx.Timeout | None | NotGiven = not_given,
  142. ) -> Message:
  143. """
  144. Modifies a message.
  145. Args:
  146. metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
  147. for storing additional information about the object in a structured format, and
  148. querying for objects via API or the dashboard.
  149. Keys are strings with a maximum length of 64 characters. Values are strings with
  150. a maximum length of 512 characters.
  151. extra_headers: Send extra headers
  152. extra_query: Add additional query parameters to the request
  153. extra_body: Add additional JSON properties to the request
  154. timeout: Override the client-level default timeout for this request, in seconds
  155. """
  156. if not thread_id:
  157. raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
  158. if not message_id:
  159. raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
  160. extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
  161. return self._post(
  162. f"/threads/{thread_id}/messages/{message_id}",
  163. body=maybe_transform({"metadata": metadata}, message_update_params.MessageUpdateParams),
  164. options=make_request_options(
  165. extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
  166. ),
  167. cast_to=Message,
  168. )
  169. @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
  170. def list(
  171. self,
  172. thread_id: str,
  173. *,
  174. after: str | Omit = omit,
  175. before: str | Omit = omit,
  176. limit: int | Omit = omit,
  177. order: Literal["asc", "desc"] | Omit = omit,
  178. run_id: str | Omit = omit,
  179. # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
  180. # The extra values given here take precedence over values defined on the client or passed to this method.
  181. extra_headers: Headers | None = None,
  182. extra_query: Query | None = None,
  183. extra_body: Body | None = None,
  184. timeout: float | httpx.Timeout | None | NotGiven = not_given,
  185. ) -> SyncCursorPage[Message]:
  186. """
  187. Returns a list of messages for a given thread.
  188. Args:
  189. after: A cursor for use in pagination. `after` is an object ID that defines your place
  190. in the list. For instance, if you make a list request and receive 100 objects,
  191. ending with obj_foo, your subsequent call can include after=obj_foo in order to
  192. fetch the next page of the list.
  193. before: A cursor for use in pagination. `before` is an object ID that defines your place
  194. in the list. For instance, if you make a list request and receive 100 objects,
  195. starting with obj_foo, your subsequent call can include before=obj_foo in order
  196. to fetch the previous page of the list.
  197. limit: A limit on the number of objects to be returned. Limit can range between 1 and
  198. 100, and the default is 20.
  199. order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  200. order and `desc` for descending order.
  201. run_id: Filter messages by the run ID that generated them.
  202. extra_headers: Send extra headers
  203. extra_query: Add additional query parameters to the request
  204. extra_body: Add additional JSON properties to the request
  205. timeout: Override the client-level default timeout for this request, in seconds
  206. """
  207. if not thread_id:
  208. raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
  209. extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
  210. return self._get_api_list(
  211. f"/threads/{thread_id}/messages",
  212. page=SyncCursorPage[Message],
  213. options=make_request_options(
  214. extra_headers=extra_headers,
  215. extra_query=extra_query,
  216. extra_body=extra_body,
  217. timeout=timeout,
  218. query=maybe_transform(
  219. {
  220. "after": after,
  221. "before": before,
  222. "limit": limit,
  223. "order": order,
  224. "run_id": run_id,
  225. },
  226. message_list_params.MessageListParams,
  227. ),
  228. ),
  229. model=Message,
  230. )
  231. @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
  232. def delete(
  233. self,
  234. message_id: str,
  235. *,
  236. thread_id: str,
  237. # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
  238. # The extra values given here take precedence over values defined on the client or passed to this method.
  239. extra_headers: Headers | None = None,
  240. extra_query: Query | None = None,
  241. extra_body: Body | None = None,
  242. timeout: float | httpx.Timeout | None | NotGiven = not_given,
  243. ) -> MessageDeleted:
  244. """
  245. Deletes a message.
  246. Args:
  247. extra_headers: Send extra headers
  248. extra_query: Add additional query parameters to the request
  249. extra_body: Add additional JSON properties to the request
  250. timeout: Override the client-level default timeout for this request, in seconds
  251. """
  252. if not thread_id:
  253. raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
  254. if not message_id:
  255. raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
  256. extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
  257. return self._delete(
  258. f"/threads/{thread_id}/messages/{message_id}",
  259. options=make_request_options(
  260. extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
  261. ),
  262. cast_to=MessageDeleted,
  263. )
  264. class AsyncMessages(AsyncAPIResource):
  265. @cached_property
  266. def with_raw_response(self) -> AsyncMessagesWithRawResponse:
  267. """
  268. This property can be used as a prefix for any HTTP method call to return
  269. the raw response object instead of the parsed content.
  270. For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
  271. """
  272. return AsyncMessagesWithRawResponse(self)
  273. @cached_property
  274. def with_streaming_response(self) -> AsyncMessagesWithStreamingResponse:
  275. """
  276. An alternative to `.with_raw_response` that doesn't eagerly read the response body.
  277. For more information, see https://www.github.com/openai/openai-python#with_streaming_response
  278. """
  279. return AsyncMessagesWithStreamingResponse(self)
  280. @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
  281. async def create(
  282. self,
  283. thread_id: str,
  284. *,
  285. content: Union[str, Iterable[MessageContentPartParam]],
  286. role: Literal["user", "assistant"],
  287. attachments: Optional[Iterable[message_create_params.Attachment]] | Omit = omit,
  288. metadata: Optional[Metadata] | Omit = omit,
  289. # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
  290. # The extra values given here take precedence over values defined on the client or passed to this method.
  291. extra_headers: Headers | None = None,
  292. extra_query: Query | None = None,
  293. extra_body: Body | None = None,
  294. timeout: float | httpx.Timeout | None | NotGiven = not_given,
  295. ) -> Message:
  296. """
  297. Create a message.
  298. Args:
  299. content: The text contents of the message.
  300. role:
  301. The role of the entity that is creating the message. Allowed values include:
  302. - `user`: Indicates the message is sent by an actual user and should be used in
  303. most cases to represent user-generated messages.
  304. - `assistant`: Indicates the message is generated by the assistant. Use this
  305. value to insert messages from the assistant into the conversation.
  306. attachments: A list of files attached to the message, and the tools they should be added to.
  307. metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
  308. for storing additional information about the object in a structured format, and
  309. querying for objects via API or the dashboard.
  310. Keys are strings with a maximum length of 64 characters. Values are strings with
  311. a maximum length of 512 characters.
  312. extra_headers: Send extra headers
  313. extra_query: Add additional query parameters to the request
  314. extra_body: Add additional JSON properties to the request
  315. timeout: Override the client-level default timeout for this request, in seconds
  316. """
  317. if not thread_id:
  318. raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
  319. extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
  320. return await self._post(
  321. f"/threads/{thread_id}/messages",
  322. body=await async_maybe_transform(
  323. {
  324. "content": content,
  325. "role": role,
  326. "attachments": attachments,
  327. "metadata": metadata,
  328. },
  329. message_create_params.MessageCreateParams,
  330. ),
  331. options=make_request_options(
  332. extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
  333. ),
  334. cast_to=Message,
  335. )
  336. @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
  337. async def retrieve(
  338. self,
  339. message_id: str,
  340. *,
  341. thread_id: str,
  342. # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
  343. # The extra values given here take precedence over values defined on the client or passed to this method.
  344. extra_headers: Headers | None = None,
  345. extra_query: Query | None = None,
  346. extra_body: Body | None = None,
  347. timeout: float | httpx.Timeout | None | NotGiven = not_given,
  348. ) -> Message:
  349. """
  350. Retrieve a message.
  351. Args:
  352. extra_headers: Send extra headers
  353. extra_query: Add additional query parameters to the request
  354. extra_body: Add additional JSON properties to the request
  355. timeout: Override the client-level default timeout for this request, in seconds
  356. """
  357. if not thread_id:
  358. raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
  359. if not message_id:
  360. raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
  361. extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
  362. return await self._get(
  363. f"/threads/{thread_id}/messages/{message_id}",
  364. options=make_request_options(
  365. extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
  366. ),
  367. cast_to=Message,
  368. )
  369. @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
  370. async def update(
  371. self,
  372. message_id: str,
  373. *,
  374. thread_id: str,
  375. metadata: Optional[Metadata] | Omit = omit,
  376. # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
  377. # The extra values given here take precedence over values defined on the client or passed to this method.
  378. extra_headers: Headers | None = None,
  379. extra_query: Query | None = None,
  380. extra_body: Body | None = None,
  381. timeout: float | httpx.Timeout | None | NotGiven = not_given,
  382. ) -> Message:
  383. """
  384. Modifies a message.
  385. Args:
  386. metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
  387. for storing additional information about the object in a structured format, and
  388. querying for objects via API or the dashboard.
  389. Keys are strings with a maximum length of 64 characters. Values are strings with
  390. a maximum length of 512 characters.
  391. extra_headers: Send extra headers
  392. extra_query: Add additional query parameters to the request
  393. extra_body: Add additional JSON properties to the request
  394. timeout: Override the client-level default timeout for this request, in seconds
  395. """
  396. if not thread_id:
  397. raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
  398. if not message_id:
  399. raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
  400. extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
  401. return await self._post(
  402. f"/threads/{thread_id}/messages/{message_id}",
  403. body=await async_maybe_transform({"metadata": metadata}, message_update_params.MessageUpdateParams),
  404. options=make_request_options(
  405. extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
  406. ),
  407. cast_to=Message,
  408. )
  409. @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
  410. def list(
  411. self,
  412. thread_id: str,
  413. *,
  414. after: str | Omit = omit,
  415. before: str | Omit = omit,
  416. limit: int | Omit = omit,
  417. order: Literal["asc", "desc"] | Omit = omit,
  418. run_id: str | Omit = omit,
  419. # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
  420. # The extra values given here take precedence over values defined on the client or passed to this method.
  421. extra_headers: Headers | None = None,
  422. extra_query: Query | None = None,
  423. extra_body: Body | None = None,
  424. timeout: float | httpx.Timeout | None | NotGiven = not_given,
  425. ) -> AsyncPaginator[Message, AsyncCursorPage[Message]]:
  426. """
  427. Returns a list of messages for a given thread.
  428. Args:
  429. after: A cursor for use in pagination. `after` is an object ID that defines your place
  430. in the list. For instance, if you make a list request and receive 100 objects,
  431. ending with obj_foo, your subsequent call can include after=obj_foo in order to
  432. fetch the next page of the list.
  433. before: A cursor for use in pagination. `before` is an object ID that defines your place
  434. in the list. For instance, if you make a list request and receive 100 objects,
  435. starting with obj_foo, your subsequent call can include before=obj_foo in order
  436. to fetch the previous page of the list.
  437. limit: A limit on the number of objects to be returned. Limit can range between 1 and
  438. 100, and the default is 20.
  439. order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  440. order and `desc` for descending order.
  441. run_id: Filter messages by the run ID that generated them.
  442. extra_headers: Send extra headers
  443. extra_query: Add additional query parameters to the request
  444. extra_body: Add additional JSON properties to the request
  445. timeout: Override the client-level default timeout for this request, in seconds
  446. """
  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 = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
  450. return self._get_api_list(
  451. f"/threads/{thread_id}/messages",
  452. page=AsyncCursorPage[Message],
  453. options=make_request_options(
  454. extra_headers=extra_headers,
  455. extra_query=extra_query,
  456. extra_body=extra_body,
  457. timeout=timeout,
  458. query=maybe_transform(
  459. {
  460. "after": after,
  461. "before": before,
  462. "limit": limit,
  463. "order": order,
  464. "run_id": run_id,
  465. },
  466. message_list_params.MessageListParams,
  467. ),
  468. ),
  469. model=Message,
  470. )
  471. @typing_extensions.deprecated("The Assistants API is deprecated in favor of the Responses API")
  472. async def delete(
  473. self,
  474. message_id: str,
  475. *,
  476. thread_id: str,
  477. # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
  478. # The extra values given here take precedence over values defined on the client or passed to this method.
  479. extra_headers: Headers | None = None,
  480. extra_query: Query | None = None,
  481. extra_body: Body | None = None,
  482. timeout: float | httpx.Timeout | None | NotGiven = not_given,
  483. ) -> MessageDeleted:
  484. """
  485. Deletes a message.
  486. Args:
  487. extra_headers: Send extra headers
  488. extra_query: Add additional query parameters to the request
  489. extra_body: Add additional JSON properties to the request
  490. timeout: Override the client-level default timeout for this request, in seconds
  491. """
  492. if not thread_id:
  493. raise ValueError(f"Expected a non-empty value for `thread_id` but received {thread_id!r}")
  494. if not message_id:
  495. raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
  496. extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
  497. return await self._delete(
  498. f"/threads/{thread_id}/messages/{message_id}",
  499. options=make_request_options(
  500. extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
  501. ),
  502. cast_to=MessageDeleted,
  503. )
  504. class MessagesWithRawResponse:
  505. def __init__(self, messages: Messages) -> None:
  506. self._messages = messages
  507. self.create = ( # pyright: ignore[reportDeprecated]
  508. _legacy_response.to_raw_response_wrapper(
  509. messages.create, # pyright: ignore[reportDeprecated],
  510. )
  511. )
  512. self.retrieve = ( # pyright: ignore[reportDeprecated]
  513. _legacy_response.to_raw_response_wrapper(
  514. messages.retrieve, # pyright: ignore[reportDeprecated],
  515. )
  516. )
  517. self.update = ( # pyright: ignore[reportDeprecated]
  518. _legacy_response.to_raw_response_wrapper(
  519. messages.update, # pyright: ignore[reportDeprecated],
  520. )
  521. )
  522. self.list = ( # pyright: ignore[reportDeprecated]
  523. _legacy_response.to_raw_response_wrapper(
  524. messages.list, # pyright: ignore[reportDeprecated],
  525. )
  526. )
  527. self.delete = ( # pyright: ignore[reportDeprecated]
  528. _legacy_response.to_raw_response_wrapper(
  529. messages.delete, # pyright: ignore[reportDeprecated],
  530. )
  531. )
  532. class AsyncMessagesWithRawResponse:
  533. def __init__(self, messages: AsyncMessages) -> None:
  534. self._messages = messages
  535. self.create = ( # pyright: ignore[reportDeprecated]
  536. _legacy_response.async_to_raw_response_wrapper(
  537. messages.create, # pyright: ignore[reportDeprecated],
  538. )
  539. )
  540. self.retrieve = ( # pyright: ignore[reportDeprecated]
  541. _legacy_response.async_to_raw_response_wrapper(
  542. messages.retrieve, # pyright: ignore[reportDeprecated],
  543. )
  544. )
  545. self.update = ( # pyright: ignore[reportDeprecated]
  546. _legacy_response.async_to_raw_response_wrapper(
  547. messages.update, # pyright: ignore[reportDeprecated],
  548. )
  549. )
  550. self.list = ( # pyright: ignore[reportDeprecated]
  551. _legacy_response.async_to_raw_response_wrapper(
  552. messages.list, # pyright: ignore[reportDeprecated],
  553. )
  554. )
  555. self.delete = ( # pyright: ignore[reportDeprecated]
  556. _legacy_response.async_to_raw_response_wrapper(
  557. messages.delete, # pyright: ignore[reportDeprecated],
  558. )
  559. )
  560. class MessagesWithStreamingResponse:
  561. def __init__(self, messages: Messages) -> None:
  562. self._messages = messages
  563. self.create = ( # pyright: ignore[reportDeprecated]
  564. to_streamed_response_wrapper(
  565. messages.create, # pyright: ignore[reportDeprecated],
  566. )
  567. )
  568. self.retrieve = ( # pyright: ignore[reportDeprecated]
  569. to_streamed_response_wrapper(
  570. messages.retrieve, # pyright: ignore[reportDeprecated],
  571. )
  572. )
  573. self.update = ( # pyright: ignore[reportDeprecated]
  574. to_streamed_response_wrapper(
  575. messages.update, # pyright: ignore[reportDeprecated],
  576. )
  577. )
  578. self.list = ( # pyright: ignore[reportDeprecated]
  579. to_streamed_response_wrapper(
  580. messages.list, # pyright: ignore[reportDeprecated],
  581. )
  582. )
  583. self.delete = ( # pyright: ignore[reportDeprecated]
  584. to_streamed_response_wrapper(
  585. messages.delete, # pyright: ignore[reportDeprecated],
  586. )
  587. )
  588. class AsyncMessagesWithStreamingResponse:
  589. def __init__(self, messages: AsyncMessages) -> None:
  590. self._messages = messages
  591. self.create = ( # pyright: ignore[reportDeprecated]
  592. async_to_streamed_response_wrapper(
  593. messages.create, # pyright: ignore[reportDeprecated],
  594. )
  595. )
  596. self.retrieve = ( # pyright: ignore[reportDeprecated]
  597. async_to_streamed_response_wrapper(
  598. messages.retrieve, # pyright: ignore[reportDeprecated],
  599. )
  600. )
  601. self.update = ( # pyright: ignore[reportDeprecated]
  602. async_to_streamed_response_wrapper(
  603. messages.update, # pyright: ignore[reportDeprecated],
  604. )
  605. )
  606. self.list = ( # pyright: ignore[reportDeprecated]
  607. async_to_streamed_response_wrapper(
  608. messages.list, # pyright: ignore[reportDeprecated],
  609. )
  610. )
  611. self.delete = ( # pyright: ignore[reportDeprecated]
  612. async_to_streamed_response_wrapper(
  613. messages.delete, # pyright: ignore[reportDeprecated],
  614. )
  615. )