Get the Request headers using Blocks

Hi,

I am trying to do a chatbot and get the request header to manage my chat engine on a per user basis. I see example showing how to get that from the Interface, but it seems it is always part of a callback function.

How would you do it with this block:

with gr.Blocks() as demo:
    chatbot = gr.Chatbot()
    msg = gr.Textbox()
    clear = gr.ClearButton([msg, chatbot])

    def respond(message, chat_history):
        bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
        chat_history.append((message, bot_message))
        time.sleep(2)
        return "", chat_history


    msg.submit(respond, [msg, chatbot], [msg, chatbot])

app = gr.mount_gradio_app(app, demo, path=CUSTOM_PATH)

Thanks

2 Likes

Any update on this issue? I run into the same issue and can’t find any clue from docs and source code.

1 Like