Gradio Chat Component UI Behaviour - Only posting query and response together

Hi,

In the following Langchain/Gradio code, when I type the question and hit submit, the question doesnโ€™t get posted to the Chat UI. Instead, it has to wait until the model gives back the response, then it will display both the question and answer at the same time.

Anyone know how to alter that behaviour?

import gradio as gr
# Define chat interface
with gr.Blocks() as demo:
    chatbot = gr.Chatbot()
    msg = gr.Textbox()
    clear = gr.Button("Clear")
    chat_history = []

    def user(query, chat_history):
        print("User query:", query)
        print("Chat history:", chat_history)

        # Convert chat history to list of tuples
        chat_history_tuples = []
        for message in chat_history:
            chat_history_tuples.append((message[0], message[1]))
        
        # Get result from QA chain
        result = qa({"question": query, "chat_history": chat_history_tuples})
        
        # Append user message and response to chat history
        chat_history.append((query, result["answer"]))
        print("Updated chat history:", chat_history)
        
        return gr.update(value=""), chat_history


    msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False)
    clear.click(lambda: None, None, chatbot, queue=False)

if __name__ == "__main__":
    demo.launch(debug=True)

Thanks.