chatkit.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. from __future__ import annotations
  3. from .threads import (
  4. Threads,
  5. AsyncThreads,
  6. ThreadsWithRawResponse,
  7. AsyncThreadsWithRawResponse,
  8. ThreadsWithStreamingResponse,
  9. AsyncThreadsWithStreamingResponse,
  10. )
  11. from .sessions import (
  12. Sessions,
  13. AsyncSessions,
  14. SessionsWithRawResponse,
  15. AsyncSessionsWithRawResponse,
  16. SessionsWithStreamingResponse,
  17. AsyncSessionsWithStreamingResponse,
  18. )
  19. from ...._compat import cached_property
  20. from ...._resource import SyncAPIResource, AsyncAPIResource
  21. __all__ = ["ChatKit", "AsyncChatKit"]
  22. class ChatKit(SyncAPIResource):
  23. @cached_property
  24. def sessions(self) -> Sessions:
  25. return Sessions(self._client)
  26. @cached_property
  27. def threads(self) -> Threads:
  28. return Threads(self._client)
  29. @cached_property
  30. def with_raw_response(self) -> ChatKitWithRawResponse:
  31. """
  32. This property can be used as a prefix for any HTTP method call to return
  33. the raw response object instead of the parsed content.
  34. For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
  35. """
  36. return ChatKitWithRawResponse(self)
  37. @cached_property
  38. def with_streaming_response(self) -> ChatKitWithStreamingResponse:
  39. """
  40. An alternative to `.with_raw_response` that doesn't eagerly read the response body.
  41. For more information, see https://www.github.com/openai/openai-python#with_streaming_response
  42. """
  43. return ChatKitWithStreamingResponse(self)
  44. class AsyncChatKit(AsyncAPIResource):
  45. @cached_property
  46. def sessions(self) -> AsyncSessions:
  47. return AsyncSessions(self._client)
  48. @cached_property
  49. def threads(self) -> AsyncThreads:
  50. return AsyncThreads(self._client)
  51. @cached_property
  52. def with_raw_response(self) -> AsyncChatKitWithRawResponse:
  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 AsyncChatKitWithRawResponse(self)
  59. @cached_property
  60. def with_streaming_response(self) -> AsyncChatKitWithStreamingResponse:
  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 AsyncChatKitWithStreamingResponse(self)
  66. class ChatKitWithRawResponse:
  67. def __init__(self, chatkit: ChatKit) -> None:
  68. self._chatkit = chatkit
  69. @cached_property
  70. def sessions(self) -> SessionsWithRawResponse:
  71. return SessionsWithRawResponse(self._chatkit.sessions)
  72. @cached_property
  73. def threads(self) -> ThreadsWithRawResponse:
  74. return ThreadsWithRawResponse(self._chatkit.threads)
  75. class AsyncChatKitWithRawResponse:
  76. def __init__(self, chatkit: AsyncChatKit) -> None:
  77. self._chatkit = chatkit
  78. @cached_property
  79. def sessions(self) -> AsyncSessionsWithRawResponse:
  80. return AsyncSessionsWithRawResponse(self._chatkit.sessions)
  81. @cached_property
  82. def threads(self) -> AsyncThreadsWithRawResponse:
  83. return AsyncThreadsWithRawResponse(self._chatkit.threads)
  84. class ChatKitWithStreamingResponse:
  85. def __init__(self, chatkit: ChatKit) -> None:
  86. self._chatkit = chatkit
  87. @cached_property
  88. def sessions(self) -> SessionsWithStreamingResponse:
  89. return SessionsWithStreamingResponse(self._chatkit.sessions)
  90. @cached_property
  91. def threads(self) -> ThreadsWithStreamingResponse:
  92. return ThreadsWithStreamingResponse(self._chatkit.threads)
  93. class AsyncChatKitWithStreamingResponse:
  94. def __init__(self, chatkit: AsyncChatKit) -> None:
  95. self._chatkit = chatkit
  96. @cached_property
  97. def sessions(self) -> AsyncSessionsWithStreamingResponse:
  98. return AsyncSessionsWithStreamingResponse(self._chatkit.sessions)
  99. @cached_property
  100. def threads(self) -> AsyncThreadsWithStreamingResponse:
  101. return AsyncThreadsWithStreamingResponse(self._chatkit.threads)