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

example_labels does not work for ChatInterface #9951

Open
1 task done
jamie0725 opened this issue Nov 13, 2024 · 1 comment
Open
1 task done

example_labels does not work for ChatInterface #9951

jamie0725 opened this issue Nov 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jamie0725
Copy link

Describe the bug

Based on the screenshot, when using additional_inputs in ChatInterface and providing example prompts, you must manually include default values for these additional inputs in the examples; otherwise, they will be set to None. However, I dislike the examples being displayed beneath the chatbot and the visibility of the additional input values. After reviewing the documentation, I believe example_labels could replace the example display, showing only the example text within the chatbot. Unfortunately, the variable appears to have no effect.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr



def get_chat_response(
    req: gr.Request,
    message: str,
    history: list,
    var_a: bool,
    var_b: list[str],
    var_c: bool,
):

    print(var_a, var_b, var_c)
    return "Hello, World!"


def get_blocks():

    with gr.Blocks(title="Test", theme=gr.themes.Default()) as demo:
        gr.Markdown("# Test")
        with gr.Tab("Test"):
            with gr.Row():
                with gr.Row():
                    var_a = gr.Checkbox(
                        label="A1",
                        value=True,
                    )
                    var_c = gr.Checkbox(
                        label="A2",
                        value=True,
                    )
                var_b = gr.CheckboxGroup(
                    label="A3",
                    choices=["1", "2", "3", "4"],
                    value=None,
                )
            chatbot = gr.Chatbot(
                type="messages",
                height=300,
                render=False,
                show_copy_button=True,
            )
            gr.ChatInterface(
                get_chat_response,
                type="messages",
                chatbot=chatbot,
                additional_inputs=[var_a, var_b, var_c],
                examples=[["hello", True, [], True], ["thisisatest", True, [], True], ["totestthetest", True, [], True]],
                example_labels=["A", "B", "C"],
                autofocus=False,
                show_progress="full",
            )
    demo.queue()

    return demo


demo = get_blocks()
demo.launch()

Screenshot

image

Logs

No response

System Info

gradio=5.5.0

Severity

Blocking usage of gradio

@jamie0725 jamie0725 added the bug Something isn't working label Nov 13, 2024
@jamie0725
Copy link
Author

What I want is one of these behaviors:

  1. Not required to set the values for additional_inputs in examples, but still use the inputs' default values.
  2. Setting the values for additional_inputs in examples is also fine, but don't show their values on the webpage; instead, only show the text part to the user as an example prompt inside the chatbot.

In the end, I want the examples to use the same default values for additional_inputs, and at the same time want the examples to be shown like this:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant