Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeEncodeError in NVIM when Running ':! chatblade' Command #70

Closed
ManchurianMan opened this issue Jan 12, 2024 · 1 comment
Closed

Comments

@ManchurianMan
Copy link

Error

When in NVIM, running the ":! chatblade " command, it returns the following error:

------------------------------------ user -------------------------------------
tell me a joke
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\manchurianman\AppData\Local\Programs\Python\Python311\Scripts\chatblade.exe\__main__.py", line 7, in <module>
  File "C:\Users\manchurianman\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatblade\__main__.py", line 5, in main
    cli.cli()
  File "C:\Users\manchurianman\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatblade\cli.py", line 152, in cli
    handle_input(query, params)
  File "C:\Users\manchurianman\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatblade\cli.py", line 82, in handle_input
    printer.print_messages(messages, params)
  File "C:\Users\manchurianman\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatblade\printer.py", line 55, in print_messages
    print_message(message, args)
  File "C:\Users\manchurianman\AppData\Local\Programs\Python\Python311\Lib\site-packages\chatblade\printer.py", line 76, in print_message
    console.print(Rule(style=COLORS[message.role]))
  File "C:\Users\manchurianman\AppData\Local\Programs\Python\Python311\Lib\site-packages\rich\console.py", line 1673, in print
    with self:
  File "C:\Users\manchurianman\AppData\Local\Programs\Python\Python311\Lib\site-packages\rich\console.py", line 865, in __exit__
    self._exit_buffer()
  File "C:\Users\manchurianman\AppData\Local\Programs\Python\Python311\Lib\site-packages\rich\console.py", line 823, in _exit_buffer
    self._check_buffer()
  File "C:\Users\manchurianman\AppData\Local\Programs\Python\Python311\Lib\site-packages\rich\console.py", line 2027, in _check_buffer
    legacy_windows_render(buffer, LegacyWindowsTerm(self.file))
  File "C:\Users\manchurianman\AppData\Local\Programs\Python\Python311\Lib\site-packages\rich\_windows_renderer.py", line 17, in legacy_windows_render
    term.write_styled(text, style)
  File "C:\Users\manchurianman\AppData\Local\Programs\Python\Python311\Lib\site-packages\rich\_win32_console.py", line 442, in write_styled
    self.write_text(text)
  File "C:\Users\manchurianman\AppData\Local\Programs\Python\Python311\Lib\site-packages\rich\_win32_console.py", line 403, in write_text
    self.write(text)
  File "C:\Users\manchurianman\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-78: character maps to <undefined>

shell returned 1

It has to do with the horizontal dividers. When I run the same command but with the -n option, it works just fine.

Environment

Python version: 3.11.4
OS: Windows 10.0.19045 N/A Build 19045
Chatblade version: 0.3.4
NVIM version: v0.9.4

@npiv
Copy link
Owner

npiv commented Feb 11, 2024

chatblade uses pretty printing via https://github.com/Textualize/rich,

if you want to reference it from a script you should use -n as you are doing. Not sure what change you would expect from chatblade here.

@npiv npiv closed this as completed Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants