gorilla-llm / gorilla-cli

LLMs for your CLI
https://gorilla.cs.berkeley.edu/
Apache License 2.0
1.28k stars 75 forks source link

🦍 Emoji causes UnicodeEncodeError in MINGW64 (Git Bash) #17

Closed Fthree closed 1 year ago

Fthree commented 1 year ago

Hi!

Trying the Gorilla CLI on my Git Bash instance on Windows 10 I get the error:

Traceback (most recent call last):
  File "G:\Programs\conda\lib\site-packages\halo\halo.py", line 410, in _render_frame
    self._write(output)
  File "G:\Programs\conda\lib\site-packages\halo\halo.py", line 305, in _write
    self._stream.write(s)
  File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 47, in write
    self.__convertor.write(text)
  File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 177, in write
    self.write_and_convert(text)
  File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 205, in write_and_convert
    self.write_plain_text(text, cursor, len(text))
  File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 210, in write_plain_text
    self.wrapped.write(text[start:end])
  File "G:\Programs\conda\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f98d' in position 3: character maps to <undefined>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "G:\Programs\conda\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "G:\Programs\conda\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "G:\Programs\conda\Scripts\gorilla.exe\__main__.py", line 7, in <module>
  File "G:\Programs\conda\lib\site-packages\go_cli.py", line 136, in main
    with Halo(text="\U0001f98d Loading", spinner="dots"):
  File "G:\Programs\conda\lib\site-packages\halo\halo.py", line 120, in __enter__
    return self.start()
  File "G:\Programs\conda\lib\site-packages\halo\halo.py", line 498, in start
    self._render_frame()
  File "G:\Programs\conda\lib\site-packages\halo\halo.py", line 412, in _render_frame
    self._write(encode_utf_8_text(output))
  File "G:\Programs\conda\lib\site-packages\halo\halo.py", line 305, in _write
    self._stream.write(s)
  File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 47, in write
    self.__convertor.write(text)
  File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 177, in write
    self.write_and_convert(text)
  File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 199, in write_and_convert
    text = self.convert_osc(text)
  File "G:\Programs\conda\lib\site-packages\colorama\ansitowin32.py", line 261, in convert_osc
    for match in self.ANSI_OSC_RE.finditer(text):
TypeError: cannot use a string pattern on a bytes-like object

I can see that character '\U0001f98d' is the 🦍emoji if I'm not mistaken, and it seems that this can't be handled properly in the command line

ShishirPatil commented 1 year ago

Hey @Fthree @ZiflowSean thank you for flagging this and also for raising the PR! Delighted to have you as a contributor and look forward to having you involved as we build this open source project!