async def aget_json does not work with bytes #207

Open
opened 2026-02-16 00:17:08 -05:00 by yindo · 2 comments
Owner

Originally created by @stonesthatwhisper on GitHub (Jul 25, 2024).

aget_json does not work with bytes although it accepts FileInput, which is supposed to be a union containing bytes.

Client:

  • Python Library
Originally created by @stonesthatwhisper on GitHub (Jul 25, 2024). aget_json does not work with bytes although it accepts `FileInput`, which is supposed to be a union containing `bytes`. **Client:** - Python Library
yindo added the bug label 2026-02-16 00:17:08 -05:00
Author
Owner

@SuryaThiru commented on GitHub (Sep 11, 2024):

Encountered the same issue.

Just allowing the specified FileInput types seems to fix it:

async def aget_json(
    self,
    file_path: Union[List[FileInput], FileInput],
    extra_info: Optional[dict] = None,
) -> List[dict]:
    """Load data from the input path."""
    # if isinstance(file_path, (str, Path)):
    if isinstance(file_path, (str, Path, bytes, BufferedIOBase)):
        return await self._aget_json(file_path, extra_info=extra_info)

I can open a PR extending the tests.

@SuryaThiru commented on GitHub (Sep 11, 2024): Encountered the same issue. Just allowing the specified `FileInput` types seems to fix it: ```python async def aget_json( self, file_path: Union[List[FileInput], FileInput], extra_info: Optional[dict] = None, ) -> List[dict]: """Load data from the input path.""" # if isinstance(file_path, (str, Path)): if isinstance(file_path, (str, Path, bytes, BufferedIOBase)): return await self._aget_json(file_path, extra_info=extra_info) ``` I can open a PR extending the tests.
Author
Owner

@pujan-dahal-yirifi commented on GitHub (Oct 1, 2024):

Encountered the same issue, is there any way to get parsed JSON objects by providing a string/byte content?

@pujan-dahal-yirifi commented on GitHub (Oct 1, 2024): Encountered the same issue, is there any way to get parsed JSON objects by providing a string/byte content?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/llama_cloud_services#207