MCPcopy Create free account
hub / github.com/danielmiessler/Fabric / initialize_session_state

Function initialize_session_state

scripts/python_ui/streamlit.py:65–109  ·  view source on GitHub ↗

Initialize necessary session state attributes. Error handling: - Ensures all required session state variables are initialized - Loads saved outputs from persistent storage - Handles missing or corrupted saved output files

()

Source from the content-addressed store, hash-verified

63
64
65def initialize_session_state():
66 """Initialize necessary session state attributes.
67
68 Error handling:
69 - Ensures all required session state variables are initialized
70 - Loads saved outputs from persistent storage
71 - Handles missing or corrupted saved output files
72 """
73 logger.info("Initializing session state")
74 default_configs = {
75 # Configuration state
76 "config_loaded": False,
77 "vendors": {},
78 "available_models": [],
79 "selected_vendor": None,
80 "selected_model": None,
81 # Pattern execution state
82 "input_content": "",
83 "selected_patterns": [],
84 "chat_output": [],
85 "current_view": "run",
86 # Pattern creation state
87 "wizard_step": "Basic Info",
88 "session_name": "",
89 "context_name": "",
90 # Model configuration
91 "config": {"vendor": "", "model": "", "context_length": "2048"},
92 # Model caching
93 "cached_models": None,
94 "last_model_fetch": 0,
95 # UI state
96 "active_tab": 0,
97 # Output management
98 "output_logs": [],
99 "starred_outputs": [],
100 "starring_output": None,
101 "temp_star_name": "",
102 }
103
104 for key, value in default_configs.items():
105 if key not in st.session_state:
106 st.session_state[key] = value
107
108 # Load saved outputs if they exist
109 load_saved_outputs()
110
111
112def parse_models_output(output: str) -> Dict[str, List[str]]:

Callers 1

mainFunction · 0.85

Calls 1

load_saved_outputsFunction · 0.85

Tested by

no test coverage detected