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

QoL: Duplicate/fork chat #6594

Open
blightbow opened this issue Dec 21, 2024 · 2 comments
Open

QoL: Duplicate/fork chat #6594

blightbow opened this issue Dec 21, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@blightbow
Copy link

blightbow commented Dec 21, 2024

Description

A feature to quickly duplicate a chat log allows the user to experiment with other possible outputs while retaining an interesting one.

Additional Context

text-generation-webui is one of the few mature UIs that doesn't have this feature yet. The release notes for 2.0 mentioned that one of the goals of the UI redesign was to more closely emulate the appearance of other UIs, so it seemed like an appropriate moment to nudge on this. :)

Current workaround

The workaround is easily done, just unintuitive for some. It's inefficient for rapid iteration on outputs, but suffices when the user really wants to hang on to a particular output before regenerating it.

  • Navigate to the chat log directory
  • Copy the log in question
  • Perform any action that would trigger a reload of the chat list. No refresh button for this; requires swapping the character back and forth (in chat or chat-instruct modes) or reloading the webpage. Clicking into a different tab doesn't work.
@blightbow blightbow added the enhancement New feature or request label Dec 21, 2024
@dEATh-PM
Copy link

Here's my I'm-not-a-python-coder solution, just in case someone can use it for something.

chat.py

def handle_fork_chat_click(state, history):
    save_history(history, datetime.now().strftime('%Y%m%d-%H-%M-%S'), state['character_menu'], state['mode'])
    histories = find_all_histories_with_first_prompts(state)
    html = redraw_html(history, state['name1'], state['name2'], state['mode'], state['chat_style'], state['character_menu'])

    return [history, html, gr.update(choices=histories, value=histories[0][1])]

Creates a new log (with the same naming convention) with the contents of the current log and sets the copy as the active log.
A better way to do it is probably to use start_new_chat() to create the base state and then copy just the history.
Better yet, refactor the start_new_chat() with a function to create a blank chat that could then be called both when starting a new chat and making a fork. But this solved my needs, it's just not as maintainable as it could be.

ui_chat.py - Right under the "rename chat" button

                    shared.gradio['rename_chat'] = gr.Button('Rename', elem_classes='refresh-button', interactive=not mu)
                    #New code below; Old code above
                    shared.gradio['Fork chat'] = gr.Button('Fork chat', elem_classes=['refresh-button', 'focus-on-chat-input'])

ui_chat.py - Right after "shared.gradio['Start new chat'].click()"

    shared.gradio['Start new chat'].click(
        ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
        chat.handle_start_new_chat_click, gradio('interface_state'), gradio('history', 'display', 'unique_id'), show_progress=False)
    #New code below; Old code above          
    shared.gradio['Fork chat'].click(
        ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
        chat.handle_fork_chat_click, gradio('interface_state', 'history'), gradio('history', 'display', 'unique_id'), show_progress=False)

With some extra CSS it looks like this:
image
I can post that too, but it's just for aesthetics and requires changes to existing code.

Without extra CSS and changes:
image

Perhaps a symbol like ⑂ would be a better choice for the button.

Disclaimer:

As mentioned above, I'm not a python coder so, this might well be a vile way of doing it, but it works for me. I also can't really solve any issues that you may run into using the code.
Use at your own risk, don't trust random people on the internet, etc.

@Th-Underscore
Copy link

Think I did what you want with this extension: https://github.com/Th-Underscore/boogaPlus

Could push it into TGWUI directly once I finish it (could be a while from now once I start focusing on other projects). For now it's a simple zero-dependency extension tho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants