Issues with adding default message to gradio chatbot when hosting on Huggingface space
I am trying to host my chatbot on huggingface space. I encountered this issue whereby when I tried to add the value parameter into the gradio Chatbot, I get a bunch of errors. It works when I try to run locally on my jupyter lab.snippet of my code below:conversation_chain = ConversationalRetrievalChain.from_llm(llm=llm, retriever=retriever, memory=memory, combine_docs_chain_kwargs={“prompt”: custom_prompt})Define an introductory messageintro_message = [{“role”: “assistant”, “content”: “Hello! I’m your virtual assistant!”}]def chat(message, history):result = conversation_chain.invoke({“question”: message})return result[“answer”]Gradio Chat Interfaceview = gr.ChatInterface(fn=chat,chatbot = gr.Chatbot(avatar_images=[“guru.png”, “guru.png”], type=“messages”,value=intro_message),type=“messages”)Launch the appifname== “main”:view.launch()Error message shown on huggingface spaces logs below:ReferenceError: scroll is not definedat file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:869:9at each (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:388:10)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:835:335at Object.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)at Object.default (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:1064:62)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14423:65at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14424:5at Object.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:1028:48at Proxy.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)ReferenceError: scroll is not definedat file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:869:9at each (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:388:10)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:835:335at Object.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)at Object.default (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:1064:62)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14423:65at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14424:5at Object.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:1028:48at Proxy.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)ReferenceError: scroll is not definedat file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:869:9at each (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:388:10)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:835:335at Object.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)at Object.default (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:1064:62)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14423:65at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14424:5at Object.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:1028:48at Proxy.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)ReferenceError: scroll is not definedat file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:869:9at each (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:388:10)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:835:335at Object.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)at Object.default (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:1064:62)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14423:65at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14424:5at Object.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:1028:48at Proxy.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)ReferenceError: scroll is not definedat file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:869:9at each (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:388:10)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:835:335at Object.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)at Object.default (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:1064:62)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14423:65at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14424:5at Object.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:1028:48at Proxy.$$render (file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/ssr-RaXq3SJh.js:423:16)Traceback (most recent call last):File “/home/user/app/app.py”, line 103, inAnybody encountered this before?
2025-01-10T02:26:05Z
There is no error in your code. I can run your code successfully.What’s your problem?
2025-01-10T04:20:33Z
Thanks for taking your time to troubleshoot my problem. Have you tried running it on huggingface space? I had errors when doing so but it works fine when I run it locally in my jupyter lab.
2025-01-10T07:08:11Z
I haven’t seen this error myself, but the error message does include SSR. It’s possible that theSSR_MODEin Gradio 5 is causing some kind of bug. Try setting the Gradio version to 4.44.0 inREADME.md.If you want to use 5, changeview.launch()toview.launch(ssr_mode=False).Or, if you’re using 5.11.0, the bug may have been fixed.
2025-01-10T19:08:25Z
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.