assistants.mjs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. import { APIResource } from "../../core/resource.mjs";
  3. import { CursorPage } from "../../core/pagination.mjs";
  4. import { buildHeaders } from "../../internal/headers.mjs";
  5. import { path } from "../../internal/utils/path.mjs";
  6. export class Assistants extends APIResource {
  7. /**
  8. * Create an assistant with a model and instructions.
  9. *
  10. * @example
  11. * ```ts
  12. * const assistant = await client.beta.assistants.create({
  13. * model: 'gpt-4o',
  14. * });
  15. * ```
  16. */
  17. create(body, options) {
  18. return this._client.post('/assistants', {
  19. body,
  20. ...options,
  21. headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
  22. });
  23. }
  24. /**
  25. * Retrieves an assistant.
  26. *
  27. * @example
  28. * ```ts
  29. * const assistant = await client.beta.assistants.retrieve(
  30. * 'assistant_id',
  31. * );
  32. * ```
  33. */
  34. retrieve(assistantID, options) {
  35. return this._client.get(path `/assistants/${assistantID}`, {
  36. ...options,
  37. headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
  38. });
  39. }
  40. /**
  41. * Modifies an assistant.
  42. *
  43. * @example
  44. * ```ts
  45. * const assistant = await client.beta.assistants.update(
  46. * 'assistant_id',
  47. * );
  48. * ```
  49. */
  50. update(assistantID, body, options) {
  51. return this._client.post(path `/assistants/${assistantID}`, {
  52. body,
  53. ...options,
  54. headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
  55. });
  56. }
  57. /**
  58. * Returns a list of assistants.
  59. *
  60. * @example
  61. * ```ts
  62. * // Automatically fetches more pages as needed.
  63. * for await (const assistant of client.beta.assistants.list()) {
  64. * // ...
  65. * }
  66. * ```
  67. */
  68. list(query = {}, options) {
  69. return this._client.getAPIList('/assistants', (CursorPage), {
  70. query,
  71. ...options,
  72. headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
  73. });
  74. }
  75. /**
  76. * Delete an assistant.
  77. *
  78. * @example
  79. * ```ts
  80. * const assistantDeleted =
  81. * await client.beta.assistants.delete('assistant_id');
  82. * ```
  83. */
  84. delete(assistantID, options) {
  85. return this._client.delete(path `/assistants/${assistantID}`, {
  86. ...options,
  87. headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
  88. });
  89. }
  90. }
  91. //# sourceMappingURL=assistants.mjs.map