beta.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. from __future__ import annotations
  3. from ..._compat import cached_property
  4. from .assistants import (
  5. Assistants,
  6. AsyncAssistants,
  7. AssistantsWithRawResponse,
  8. AsyncAssistantsWithRawResponse,
  9. AssistantsWithStreamingResponse,
  10. AsyncAssistantsWithStreamingResponse,
  11. )
  12. from ..._resource import SyncAPIResource, AsyncAPIResource
  13. from .chatkit.chatkit import (
  14. ChatKit,
  15. AsyncChatKit,
  16. ChatKitWithRawResponse,
  17. AsyncChatKitWithRawResponse,
  18. ChatKitWithStreamingResponse,
  19. AsyncChatKitWithStreamingResponse,
  20. )
  21. from .threads.threads import (
  22. Threads,
  23. AsyncThreads,
  24. ThreadsWithRawResponse,
  25. AsyncThreadsWithRawResponse,
  26. ThreadsWithStreamingResponse,
  27. AsyncThreadsWithStreamingResponse,
  28. )
  29. from ...resources.chat import Chat, AsyncChat
  30. from .realtime.realtime import (
  31. Realtime,
  32. AsyncRealtime,
  33. )
  34. __all__ = ["Beta", "AsyncBeta"]
  35. class Beta(SyncAPIResource):
  36. @cached_property
  37. def chat(self) -> Chat:
  38. return Chat(self._client)
  39. @cached_property
  40. def realtime(self) -> Realtime:
  41. return Realtime(self._client)
  42. @cached_property
  43. def chatkit(self) -> ChatKit:
  44. return ChatKit(self._client)
  45. @cached_property
  46. def assistants(self) -> Assistants:
  47. return Assistants(self._client)
  48. @cached_property
  49. def threads(self) -> Threads:
  50. return Threads(self._client)
  51. @cached_property
  52. def with_raw_response(self) -> BetaWithRawResponse:
  53. """
  54. This property can be used as a prefix for any HTTP method call to return
  55. the raw response object instead of the parsed content.
  56. For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
  57. """
  58. return BetaWithRawResponse(self)
  59. @cached_property
  60. def with_streaming_response(self) -> BetaWithStreamingResponse:
  61. """
  62. An alternative to `.with_raw_response` that doesn't eagerly read the response body.
  63. For more information, see https://www.github.com/openai/openai-python#with_streaming_response
  64. """
  65. return BetaWithStreamingResponse(self)
  66. class AsyncBeta(AsyncAPIResource):
  67. @cached_property
  68. def chat(self) -> AsyncChat:
  69. return AsyncChat(self._client)
  70. @cached_property
  71. def realtime(self) -> AsyncRealtime:
  72. return AsyncRealtime(self._client)
  73. @cached_property
  74. def chatkit(self) -> AsyncChatKit:
  75. return AsyncChatKit(self._client)
  76. @cached_property
  77. def assistants(self) -> AsyncAssistants:
  78. return AsyncAssistants(self._client)
  79. @cached_property
  80. def threads(self) -> AsyncThreads:
  81. return AsyncThreads(self._client)
  82. @cached_property
  83. def with_raw_response(self) -> AsyncBetaWithRawResponse:
  84. """
  85. This property can be used as a prefix for any HTTP method call to return
  86. the raw response object instead of the parsed content.
  87. For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
  88. """
  89. return AsyncBetaWithRawResponse(self)
  90. @cached_property
  91. def with_streaming_response(self) -> AsyncBetaWithStreamingResponse:
  92. """
  93. An alternative to `.with_raw_response` that doesn't eagerly read the response body.
  94. For more information, see https://www.github.com/openai/openai-python#with_streaming_response
  95. """
  96. return AsyncBetaWithStreamingResponse(self)
  97. class BetaWithRawResponse:
  98. def __init__(self, beta: Beta) -> None:
  99. self._beta = beta
  100. @cached_property
  101. def chatkit(self) -> ChatKitWithRawResponse:
  102. return ChatKitWithRawResponse(self._beta.chatkit)
  103. @cached_property
  104. def assistants(self) -> AssistantsWithRawResponse:
  105. return AssistantsWithRawResponse(self._beta.assistants)
  106. @cached_property
  107. def threads(self) -> ThreadsWithRawResponse:
  108. return ThreadsWithRawResponse(self._beta.threads)
  109. class AsyncBetaWithRawResponse:
  110. def __init__(self, beta: AsyncBeta) -> None:
  111. self._beta = beta
  112. @cached_property
  113. def chatkit(self) -> AsyncChatKitWithRawResponse:
  114. return AsyncChatKitWithRawResponse(self._beta.chatkit)
  115. @cached_property
  116. def assistants(self) -> AsyncAssistantsWithRawResponse:
  117. return AsyncAssistantsWithRawResponse(self._beta.assistants)
  118. @cached_property
  119. def threads(self) -> AsyncThreadsWithRawResponse:
  120. return AsyncThreadsWithRawResponse(self._beta.threads)
  121. class BetaWithStreamingResponse:
  122. def __init__(self, beta: Beta) -> None:
  123. self._beta = beta
  124. @cached_property
  125. def chatkit(self) -> ChatKitWithStreamingResponse:
  126. return ChatKitWithStreamingResponse(self._beta.chatkit)
  127. @cached_property
  128. def assistants(self) -> AssistantsWithStreamingResponse:
  129. return AssistantsWithStreamingResponse(self._beta.assistants)
  130. @cached_property
  131. def threads(self) -> ThreadsWithStreamingResponse:
  132. return ThreadsWithStreamingResponse(self._beta.threads)
  133. class AsyncBetaWithStreamingResponse:
  134. def __init__(self, beta: AsyncBeta) -> None:
  135. self._beta = beta
  136. @cached_property
  137. def chatkit(self) -> AsyncChatKitWithStreamingResponse:
  138. return AsyncChatKitWithStreamingResponse(self._beta.chatkit)
  139. @cached_property
  140. def assistants(self) -> AsyncAssistantsWithStreamingResponse:
  141. return AsyncAssistantsWithStreamingResponse(self._beta.assistants)
  142. @cached_property
  143. def threads(self) -> AsyncThreadsWithStreamingResponse:
  144. return AsyncThreadsWithStreamingResponse(self._beta.threads)