Hi community,
I created streamlit-server-state
, through which apps can use a state object shared across the sessions on the server with an interface similar to the SessionState.
One reason why I developed this is to create chat apps.
I think chat apps are one kind of applications good for NLP methods to be used with, though they cannot be implemented upon raw Streamlit since different users (sessions) cannot communicate with each other.
With this library, sessions have access to a “server-wide” shared state object and I could actually create a simple chat app; https://share.streamlit.io/whitphx/streamlit-server-state/main/app_chat_rooms.py
- You can enter an existing room or create a new one to join.
- First you set your nick name.
- Then, you can send messages in the room.
One interesting point of this library is that once the code refers to the server-state, the session automatically starts to subscribe the state and when the state is updated within one session, all the subscribing sessions are automatically rerun.
This makes it possible for all the clients in a chat app to automatically load the messages when a new message is added.
I think for example combining sentiment analysis to chat apps will be interesting, or auto-assigning emoji to each message with DeepMoji is another application which I think will be fun… These are future work, or can anyone please do them?
Note that this library uses not public API of Streamlit, breaks the built-in session isolation mechanism to some extent and might introduce some vulnerability into the app. I recommend only to use this library for private prototypes.
In addition, the sample chat app above does not have authentication mechanism and I did not care about security. Do not share sensitive information there.