## Description fix int unable find method .split, not sure why its a int ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin.
18 lines
653 B
Python
18 lines
653 B
Python
from io import BufferedReader
|
|
from typing import Union, BinaryIO
|
|
from .data_types import TextData, BinaryData
|
|
from tempfile import SpooledTemporaryFile
|
|
|
|
from cognee.modules.ingestion.exceptions import IngestionError
|
|
|
|
|
|
def classify(data: Union[str, BinaryIO], filename: str = None):
|
|
if isinstance(data, str):
|
|
return TextData(data)
|
|
|
|
if isinstance(data, BufferedReader) or isinstance(data, SpooledTemporaryFile):
|
|
return BinaryData(data, str(data.name).split("/")[-1] if data.name else filename)
|
|
|
|
raise IngestionError(
|
|
message=f"Type of data sent to classify(data: Union[str, BinaryIO) not supported: {type(data)}"
|
|
)
|