thinkst / zippy

Detect AI-generated text [relatively] quickly via compression ratios
MIT License
202 stars 8 forks source link

[BUG] Unable to run zippy -h #13

Open vivekprajapati2048 opened 5 months ago

vivekprajapati2048 commented 5 months ago

I want to implement this repository. I cloned it on my windows machine and followed Readme.md file for the installation using pip3. However, after successful installation, I ran into following error while trying to run zippy -h:

(venv) C:\Users\HP\PycharmProjects\zippy>zippy -h 
Traceback (most recent call last):
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main                              
    return _run_code(code, main_globals, None,                                                                                           
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code                                         
    exec(code, run_globals)                                                                                                              
  File "C:\Users\HP\PycharmProjects\zippy\venv\Scripts\zippy.exe\__main__.py", line 4, in <module>      
  File "C:\Users\HP\PycharmProjects\zippy\venv\lib\site-packages\zippy\__init__.py", line 1, in <module>
    from .zippy import *
  File "C:\Users\HP\PycharmProjects\zippy\venv\lib\site-packages\zippy\zippy.py", line 44, in <module>
    PRELUDE_STR = clean_text(files('zippy').joinpath(PRELUDE_FILE).read_text())
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\pathlib.py", line 1135, in read_text
    return f.read()
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 54323: character maps to <undefined>

Can you please let me know if there is any step which I am missing?

ranok commented 5 months ago

Thank you @vivekprajapati2048 for reporting this. It appears that I need to explicitly set a character encoding when reading files. I will make a couple fixes and ping you shortly to retest.