kotaemon icon indicating copy to clipboard operation
kotaemon copied to clipboard

[BUG] UnicodeDecodeError when inheriting Gradio components on Windows

Open Lee-Ju-Yeong opened this issue 1 year ago • 0 comments

Description

When inheriting from Gradio's gr.File component to create a new component, a UnicodeDecodeError occurs on Windows due to 'cp949' codec issues. This happens because Gradio's internal code uses the default system encoding when reading files.

Reproduction steps

# optional (setup env)
conda create -n kotaemon python=3.10
conda activate kotaemon

pip install -e "libs/kotaemon[all]"
pip install -e "libs/ktem"

Screenshots

![DESCRIPTION](LINK.png)

Logs

leerj@DESKTOP-F8TPEBF MINGW64 /e/AI/pythonProject/venv/kotaemon (kotaemon-closednet)
$ python app.py
[nltk_data] Downloading package punkt_tab to
[nltk_data]     C:\Users\leerj\miniconda3\envs\kotaemon\lib\site-
[nltk_data]     packages\llama_index\core\_static/nltk_cache...
[nltk_data]   Package punkt_tab is already up-to-date!
Traceback (most recent call last):
  File "E:\AI\pythonProject\venv\kotaemon\app.py", line 33, in <module>
    from ktem.main import App  # noqa
  File "E:\AI\pythonProject\venv\kotaemon\libs\ktem\ktem\main.py", line 4, in <module>
    from ktem.pages.chat import ChatPage
  File "E:\AI\pythonProject\venv\kotaemon\libs\ktem\ktem\pages\chat\__init__.py", line 11, in <module>
    from ktem.index.file.ui import File
  File "E:\AI\pythonProject\venv\kotaemon\libs\ktem\ktem\index\file\ui.py", line 26, in <module>
    class File(gr.File):
  File "C:\Users\leerj\miniconda3\envs\kotaemon\lib\site-packages\gradio\component_meta.py", line 202, in __new__
    create_or_modify_pyi(component_class, name, events)
  File "C:\Users\leerj\miniconda3\envs\kotaemon\lib\site-packages\gradio\component_meta.py", line 92, in create_or_modify_pyi
    source_code = source_file.read_text()
  File "C:\Users\leerj\miniconda3\envs\kotaemon\lib\pathlib.py", line 1135, in read_text
    return f.read()
UnicodeDecodeError: 'cp949' codec can't decode byte 0x80 in position 1668: illegal multibyte sequence
(kotaemon)

Browsers

Chrome

OS

Windows

Additional information

No response

Lee-Ju-Yeong avatar Nov 14 '24 02:11 Lee-Ju-Yeong