threads.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. "use strict";
  2. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  3. Object.defineProperty(exports, "__esModule", { value: true });
  4. exports.Threads = void 0;
  5. const resource_1 = require("../../../core/resource.js");
  6. const pagination_1 = require("../../../core/pagination.js");
  7. const headers_1 = require("../../../internal/headers.js");
  8. const path_1 = require("../../../internal/utils/path.js");
  9. class Threads extends resource_1.APIResource {
  10. /**
  11. * Retrieve a ChatKit thread
  12. *
  13. * @example
  14. * ```ts
  15. * const chatkitThread =
  16. * await client.beta.chatkit.threads.retrieve('cthr_123');
  17. * ```
  18. */
  19. retrieve(threadID, options) {
  20. return this._client.get((0, path_1.path) `/chatkit/threads/${threadID}`, {
  21. ...options,
  22. headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
  23. });
  24. }
  25. /**
  26. * List ChatKit threads
  27. *
  28. * @example
  29. * ```ts
  30. * // Automatically fetches more pages as needed.
  31. * for await (const chatkitThread of client.beta.chatkit.threads.list()) {
  32. * // ...
  33. * }
  34. * ```
  35. */
  36. list(query = {}, options) {
  37. return this._client.getAPIList('/chatkit/threads', (pagination_1.ConversationCursorPage), {
  38. query,
  39. ...options,
  40. headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
  41. });
  42. }
  43. /**
  44. * Delete a ChatKit thread
  45. *
  46. * @example
  47. * ```ts
  48. * const thread = await client.beta.chatkit.threads.delete(
  49. * 'cthr_123',
  50. * );
  51. * ```
  52. */
  53. delete(threadID, options) {
  54. return this._client.delete((0, path_1.path) `/chatkit/threads/${threadID}`, {
  55. ...options,
  56. headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
  57. });
  58. }
  59. /**
  60. * List ChatKit thread items
  61. *
  62. * @example
  63. * ```ts
  64. * // Automatically fetches more pages as needed.
  65. * for await (const thread of client.beta.chatkit.threads.listItems(
  66. * 'cthr_123',
  67. * )) {
  68. * // ...
  69. * }
  70. * ```
  71. */
  72. listItems(threadID, query = {}, options) {
  73. return this._client.getAPIList((0, path_1.path) `/chatkit/threads/${threadID}/items`, (pagination_1.ConversationCursorPage), { query, ...options, headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]) });
  74. }
  75. }
  76. exports.Threads = Threads;
  77. //# sourceMappingURL=threads.js.map