files.d.mts 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import { APIResource } from "../core/resource.mjs";
  2. import { APIPromise } from "../core/api-promise.mjs";
  3. import { CursorPage, type CursorPageParams, PagePromise } from "../core/pagination.mjs";
  4. import { type Uploadable } from "../core/uploads.mjs";
  5. import { RequestOptions } from "../internal/request-options.mjs";
  6. export declare class Files extends APIResource {
  7. /**
  8. * Upload a file that can be used across various endpoints. Individual files can be
  9. * up to 512 MB, and the size of all files uploaded by one organization can be up
  10. * to 1 TB.
  11. *
  12. * - The Assistants API supports files up to 2 million tokens and of specific file
  13. * types. See the
  14. * [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools)
  15. * for details.
  16. * - The Fine-tuning API only supports `.jsonl` files. The input also has certain
  17. * required formats for fine-tuning
  18. * [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input)
  19. * or
  20. * [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
  21. * models.
  22. * - The Batch API only supports `.jsonl` files up to 200 MB in size. The input
  23. * also has a specific required
  24. * [format](https://platform.openai.com/docs/api-reference/batch/request-input).
  25. *
  26. * Please [contact us](https://help.openai.com/) if you need to increase these
  27. * storage limits.
  28. */
  29. create(body: FileCreateParams, options?: RequestOptions): APIPromise<FileObject>;
  30. /**
  31. * Returns information about a specific file.
  32. */
  33. retrieve(fileID: string, options?: RequestOptions): APIPromise<FileObject>;
  34. /**
  35. * Returns a list of files.
  36. */
  37. list(query?: FileListParams | null | undefined, options?: RequestOptions): PagePromise<FileObjectsPage, FileObject>;
  38. /**
  39. * Delete a file and remove it from all vector stores.
  40. */
  41. delete(fileID: string, options?: RequestOptions): APIPromise<FileDeleted>;
  42. /**
  43. * Returns the contents of the specified file.
  44. */
  45. content(fileID: string, options?: RequestOptions): APIPromise<Response>;
  46. /**
  47. * Waits for the given file to be processed, default timeout is 30 mins.
  48. */
  49. waitForProcessing(id: string, { pollInterval, maxWait }?: {
  50. pollInterval?: number;
  51. maxWait?: number;
  52. }): Promise<FileObject>;
  53. }
  54. export type FileObjectsPage = CursorPage<FileObject>;
  55. export type FileContent = string;
  56. export interface FileDeleted {
  57. id: string;
  58. deleted: boolean;
  59. object: 'file';
  60. }
  61. /**
  62. * The `File` object represents a document that has been uploaded to OpenAI.
  63. */
  64. export interface FileObject {
  65. /**
  66. * The file identifier, which can be referenced in the API endpoints.
  67. */
  68. id: string;
  69. /**
  70. * The size of the file, in bytes.
  71. */
  72. bytes: number;
  73. /**
  74. * The Unix timestamp (in seconds) for when the file was created.
  75. */
  76. created_at: number;
  77. /**
  78. * The name of the file.
  79. */
  80. filename: string;
  81. /**
  82. * The object type, which is always `file`.
  83. */
  84. object: 'file';
  85. /**
  86. * The intended purpose of the file. Supported values are `assistants`,
  87. * `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`,
  88. * `vision`, and `user_data`.
  89. */
  90. purpose: 'assistants' | 'assistants_output' | 'batch' | 'batch_output' | 'fine-tune' | 'fine-tune-results' | 'vision' | 'user_data';
  91. /**
  92. * @deprecated Deprecated. The current status of the file, which can be either
  93. * `uploaded`, `processed`, or `error`.
  94. */
  95. status: 'uploaded' | 'processed' | 'error';
  96. /**
  97. * The Unix timestamp (in seconds) for when the file will expire.
  98. */
  99. expires_at?: number;
  100. /**
  101. * @deprecated Deprecated. For details on why a fine-tuning training file failed
  102. * validation, see the `error` field on `fine_tuning.job`.
  103. */
  104. status_details?: string;
  105. }
  106. /**
  107. * The intended purpose of the uploaded file. One of: - `assistants`: Used in the
  108. * Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for
  109. * fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:
  110. * Flexible file type for any purpose - `evals`: Used for eval data sets
  111. */
  112. export type FilePurpose = 'assistants' | 'batch' | 'fine-tune' | 'vision' | 'user_data' | 'evals';
  113. export interface FileCreateParams {
  114. /**
  115. * The File object (not file name) to be uploaded.
  116. */
  117. file: Uploadable;
  118. /**
  119. * The intended purpose of the uploaded file. One of: - `assistants`: Used in the
  120. * Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for
  121. * fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:
  122. * Flexible file type for any purpose - `evals`: Used for eval data sets
  123. */
  124. purpose: FilePurpose;
  125. /**
  126. * The expiration policy for a file. By default, files with `purpose=batch` expire
  127. * after 30 days and all other files are persisted until they are manually deleted.
  128. */
  129. expires_after?: FileCreateParams.ExpiresAfter;
  130. }
  131. export declare namespace FileCreateParams {
  132. /**
  133. * The expiration policy for a file. By default, files with `purpose=batch` expire
  134. * after 30 days and all other files are persisted until they are manually deleted.
  135. */
  136. interface ExpiresAfter {
  137. /**
  138. * Anchor timestamp after which the expiration policy applies. Supported anchors:
  139. * `created_at`.
  140. */
  141. anchor: 'created_at';
  142. /**
  143. * The number of seconds after the anchor time that the file will expire. Must be
  144. * between 3600 (1 hour) and 2592000 (30 days).
  145. */
  146. seconds: number;
  147. }
  148. }
  149. export interface FileListParams extends CursorPageParams {
  150. /**
  151. * Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  152. * order and `desc` for descending order.
  153. */
  154. order?: 'asc' | 'desc';
  155. /**
  156. * Only return files with the given purpose.
  157. */
  158. purpose?: string;
  159. }
  160. export declare namespace Files {
  161. export { type FileContent as FileContent, type FileDeleted as FileDeleted, type FileObject as FileObject, type FilePurpose as FilePurpose, type FileObjectsPage as FileObjectsPage, type FileCreateParams as FileCreateParams, type FileListParams as FileListParams, };
  162. }
  163. //# sourceMappingURL=files.d.mts.map