atulsharma42 commited on
Commit
f7ed533
Β·
verified Β·
1 Parent(s): f2f12c3

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +21 -22
src/streamlit_app.py CHANGED
@@ -5,43 +5,42 @@ import io
5
  import re
6
 
7
  # ==========================================
8
- # 1. UI CONFIGURATION & SECURE SETUP
9
  # ==========================================
10
  st.set_page_config(page_title="CX Architect Auto-Mapper", layout="wide", page_icon="πŸ—οΈ")
11
  st.title("πŸ—οΈ CX Architect: Omni-Channel Generator")
12
  st.markdown("Upload your PRD, VOC data, or an existing spreadsheet. The AI engine will instantly map the customer journey and generate a structured VA Design Sheet.")
13
 
14
- # Sidebar Configuration Panel
 
 
 
 
15
  with st.sidebar:
16
  st.header("βš™οΈ Configuration")
17
 
18
- # 1. Toggle for Demo Simulation Mode
19
- demo_mode = st.toggle("πŸš€ Activate Demo Simulation Mode", value=False, help="Turn this ON if your Google API Key is unavailable or restricted.")
20
-
21
- # 2. Key Input - ALWAYS evaluated so it NEVER throws a NameError, but disabled if Demo Mode is active
22
- api_key = st.text_input(
23
- "Enter Gemini API Key",
24
- type="password",
25
- disabled=demo_mode,
26
- placeholder="Paste your AIza... key here"
27
- )
28
 
29
- if demo_mode:
 
 
 
 
 
30
  st.success("🟒 Simulation Mode Active (No Key Required)")
31
- elif api_key.startswith("AQ."):
32
- st.warning("⚠️ Restricted 'AQ.' token detected. If it fails, switch to Demo Simulation Mode.")
33
 
34
  st.markdown("---")
35
  st.markdown("**Framework: LAMF Process Automation Engine**")
36
 
37
- # Multi-Format File Selection Box
38
  uploaded_file = st.file_uploader("Drop your Lending Document here (PDF, TXT, or CSV)", type=["pdf", "txt", "csv"])
39
 
40
  # ==========================================
41
- # 2. DATA PROCESSING & SIMULATION LAYOUTS
42
  # ==========================================
43
  def get_simulation_assets():
44
- """Returns high-fidelity layout data modeled directly from real lending datasets"""
45
  flow_text = (
46
  "πŸ“ MILESTONE 1: USER_AUTHENTICATION\n"
47
  " - Happy Path: Identity verified instantly via core onboarding APIs.\n"
@@ -103,13 +102,13 @@ if st.button("πŸš€ Generate Design Sheets & Flow"):
103
  if demo_mode:
104
  flow_output, dataframe_output = get_simulation_assets()
105
 
106
- # SCENARIO B: Native Parsing for existing CSV files
107
  elif uploaded_file.name.endswith('.csv'):
108
  raw_df = pd.read_csv(io.BytesIO(uploaded_file.getvalue()), errors='ignore')
109
  dataframe_output = raw_df
110
- flow_output = f"πŸ“‹ Native Document File Detected: '{uploaded_file.name}'\nSuccessfully loaded {len(raw_df)} rows directly into the matrix view."
111
 
112
- # SCENARIO C: Live AI Extraction Mode
113
  else:
114
  doc_text = safe_read_file(uploaded_file)
115
  genai.configure(api_key=api_key)
@@ -152,7 +151,7 @@ if st.button("πŸš€ Generate Design Sheets & Flow"):
152
  dataframe_output = pd.DataFrame(clean_rows, columns=headers)
153
 
154
  # ==========================================
155
- # 4. RENDER OUTPUT INTERFACE
156
  # ==========================================
157
  st.success("🎯 Assets Computed Successfully!")
158
  tab1, tab2 = st.tabs(["πŸ—ΊοΈ Visual Journey Path", "πŸ“Š VA Design Sheet (Excel)"])
 
5
  import re
6
 
7
  # ==========================================
8
+ # 1. BASE INITIALIZATION & GLOBAL SCOPE
9
  # ==========================================
10
  st.set_page_config(page_title="CX Architect Auto-Mapper", layout="wide", page_icon="πŸ—οΈ")
11
  st.title("πŸ—οΈ CX Architect: Omni-Channel Generator")
12
  st.markdown("Upload your PRD, VOC data, or an existing spreadsheet. The AI engine will instantly map the customer journey and generate a structured VA Design Sheet.")
13
 
14
+ # Explicitly initialize variables at the top to protect against older engine versions
15
+ api_key = ""
16
+ demo_mode = False
17
+
18
+ # Sidebar Configuration Panel (Hyper-compatible Layout)
19
  with st.sidebar:
20
  st.header("βš™οΈ Configuration")
21
 
22
+ # Switched from st.toggle to st.checkbox for 100% version compatibility
23
+ demo_mode = st.checkbox("πŸš€ Activate Demo Simulation Mode", value=False)
 
 
 
 
 
 
 
 
24
 
25
+ # Render key input based on the chosen mode
26
+ if not demo_mode:
27
+ api_key = st.text_input("Enter Gemini API Key", type="password", placeholder="Paste your AIza... key here")
28
+ if api_key and api_key.startswith("AQ."):
29
+ st.warning("⚠️ Restricted token format detected. Switch to Demo Simulation Mode if it blocks.")
30
+ else:
31
  st.success("🟒 Simulation Mode Active (No Key Required)")
 
 
32
 
33
  st.markdown("---")
34
  st.markdown("**Framework: LAMF Process Automation Engine**")
35
 
36
+ # Multi-Format File Upload Area
37
  uploaded_file = st.file_uploader("Drop your Lending Document here (PDF, TXT, or CSV)", type=["pdf", "txt", "csv"])
38
 
39
  # ==========================================
40
+ # 2. FAIL-SAFE SIMULATION STORAGE
41
  # ==========================================
42
  def get_simulation_assets():
43
+ """Returns perfect layout data matrices modeled directly from real lending datasets"""
44
  flow_text = (
45
  "πŸ“ MILESTONE 1: USER_AUTHENTICATION\n"
46
  " - Happy Path: Identity verified instantly via core onboarding APIs.\n"
 
102
  if demo_mode:
103
  flow_output, dataframe_output = get_simulation_assets()
104
 
105
+ # SCENARIO B: Native Parsing for existing CSV design matrices
106
  elif uploaded_file.name.endswith('.csv'):
107
  raw_df = pd.read_csv(io.BytesIO(uploaded_file.getvalue()), errors='ignore')
108
  dataframe_output = raw_df
109
+ flow_output = f"πŸ“‹ Native Document File Detected: '{uploaded_file.name}'\nSuccessfully loaded {len(raw_df)} configuration layout rows directly into the dashboard matrix."
110
 
111
+ # SCENARIO C: Live AI Extraction Core
112
  else:
113
  doc_text = safe_read_file(uploaded_file)
114
  genai.configure(api_key=api_key)
 
151
  dataframe_output = pd.DataFrame(clean_rows, columns=headers)
152
 
153
  # ==========================================
154
+ # 4. RENDER INTERACTIVE PRESENTATION TABS
155
  # ==========================================
156
  st.success("🎯 Assets Computed Successfully!")
157
  tab1, tab2 = st.tabs(["πŸ—ΊοΈ Visual Journey Path", "πŸ“Š VA Design Sheet (Excel)"])