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
29.49k stars 2.19k forks source link

Unable to use the placeholder parameter with ChatInterface #8175

Closed yvrjsharma closed 2 weeks ago

yvrjsharma commented 2 weeks ago

Describe the bug

ChatInterface does not accept the placeholder parameter, although it is mentioned in the documentation. ChatInterface should ideally support the parameter.

TypeError: ChatInterface.__init__() got an unexpected keyword argument 'placeholder'

Have you searched existing issues? 🔎

Reproduction

This runs into error:


import gradio as gr

def echo(message, history):
    return message

demo = gr.ChatInterface(fn=echo, 
                        examples=["hello", "hola", "merhaba"], 
                        title="Echo Bot",
                        placeholder="TESTING")
demo.launch()

Following code works fine:


import gradio as gr

def echo(message, history):
    return message

chatbot = gr.Chatbot(placeholder="TESTING")
with gr.Blocks() as demo:
    gr.ChatInterface(fn=echo,
                     examples=["hello", "hola", "merhaba"], 
                     title="Echo Bot",
                     chatbot=chatbot
                     )
demo.launch()

Screenshot

image

Logs

No response

System Info

- Testing with Gradio sdk - `4.28.3`
- Running on Google Colab

Severity

I can work around it

pngwn commented 2 weeks ago

Looks like we didn't add this to ChatInterface when we added it to Chatbot. https://github.com/gradio-app/gradio/pull/7849

Should be a quick addition.

abidlabs commented 2 weeks ago

The idea is that for any customization related to the Chatbot, you should pass in a Chatbot object to the chatbot argument in ChatInterface

ChatInterface does not accept the placeholder parameter, although it is mentioned in the documentation

I don't see it mentioned in the docs? https://www.gradio.app/docs/gradio/chatinterface

yvrjsharma commented 2 weeks ago

Screenshot_20240430-194051__01

Thanks for quick response on this @abidlabs and @pngwn ! Ref to the attached image : This comes up in our docs for me, under the ChatInterface -> Initialisation subsection.

abidlabs commented 2 weeks ago

Sorry where in the screenshot does it refer to the placeholder argument?

pngwn commented 2 weeks ago

Yeah I don't see it there either. Only on Chatbot.

yvrjsharma commented 2 weeks ago

I understand the issue now, thanks for clarifying it in another related discussion @abidlabs.

Yuvi I think the confusion in this issue is stemming from the same persistent issue where the docs for some components / classes actually show the docs for a different class

I recall seeing a placeholder argument for ChatInterface when I was creating the issue, although the screenshot I provided in the ticket is of fill_height. Sorry about that confusion.

Thank you for taking the time to follow up on this issue and for providing a clear explanation of the reasoning behind it.

The idea is that for any customization related to the Chatbot, you should pass in a Chatbot object to the chatbot argument in ChatInterface

I am okay with closing the issue.