file-batches.d.ts 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. import { APIResource } from "../../resource.js";
  2. import { Uploadable } from "../../core.js";
  3. import * as Core from "../../core.js";
  4. import * as FilesAPI from "./files.js";
  5. import { VectorStoreFilesPage } from "./files.js";
  6. import * as VectorStoresAPI from "./vector-stores.js";
  7. import { type CursorPageParams } from "../../pagination.js";
  8. export declare class FileBatches extends APIResource {
  9. /**
  10. * Create a vector store file batch.
  11. */
  12. create(vectorStoreId: string, body: FileBatchCreateParams, options?: Core.RequestOptions): Core.APIPromise<VectorStoreFileBatch>;
  13. /**
  14. * Retrieves a vector store file batch.
  15. */
  16. retrieve(vectorStoreId: string, batchId: string, options?: Core.RequestOptions): Core.APIPromise<VectorStoreFileBatch>;
  17. /**
  18. * Cancel a vector store file batch. This attempts to cancel the processing of
  19. * files in this batch as soon as possible.
  20. */
  21. cancel(vectorStoreId: string, batchId: string, options?: Core.RequestOptions): Core.APIPromise<VectorStoreFileBatch>;
  22. /**
  23. * Create a vector store batch and poll until all files have been processed.
  24. */
  25. createAndPoll(vectorStoreId: string, body: FileBatchCreateParams, options?: Core.RequestOptions & {
  26. pollIntervalMs?: number;
  27. }): Promise<VectorStoreFileBatch>;
  28. /**
  29. * Returns a list of vector store files in a batch.
  30. */
  31. listFiles(vectorStoreId: string, batchId: string, query?: FileBatchListFilesParams, options?: Core.RequestOptions): Core.PagePromise<VectorStoreFilesPage, FilesAPI.VectorStoreFile>;
  32. listFiles(vectorStoreId: string, batchId: string, options?: Core.RequestOptions): Core.PagePromise<VectorStoreFilesPage, FilesAPI.VectorStoreFile>;
  33. /**
  34. * Wait for the given file batch to be processed.
  35. *
  36. * Note: this will return even if one of the files failed to process, you need to
  37. * check batch.file_counts.failed_count to handle this case.
  38. */
  39. poll(vectorStoreId: string, batchId: string, options?: Core.RequestOptions & {
  40. pollIntervalMs?: number;
  41. }): Promise<VectorStoreFileBatch>;
  42. /**
  43. * Uploads the given files concurrently and then creates a vector store file batch.
  44. *
  45. * The concurrency limit is configurable using the `maxConcurrency` parameter.
  46. */
  47. uploadAndPoll(vectorStoreId: string, { files, fileIds }: {
  48. files: Uploadable[];
  49. fileIds?: string[];
  50. }, options?: Core.RequestOptions & {
  51. pollIntervalMs?: number;
  52. maxConcurrency?: number;
  53. }): Promise<VectorStoreFileBatch>;
  54. }
  55. /**
  56. * A batch of files attached to a vector store.
  57. */
  58. export interface VectorStoreFileBatch {
  59. /**
  60. * The identifier, which can be referenced in API endpoints.
  61. */
  62. id: string;
  63. /**
  64. * The Unix timestamp (in seconds) for when the vector store files batch was
  65. * created.
  66. */
  67. created_at: number;
  68. file_counts: VectorStoreFileBatch.FileCounts;
  69. /**
  70. * The object type, which is always `vector_store.file_batch`.
  71. */
  72. object: 'vector_store.files_batch';
  73. /**
  74. * The status of the vector store files batch, which can be either `in_progress`,
  75. * `completed`, `cancelled` or `failed`.
  76. */
  77. status: 'in_progress' | 'completed' | 'cancelled' | 'failed';
  78. /**
  79. * The ID of the
  80. * [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  81. * that the [File](https://platform.openai.com/docs/api-reference/files) is
  82. * attached to.
  83. */
  84. vector_store_id: string;
  85. }
  86. export declare namespace VectorStoreFileBatch {
  87. interface FileCounts {
  88. /**
  89. * The number of files that where cancelled.
  90. */
  91. cancelled: number;
  92. /**
  93. * The number of files that have been processed.
  94. */
  95. completed: number;
  96. /**
  97. * The number of files that have failed to process.
  98. */
  99. failed: number;
  100. /**
  101. * The number of files that are currently being processed.
  102. */
  103. in_progress: number;
  104. /**
  105. * The total number of files.
  106. */
  107. total: number;
  108. }
  109. }
  110. export interface FileBatchCreateParams {
  111. /**
  112. * A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
  113. * the vector store should use. Useful for tools like `file_search` that can access
  114. * files.
  115. */
  116. file_ids: Array<string>;
  117. /**
  118. * Set of 16 key-value pairs that can be attached to an object. This can be useful
  119. * for storing additional information about the object in a structured format, and
  120. * querying for objects via API or the dashboard. Keys are strings with a maximum
  121. * length of 64 characters. Values are strings with a maximum length of 512
  122. * characters, booleans, or numbers.
  123. */
  124. attributes?: Record<string, string | number | boolean> | null;
  125. /**
  126. * The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  127. * strategy. Only applicable if `file_ids` is non-empty.
  128. */
  129. chunking_strategy?: VectorStoresAPI.FileChunkingStrategyParam;
  130. }
  131. export interface FileBatchListFilesParams extends CursorPageParams {
  132. /**
  133. * A cursor for use in pagination. `before` is an object ID that defines your place
  134. * in the list. For instance, if you make a list request and receive 100 objects,
  135. * starting with obj_foo, your subsequent call can include before=obj_foo in order
  136. * to fetch the previous page of the list.
  137. */
  138. before?: string;
  139. /**
  140. * Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
  141. */
  142. filter?: 'in_progress' | 'completed' | 'failed' | 'cancelled';
  143. /**
  144. * Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  145. * order and `desc` for descending order.
  146. */
  147. order?: 'asc' | 'desc';
  148. }
  149. export declare namespace FileBatches {
  150. export { type VectorStoreFileBatch as VectorStoreFileBatch, type FileBatchCreateParams as FileBatchCreateParams, type FileBatchListFilesParams as FileBatchListFilesParams, };
  151. }
  152. export { VectorStoreFilesPage };
  153. //# sourceMappingURL=file-batches.d.ts.map