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 message

intro_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 Interface

view = gr.ChatInterface(
fn=chat,
chatbot = gr.Chatbot(avatar_images=[“guru.png”, “guru.png”], type=“messages”, value=intro_message),
type=“messages”
)

Launch the app

if name == “main”:
view.launch()

Error message shown on huggingface spaces logs below:

ReferenceError: scroll is not defined
at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:869:9
at 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:335
at 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:65
at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14424:5
at 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:48
at 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 defined
at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:869:9
at 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:335
at 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:65
at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14424:5
at 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:48
at 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 defined
at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:869:9
at 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:335
at 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:65
at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14424:5
at 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:48
at 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 defined
at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:869:9
at 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:335
at 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:65
at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14424:5
at 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:48
at 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 defined
at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/Index55-D5oefuYR.js:869:9
at 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:335
at 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:65
at file:///usr/local/lib/python3.10/site-packages/gradio/templates/node/build/server/chunks/2-CClG50To.js:14424:5
at 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:48
at 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, in

Anybody encountered this before?

1 Like

There is no error in your code. I can run your code successfully.
What’s your problem?

1 Like

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.

1 Like

I haven’t seen this error myself, but the error message does include SSR. It’s possible that the SSR_MODE in Gradio 5 is causing some kind of bug. Try setting the Gradio version to 4.44.0 in README.md.
If you want to use 5, change view.launch() to view.launch(ssr_mode=False).
Or, if you’re using 5.11.0, the bug may have been fixed.

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.