def is_text_file(path: str, size: int = 0, content: Optional[bytes] = None) -> bool:
    """Determine if a file is a text file based on extension, size, and content analysis.

    Args:
        path: File path or name
        size: File size in bytes (0 to skip size check)
        content: Optional sample of file content for analysis

    Returns:
        True if the file is likely a text file, False otherwise
    """
    # Skip large files
    if size > 0 and size > MAX_TEXT_DETECTION_SIZE:
        return False

    # Check extension
    ext = Path(path).suffix.lower()

    # Explicitly reject binary extensions
    if is_likely_binary_extension(ext):
        return False

    # Accept known text extensions
    if is_likely_text_extension(ext):
        return True

    # For unknown extensions, check content if available
    if content:
        return is_text_by_content_analysis(content)

    # For unknown extensions without content, use mimetypes as fallback
    mime_type, _ = mimetypes.guess_type(path)
    if mime_type and mime_type.startswith("text/"):
        return True

    # Default to exclude files with unknown types
    return False
Determine if a file is a text file based on extension, size, and content analysis.

    Args:
        path: File path or name
        size: File size in bytes (0 to skip size check)
        content: Optional sample of file content for analysis

    Returns:
        True if the file is likely a text file, False otherwise
    
backend/airweave/platform/utils/file_extensions.py