MCPcopy
hub / github.com/langroid/langroid / _load_doc_as_bytesio

Method _load_doc_as_bytesio

langroid/parsing/document_parser.py:262–275  ·  view source on GitHub ↗

Load the docs into a BytesIO object. Returns: BytesIO: A BytesIO object containing the doc data.

(self)

Source from the content-addressed store, hash-verified

260 raise ValueError("Unsupported document type from bytes")
261
262 def _load_doc_as_bytesio(self) -> BytesIO:
263 """
264 Load the docs into a BytesIO object.
265
266 Returns:
267 BytesIO: A BytesIO object containing the doc data.
268 """
269 if self.source.startswith(("http://", "https://")):
270 response = requests.get(self.source)
271 response.raise_for_status()
272 return BytesIO(response.content)
273 else:
274 with open(self.source, "rb") as f:
275 return BytesIO(f.read())
276
277 @staticmethod
278 def chunks_from_path_or_bytes(

Callers 4

__init__Method · 0.95
test_get_pdf_doc_urlFunction · 0.80
test_image_pdfFunction · 0.80
test_get_docx_fileFunction · 0.80

Calls 1

getMethod · 0.80

Tested by 3

test_get_pdf_doc_urlFunction · 0.64
test_image_pdfFunction · 0.64
test_get_docx_fileFunction · 0.64