gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
33.97k stars 2.58k forks source link

`example_labels` does not work for ChatInterface #9951

Open jamie0725 opened 2 days ago

jamie0725 commented 2 days ago

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? 🔎

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 commented 2 days ago

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