Spaces:
Sleeping
Sleeping
Download session.py from tbels89/Prometheus: direct link, hf CLI and curl.
- Browser
- Download file 752 Bytes
-
https://huggingface.co/spaces/tbels89/Prometheus/resolve/main/session.py
- Command line
-
hf download hf://spaces/tbels89/Prometheus/session.py
-
curl -L -o session.py https://huggingface.co/spaces/tbels89/Prometheus/resolve/main/session.py
752 Bytes
| # session.py | |
| import streamlit as st | |
| import uuid | |
| from logging_config import logger | |
| def get_session_id(): | |
| """ | |
| Generate a session ID using a UUID and store it in Streamlit's session state. | |
| Ensures user-specific chat sessions. | |
| """ | |
| if "session_id" not in st.session_state: | |
| # Log session initialization | |
| logger.info("Generating new session ID.") | |
| # Generate a new UUID and assign it to session state | |
| st.session_state["session_id"] = str(uuid.uuid4()) | |
| logger.info(f"New session ID: {st.session_state['session_id']}") | |
| else: | |
| logger.info(f"Using existing session ID: {st.session_state['session_id']}") | |
| # Return the session ID from session state | |
| return st.session_state["session_id"] |