MCPcopy
hub / github.com/openai/openai-python / poll

Method poll

src/openai/resources/vector_stores/files.py:814–853  ·  view source on GitHub ↗

Wait for the vector store file to finish processing. Note: this will return even if the file failed to process, you need to check file.last_error and file.status to handle these cases

(
        self,
        file_id: str,
        *,
        vector_store_id: str,
        poll_interval_ms: int | Omit = omit,
    )

Source from the content-addressed store, hash-verified

812 )
813
814 async def poll(
815 self,
816 file_id: str,
817 *,
818 vector_store_id: str,
819 poll_interval_ms: int | Omit = omit,
820 ) -> VectorStoreFile:
821 """Wait for the vector store file to finish processing.
822
823 Note: this will return even if the file failed to process, you need to check
824 file.last_error and file.status to handle these cases
825 """
826 headers: dict[str, str] = {"X-Stainless-Poll-Helper": "true"}
827 if is_given(poll_interval_ms):
828 headers["X-Stainless-Custom-Poll-Interval"] = str(poll_interval_ms)
829
830 while True:
831 response = await self.with_raw_response.retrieve(
832 file_id,
833 vector_store_id=vector_store_id,
834 extra_headers=headers,
835 )
836
837 file = response.parse()
838 if file.status == "in_progress":
839 if not is_given(poll_interval_ms):
840 from_header = response.headers.get("openai-poll-after-ms")
841 if from_header is not None:
842 poll_interval_ms = int(from_header)
843 else:
844 poll_interval_ms = 1000
845
846 await self._sleep(poll_interval_ms / 1000)
847 elif file.status == "cancelled" or file.status == "completed" or file.status == "failed":
848 return file
849 else:
850 if TYPE_CHECKING: # type: ignore[unreachable]
851 assert_never(file.status)
852 else:
853 return file
854
855 async def upload(
856 self,

Callers 1

create_and_pollMethod · 0.95

Calls 5

is_givenFunction · 0.85
retrieveMethod · 0.45
parseMethod · 0.45
getMethod · 0.45
_sleepMethod · 0.45

Tested by

no test coverage detected