Hi,
I’m currently building a chatbot with Chat Interface and OpenAI. I’ve been trying to write an input() event listener where the chat history gets cleared when I select a new option on a dropdown (basically automating the clear button). I’ve read the code for the clear button on Gradio’s GitHub page, and it seems that all you have to do is set the component you want cleared to [ ] or None.
Unfortunately, when I set the Chat Interface component to [ ] or None, I get the following error:
gradio.exceptions.InvalidBlockError: Output component with id 1 used in input() event not found in this gr.Blocks context. You are allowed to nest gr.Blocks contexts, but there must be a gr.Blocks context that contains all components and events.
I’m really not sure what the issue is, because I only have one Block and every component is inside it.
The closest I’ve gotten it to working is making a Chatbot component before the Chat Interface and setting it to the chatbot parameter in the Chat Interface, then upon the dropdown selection, resetting the messages sent to OpenAI and setting the Chatbot component to [ ]. This will actually clear the chat history. However, as soon as I submit another message in the Chat Interface, the chat history from before the dropdown change mysteriously reappears, as if I had never reset the Chatbot component in the first place? This is super strange to me as my debugging has confirmed that the message history sent to OpenAI has been totally reset to default, so I wonder where the Chat Interface is getting it from. Maybe Chat Interface is storing the chat history somewhere inaccessible to a reset?
This issue isn’t at all present when I just press the clear button of the Chat Interface, so ideally, if there’s any way to just automate a click, that would be amazing. Thanks.