(
key: IntegrationTaskKey,
id: string,
options: OpenAIRequestOptions = {}
)
| 144 | } |
| 145 | |
| 146 | async waitForProcessing( |
| 147 | key: IntegrationTaskKey, |
| 148 | id: string, |
| 149 | options: OpenAIRequestOptions = {} |
| 150 | ): Promise<OpenAI.Files.FileObject> { |
| 151 | return this.runTask( |
| 152 | key, |
| 153 | async (client, task, io) => { |
| 154 | const url = createBackgroundFetchUrl( |
| 155 | client, |
| 156 | `/files/${id}`, |
| 157 | this.options.defaultQuery, |
| 158 | options |
| 159 | ); |
| 160 | |
| 161 | const headers = this.options.defaultHeaders ?? {}; |
| 162 | |
| 163 | const processedFile = await io.backgroundPoll<OpenAI.Files.FileObject>("poll", { |
| 164 | url, |
| 165 | requestInit: { |
| 166 | headers: createBackgroundFetchHeaders(client, task.idempotencyKey, headers, options), |
| 167 | }, |
| 168 | interval: 10, |
| 169 | timeout: 600, |
| 170 | responseFilter: { |
| 171 | status: [200], |
| 172 | body: { |
| 173 | status: ["processed", "error", "deleted"], |
| 174 | }, |
| 175 | }, |
| 176 | }); |
| 177 | |
| 178 | return processedFile; |
| 179 | }, |
| 180 | { |
| 181 | name: "Wait for processing", |
| 182 | properties: [ |
| 183 | { |
| 184 | label: "fileId", |
| 185 | text: id, |
| 186 | }, |
| 187 | ], |
| 188 | }, |
| 189 | handleOpenAIError |
| 190 | ); |
| 191 | } |
| 192 | |
| 193 | retrieve( |
| 194 | key: IntegrationTaskKey, |
nothing calls this directly
no test coverage detected