Create session_state.py
Browse files- src/session_state.py +46 -0
src/session_state.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
This module handles session state initialization and management.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
import streamlit as st
|
| 6 |
+
import uuid
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def initialize_session_state():
|
| 10 |
+
"""
|
| 11 |
+
Initialize all session state variables needed for the application.
|
| 12 |
+
"""
|
| 13 |
+
# Main conversation history
|
| 14 |
+
if 'history' not in st.session_state:
|
| 15 |
+
st.session_state.history = []
|
| 16 |
+
|
| 17 |
+
# Unique consultation ID for tracking sessions
|
| 18 |
+
if 'consultation_id' not in st.session_state:
|
| 19 |
+
st.session_state.consultation_id = str(uuid.uuid4())[:8]
|
| 20 |
+
|
| 21 |
+
# RAG feature toggle
|
| 22 |
+
if 'use_rag' not in st.session_state:
|
| 23 |
+
st.session_state.use_rag = True
|
| 24 |
+
|
| 25 |
+
# Processing state for showing typing indicator
|
| 26 |
+
if 'processing' not in st.session_state:
|
| 27 |
+
st.session_state.processing = False
|
| 28 |
+
|
| 29 |
+
# Report generation state
|
| 30 |
+
if 'show_report_form' not in st.session_state:
|
| 31 |
+
st.session_state.show_report_form = False
|
| 32 |
+
|
| 33 |
+
if 'report_step' not in st.session_state:
|
| 34 |
+
st.session_state.report_step = 0
|
| 35 |
+
|
| 36 |
+
# Patient information for reports
|
| 37 |
+
if 'patient_info' not in st.session_state:
|
| 38 |
+
st.session_state.patient_info = {"name": "", "age": "", "gender": ""}
|
| 39 |
+
|
| 40 |
+
# PDF report data
|
| 41 |
+
if 'pdf_data' not in st.session_state:
|
| 42 |
+
st.session_state.pdf_data = None
|
| 43 |
+
|
| 44 |
+
# Email form visibility
|
| 45 |
+
if 'show_email_form' not in st.session_state:
|
| 46 |
+
st.session_state.show_email_form = False
|