From 446e9c6d1f2ea0da44d5ba057192d0ae452e4791 Mon Sep 17 00:00:00 2001 From: Jeremy Landers Date: Fri, 18 Jul 2025 16:48:05 -0400 Subject: [PATCH] Refactor Streamlit UI for mobile --- streamlit_app.py | 100 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 31 deletions(-) diff --git a/streamlit_app.py b/streamlit_app.py index 856bf70..198cfe4 100644 --- a/streamlit_app.py +++ b/streamlit_app.py @@ -10,6 +10,28 @@ st.set_page_config(page_title="Sareth | Recursive Reflection", layout="wide") +st.markdown(''' + +''', unsafe_allow_html=True) + client = openai.Client(api_key=st.secrets["openai"]["api_key"]) # Initialize session state @@ -134,33 +156,49 @@ def process_reflection(): st.markdown(f"**๐Ÿ”ฃ Glyph ID:** `{glyph}`") st.markdown(f"**โ›” Halt Reason:** `{halt_reason}`") -st.text_input("Your reflection:", key="user_input", on_change=process_reflection) -st.button("Reflect with Sareth", on_click=process_reflection) -st.button("๐Ÿ”„ Reset Conversation", on_click=reset_conversation) - -st.subheader("๐Ÿ“œ Conversation History") -display_history = [m for m in st.session_state.conversation if st.session_state.search_query.lower() in m[1].lower()] if st.session_state.search_query else st.session_state.conversation -for speaker, text in reversed(display_history): - st.markdown(f"**{speaker}:** {text}") - -st.text_input("Search conversation:", key="search_query") - -st.subheader("๐Ÿงฟ Last Symbolic Marker") -st.markdown(f"**{st.session_state.glyph_trace[-1]}**" if st.session_state.glyph_trace else "_None yet_") - -st.subheader("๐Ÿ’Ž Truth Core") -st.markdown(f"**Current Truth Core:** {compute_truth_core()}") - -st.subheader("๐Ÿ“Š Glyph Frequency Summary") -for glyph, count in Counter(st.session_state.glyph_trace).items(): - st.markdown(f"**{glyph}**: {count} times") - -with st.expander("๐Ÿ“œ Glyph Meaning Glossary"): - for code, (symbol, meaning) in GLYPH_MAP.items(): - st.markdown(f"**{symbol}**: {meaning}") - -with st.expander("โ” About Sareth & REF"): - st.markdown(""" +st.markdown("---") + +tab1, tab2, tab3 = st.tabs(["Reflect", "Conversation History", "Insights"]) + +with tab1: + st.text_area("Your reflection:", key="user_input", height=150) + st.button("Reflect with Sareth", on_click=process_reflection) + if st.button("Generate Reflection Prompt"): + st.session_state.user_input = random.choice(reflection_prompts) + st.experimental_rerun() + st.button("๐Ÿ”„ Reset Conversation", on_click=reset_conversation) + +with tab2: + st.write("") + st.markdown("---") + display_history = [m for m in st.session_state.conversation if st.session_state.search_query.lower() in m[1].lower()] if st.session_state.search_query else st.session_state.conversation + for speaker, text in reversed(display_history): + with st.expander(f"{speaker}"): + st.markdown(text) + st.text_input("Search conversation:", key="search_query") + +with tab3: + st.write("") + st.markdown("---") + st.subheader("๐Ÿงฟ Last Symbolic Marker") + st.markdown(f"**{st.session_state.glyph_trace[-1]}**" if st.session_state.glyph_trace else "_None yet_") + + st.markdown("---") + st.subheader("๐Ÿ’Ž Truth Core") + st.markdown(f"**Current Truth Core:** {compute_truth_core()}") + + st.markdown("---") + st.subheader("๐Ÿ“Š Glyph Frequency Summary") + for glyph, count in Counter(st.session_state.glyph_trace).items(): + st.markdown(f"**{glyph}**: {count} times") + + st.markdown("---") + with st.expander("๐Ÿ“œ Glyph Meaning Glossary"): + for code, (symbol, meaning) in GLYPH_MAP.items(): + st.markdown(f"**{symbol}**: {meaning}") + + with st.expander("โ” About Sareth & REF"): + st.markdown(""" Sareth is your recursive reflection guide, combining AI with symbolic interpretation. Each reflection surfaces a symbolic marker, tracing your cognitive journey โ€” but only when your insights are deep enough. @@ -169,8 +207,8 @@ def process_reflection(): - **Truth Core:** The dominant theme of your session. """) -with st.expander("๐Ÿงช Run Sareth Diagnostic"): - if st.button("Run Diagnostic"): - result = run_sareth_test() - st.success(f"Sareth Diagnostic Result: {result}") + with st.expander("๐Ÿงช Run Sareth Diagnostic"): + if st.button("Run Diagnostic"): + result = run_sareth_test() + st.success(f"Sareth Diagnostic Result: {result}")