Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +21 -22
src/streamlit_app.py
CHANGED
|
@@ -5,43 +5,42 @@ import io
|
|
| 5 |
import re
|
| 6 |
|
| 7 |
# ==========================================
|
| 8 |
-
# 1.
|
| 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 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
with st.sidebar:
|
| 16 |
st.header("βοΈ Configuration")
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
demo_mode = st.
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 38 |
uploaded_file = st.file_uploader("Drop your Lending Document here (PDF, TXT, or CSV)", type=["pdf", "txt", "csv"])
|
| 39 |
|
| 40 |
# ==========================================
|
| 41 |
-
# 2.
|
| 42 |
# ==========================================
|
| 43 |
def get_simulation_assets():
|
| 44 |
-
"""Returns
|
| 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
|
| 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
|
| 111 |
|
| 112 |
-
# SCENARIO C: Live AI Extraction
|
| 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
|
| 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)"])
|