HF Spaces - Gradio UI is different. Why?

I have been running a multi-agent using HF Smolagents and Gradio UI locally for a while and was so far quite happy with it.

I wanted to explore what needs to be done to run it in Spaces, so I created a Space to run it. After a few trials, i got it to run, but the UI looks completely different and UI elements are not clickable.

Both use the same gradio version (5.45.0) and are based on the correct requirements.txt. Based on the error log on the broweser its indicated that css/javascript is the issue. But I have no clue how to fix this?

What are next steps that I can use to debug it?

1 Like

Hmm… Try demo.launch(ssr_mode=False) for now. And ensure specify version in REAMDE.md.

---
sdk: gradio
sdk_version: 5.45.0
app_file: app.py
---
1 Like

If I remove server side rendering nothing is rendered.

1 Like

I’ve never seen this symptom before…
Something other than README.md, app.py, and requirements.txt might be causing trouble…

Could it be that there are resources like CSS in the repository, but they’re set to Private (resulting in a 404 error without a token), so Gradio can’t access them…?

1 Like

Thank you for your help1 It’s a standard README. But you nudged me in the right direction. The site needs to be public and can’t be private.

1 Like

While you could manually place it on a repository in a private space, I think using a public resource is simpler.

1 Like

Thank you. I think so too. I noticed that now my model loader is also not working. Going back to what I wanted to achieve is that it can be public, but then I don’t want to use my own keys so I need to get this from the user or user profile.

TL;DR the rendering problem is solve (thank you!). I need to instantiate the models differently and also need to rethink key management.

1 Like

It is recommended to use Secrets for managing API keys and similar credentials. Secrets are a type of environment variable, but they are hidden from others. Regular environment variables are completely visible to others…

1 Like

Thanks. That’s what I had already implemented. But they are tied to my account setup. Therefore, if this Space is public, I would incur the cost of people potentially using it.

1 Like

Oh. I see. In that case, you’d either use Gradio’s LoginButton or explicitly provide a field for entering the token.

1 Like

That’s exactly what I was looking for!

Thank you so much!

1 Like