oobabooga / text-generation-webui

A Gradio web UI for Large Language Models.
GNU Affero General Public License v3.0
39.7k stars 5.21k forks source link

Saving a character causes the character selector to become blank and the UI fails to save logs correctly as a result #6272

Closed sinful-developer closed 1 month ago

sinful-developer commented 2 months ago

Describe the bug

Ever since version v1.11 I've had an issue where the UI tried to save a folder that exceeded the filename limit of my OS.

My guess is that this bug could be have been introduced with the optimization of the UI. But that's just a guess, my understanding of python is pretty depressing.

I've finally narrowed down the cause of that error and it appears to be caused by the character selector not remembering what character it's on when you click save. It will instead try to load a character who has the name of the YAML content in the drop down.

This isn't the biggest issue as the character is still saved and the settings are still loaded in. The problem occurs when you chat with the character as the character's name is no longer used under logs/chat but instead something like "[{'choices': ['Assistant', 'Example', 'Thomas'], 'value': 'Thomas', '__type__': 'update'}]"

I hope my attempt at explaining all this makes sense. Otherwise I'd happily try to clarify.

Is there an existing issue for this?

Reproduction

  1. Clone the repo (existing installation will also get the issue).
  2. run ./start_linux.sh
  3. Create a character or save an existing one.
  4. The drop down will become blank and an error will be thrown in the console about no character being selected. The character is still saved to the characters folder with the correct name. But the UI will get confused when saving the chat log.

Screenshot

Saving the character: billede

The menu goes blank, though everything (context, greeting, name, etc. is still loaded): billede

The chat is also still there: billede

But if you delete the chat or a message in the chat it will create a folder with the YAML content like the one below: billede This folder can quickly exceed the filename limit or not work at all because of illegal characters. My filesystem is just psychotic enough to let me use YAML as a filename ๐Ÿ˜…

Logs

21:14:23-069556 INFO     Saved "/mnt/data_drive/llm_debug/text-generation-webui/characters/Thomas.yaml".
21:14:23-270744 ERROR    Could not find the character "[{'choices': ['Assistant', 'Example', 'Thomas'], 'value': 'Thomas',
                         '__type__': 'update'}]" inside characters/. No character has been loaded.
Traceback (most recent call last):
  File "/mnt/data_drive/llm_debug/text-generation-webui/installer_files/env/lib/python3.11/site-packages/gradio/queueing.py", line 527, in process_events
    response = await route_utils.call_process_api(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/data_drive/llm_debug/text-generation-webui/installer_files/env/lib/python3.11/site-packages/gradio/route_utils.py", line 261, in call_process_api
    output = await app.get_blocks().process_api(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/data_drive/llm_debug/text-generation-webui/installer_files/env/lib/python3.11/site-packages/gradio/blocks.py", line 1786, in process_api
    result = await self.call_function(
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/data_drive/llm_debug/text-generation-webui/installer_files/env/lib/python3.11/site-packages/gradio/blocks.py", line 1338, in call_function
    prediction = await anyio.to_thread.run_sync(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/data_drive/llm_debug/text-generation-webui/installer_files/env/lib/python3.11/site-packages/anyio/to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/data_drive/llm_debug/text-generation-webui/installer_files/env/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 2177, in run_sync_in_worker_thread
    return await future
           ^^^^^^^^^^^^
  File "/mnt/data_drive/llm_debug/text-generation-webui/installer_files/env/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 859, in run
    result = context.run(func, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/data_drive/llm_debug/text-generation-webui/installer_files/env/lib/python3.11/site-packages/gradio/utils.py", line 759, in wrapper
    response = f(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^
  File "/mnt/data_drive/llm_debug/text-generation-webui/modules/chat.py", line 1121, in handle_character_menu_change
    name1, name2, picture, greeting, context = load_character(state['character_menu'], state['name1'], state['name2'])
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/data_drive/llm_debug/text-generation-webui/modules/chat.py", line 732, in load_character
    raise ValueError
ValueError

System Info

OS: Fedora 40 running Linux kernel 6.9.10
CPU: AMD Ryzen 7 7735HS
GPU (onboard): Radeon 680M
RAM: 32GB
oobabooga commented 2 months ago

Thanks for reporting this. It was 1 stray comma that cause the whole issue. Fixed here: https://github.com/oobabooga/text-generation-webui/commit/498fec2c7c7df376007f264261acfcfcb76168ea

sinful-developer commented 1 month ago

Classic ๐Ÿ˜„

I can confirm https://github.com/oobabooga/text-generation-webui/commit/498fec2c7c7df376007f264261acfcfcb76168ea fixed the issue for me.

Thank your for prompt response and fix ๐Ÿ˜Š