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
32.13k stars 2.4k forks source link

Make the accordion open by default if its the last message in the chatbot history #9081

Open davidberenstein1957 opened 1 month ago

davidberenstein1957 commented 1 month ago

Describe the bug

The docs show different bahavior https://www.gradio.app/docs/gradio/chatbot#behavior

Have you searched existing issues? 🔎

Reproduction

https://github.com/davidberenstein1957/data-viber/blob/main/README.md

from data_viber import AnnotatorInterFace

prompts = [
    [
        {
            "role": "user",
            "content": "Tell me something about Anthony Bourdain."
        },
        {
            "role": "assistant",
            "content": "Anthony Michael Bourdain was an American celebrity chef, author, and travel documentarian."
        }
    ]
]

interface = AnnotatorInterFace.for_chat_classification_per_message(
    prompts=prompts,
    labels=["toxic", "non-toxic"],
    fn=None, # a callable e.g. (function or transformers pipelines) that returns [{"label": str, "score": float}]
    dataset_name=None # "<my_hf_org>/<my_dataset>" if you want to log to the hub
)
interface.launch()

Screenshot

image

Logs

No response

System Info

MacOS 
Chromium
gradio                        4.22.0

Severity

I can work around it

abidlabs commented 1 month ago

Hi @davidberenstein1957 sorry I didn't understand, can you elaborate what the issue is? In your screenshot, it looks like the accordion is expanded, no?

davidberenstein1957 commented 1 month ago

Hi @aliabid94, It is collapsed by default and according to the docs it should not be an accordion at all. I think having the accordion collapsed by default makes it a bit useless for chat interactionsbut I guess it inherits the behavior from the agent tool information accordion? Would it be possible to add an additional flag to the Metadata to control this? "expanded=True" or something?

freddyaboulton commented 1 month ago

ah the image linked in the docs is outdated, will fix. We designed the accordion for tool responses which is why they are closed by default. If you want to add a general title for your message, I think you can use include it as a markdown header in your response.

davidberenstein1957 commented 1 month ago

Okay, I wanted to avoid altering my original content that is why the Metadata looked nice. Would it be possible achieve an opened accordion by default? On 13 Aug 2024, at 22:09, Freddy Boulton @.***> wrote: ah the image linked in the docs is outdated, will fix. We designed the accordion for tool responses which is why they are closed by default. If you want to add a general title for your message, I think you can use include it as a markdown header in your response.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

abidlabs commented 1 month ago

Slight tangent: but one thing that I think we should do is make the accordion open by default if its the last message in the chatbot history. That creates a nice effect that while a message is streaming, you can see the tool use, but once its finished, it doesn't take up unnecessary space. Not sure whether that would be sufficient for you @davidberenstein1957?

davidberenstein1957 commented 1 month ago

Hi,I agree that that makes sense but sadly it would not halo with my usecase. I can work around it for now if there is not other way.Thank you for the help. On 13 Aug 2024, at 23:08, Abubakar Abid @.***> wrote: Slight tangent: but one thing that I think we should do is make the accordion open by default if its the last message in the chatbot history. That creates a nice effect that while a message is streaming, you can see the tool use, but once its finished, it doesn't take up unnecessary space. Not sure whether that would be sufficient for you @davidberenstein1957?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>