| import streamlit as st | |
| from mechanisms import MECHANISMS | |
| if "cache" not in st.session_state: | |
| st.session_state.cache = {} | |
| if "history" not in st.session_state: | |
| st.session_state.history = {} | |
| st.title("LLM Consistency Demo") | |
| st.markdown("Explore mechanisms to improve LLM predictability & consistency.") | |
| mode = st.radio("Choose Mechanism:", list(MECHANISMS.keys())) | |
| user_prompt = st.text_input("Enter your query:") | |
| if st.button("Ask"): | |
| if user_prompt.strip(): | |
| answer = MECHANISMS[mode](user_prompt) | |
| st.markdown("### Response:") | |
| st.write(answer) | |
| if st.button("Clear Cache"): | |
| st.session_state.cache.clear() | |
| st.success("Cache cleared!") | |
| if st.button("Clear History"): | |
| st.session_state.history.clear() | |
| st.success("History cleared!") | |