openui icon indicating copy to clipboard operation
openui copied to clipboard

Can OpenUI program pyscript in UI?

Open cosmosanalytics opened this issue 1 year ago • 6 comments

Pyscript brings python into frontend, I am wondering if OpenUI can code pyscript in UI? If yes, can you give me an example?

cosmosanalytics avatar May 04 '24 23:05 cosmosanalytics

It's able to do JavaScript if you ask it to. For pyscript to work we would need to bootstrap the interpreter like we do with tailwind. Possible but not something I'm planning on.

I'm curious, why do you want to run pyscript instead of JavaScript?

vanpelt avatar May 05 '24 09:05 vanpelt

Because pyscript completely replaces the backend. see the demos at https://pyscript.net/examples/.

JavaScript can only do frontend with node js (or python) at the backend.

If I can use pyscript in OpenUI, I would just need one static web page, everything will be run in the browser.

cosmosanalytics avatar May 05 '24 12:05 cosmosanalytics

I can use gemini ai to write pyscript in html, so LLM is capable of writing pyscript in html as well as javascript.

I am a python data scientist, using streamlit to present my analytics, being able to write pyscript in html will save me time to setup the backend.

cosmosanalytics avatar May 05 '24 13:05 cosmosanalytics

See pyscript example to do chatgpt at the frontend https://pyscript.com/@adec3dd4-c366-46d3-9d45-84d3b0996a43/07a0de9f-afd1-4975-a65d-17dfb3bf7b4e/latest

cosmosanalytics avatar May 05 '24 13:05 cosmosanalytics

here is a screenshot of gemini ai generating pyscript in html image

cosmosanalytics avatar May 05 '24 13:05 cosmosanalytics

The problem is you really don't want to put your api key into the frontend... also, there's nothing specific about Python in this project. It could all be JavaScript. I just preferred Python for the backend.

vanpelt avatar May 07 '24 18:05 vanpelt

I added an option to convert an HTML component into a Streamlit app which could be useful.

vanpelt avatar May 21 '24 00:05 vanpelt