def strip_invalid_filename_characters(filename: str, max_bytes: int = 200) -> str:
    """
    Strips invalid characters from a filename and ensures it does not exceed the maximum byte length
    Invalid characters are any characters that are not alphanumeric or one of the following: . _ - ,
    The filename may include an extension (in which case it is preserved exactly as is), or could be just a name without an extension.
    """
    name, ext = os.path.splitext(filename)
    name = "".join([char for char in name if char.isalnum() or char in "._-, "])
    filename = name + ext
    filename_len = len(filename.encode())
    if filename_len > max_bytes:
        while filename_len > max_bytes:
            if len(name) == 0:
                break
            name = name[:-1]
            filename = name + ext
            filename_len = len(filename.encode())
    return filename

    Strips invalid characters from a filename and ensures it does not exceed the maximum byte length
    Invalid characters are any characters that are not alphanumeric or one of the following: . _ - ,
    The filename may include an extension (in which case it is preserved exactly as is), or could be just a name without an extension.
    
client/python/gradio_client/utils.py