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

Function initialize_session_state

scripts/python_ui/streamlit.py:66–110  ·  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

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