assistants.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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.Assistants = 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 Assistants extends resource_1.APIResource {
  10. /**
  11. * Create an assistant with a model and instructions.
  12. *
  13. * @example
  14. * ```ts
  15. * const assistant = await client.beta.assistants.create({
  16. * model: 'gpt-4o',
  17. * });
  18. * ```
  19. */
  20. create(body, options) {
  21. return this._client.post('/assistants', {
  22. body,
  23. ...options,
  24. headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
  25. });
  26. }
  27. /**
  28. * Retrieves an assistant.
  29. *
  30. * @example
  31. * ```ts
  32. * const assistant = await client.beta.assistants.retrieve(
  33. * 'assistant_id',
  34. * );
  35. * ```
  36. */
  37. retrieve(assistantID, options) {
  38. return this._client.get((0, path_1.path) `/assistants/${assistantID}`, {
  39. ...options,
  40. headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
  41. });
  42. }
  43. /**
  44. * Modifies an assistant.
  45. *
  46. * @example
  47. * ```ts
  48. * const assistant = await client.beta.assistants.update(
  49. * 'assistant_id',
  50. * );
  51. * ```
  52. */
  53. update(assistantID, body, options) {
  54. return this._client.post((0, path_1.path) `/assistants/${assistantID}`, {
  55. body,
  56. ...options,
  57. headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
  58. });
  59. }
  60. /**
  61. * Returns a list of assistants.
  62. *
  63. * @example
  64. * ```ts
  65. * // Automatically fetches more pages as needed.
  66. * for await (const assistant of client.beta.assistants.list()) {
  67. * // ...
  68. * }
  69. * ```
  70. */
  71. list(query = {}, options) {
  72. return this._client.getAPIList('/assistants', (pagination_1.CursorPage), {
  73. query,
  74. ...options,
  75. headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
  76. });
  77. }
  78. /**
  79. * Delete an assistant.
  80. *
  81. * @example
  82. * ```ts
  83. * const assistantDeleted =
  84. * await client.beta.assistants.delete('assistant_id');
  85. * ```
  86. */
  87. delete(assistantID, options) {
  88. return this._client.delete((0, path_1.path) `/assistants/${assistantID}`, {
  89. ...options,
  90. headers: (0, headers_1.buildHeaders)([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
  91. });
  92. }
  93. }
  94. exports.Assistants = Assistants;
  95. //# sourceMappingURL=assistants.js.map