Wait for the given file batch to be processed. Note: this will return even if one of the files failed to process, you need to check batch.file_counts.failed_count to handle this case.
(
self,
batch_id: str,
*,
vector_store_id: str,
poll_interval_ms: int | Omit = omit,
)
| 329 | ) |
| 330 | |
| 331 | def poll( |
| 332 | self, |
| 333 | batch_id: str, |
| 334 | *, |
| 335 | vector_store_id: str, |
| 336 | poll_interval_ms: int | Omit = omit, |
| 337 | ) -> VectorStoreFileBatch: |
| 338 | """Wait for the given file batch to be processed. |
| 339 | |
| 340 | Note: this will return even if one of the files failed to process, you need to |
| 341 | check batch.file_counts.failed_count to handle this case. |
| 342 | """ |
| 343 | headers: dict[str, str] = {"X-Stainless-Poll-Helper": "true"} |
| 344 | if is_given(poll_interval_ms): |
| 345 | headers["X-Stainless-Custom-Poll-Interval"] = str(poll_interval_ms) |
| 346 | |
| 347 | while True: |
| 348 | response = self.with_raw_response.retrieve( |
| 349 | batch_id, |
| 350 | vector_store_id=vector_store_id, |
| 351 | extra_headers=headers, |
| 352 | ) |
| 353 | |
| 354 | batch = response.parse() |
| 355 | if batch.file_counts.in_progress > 0: |
| 356 | if not is_given(poll_interval_ms): |
| 357 | from_header = response.headers.get("openai-poll-after-ms") |
| 358 | if from_header is not None: |
| 359 | poll_interval_ms = int(from_header) |
| 360 | else: |
| 361 | poll_interval_ms = 1000 |
| 362 | |
| 363 | self._sleep(poll_interval_ms / 1000) |
| 364 | continue |
| 365 | |
| 366 | return batch |
| 367 | |
| 368 | def upload_and_poll( |
| 369 | self, |