Spaces:
Sleeping
Sleeping
File size: 1,230 Bytes
7dfa846 e40d075 7dfa846 e40d075 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import streamlit as st
from main import summarize_text, summarizer
st.set_page_config(page_title="TextSum AI", page_icon="π", layout="centered")
st.title("π TextSum AI")
st.caption("Paste your text below and get a concise summary.")
# Clear memory button
if st.button("ποΈ Clear Memory"):
summarizer.clear_memory()
st.session_state.chat_history = []
st.success("Memory cleared!")
# Chat history in session state
if "chat_history" not in st.session_state:
st.session_state.chat_history = []
# Display chat history
for message in st.session_state.chat_history:
with st.chat_message(message["role"]):
st.markdown(message["content"])
# Input
user_input = st.chat_input("Paste your text or ask a follow-up question...")
if user_input:
# Display user message
with st.chat_message("user"):
st.markdown(user_input)
st.session_state.chat_history.append({"role": "user", "content": user_input})
# Get summary
with st.spinner("Summarizing..."):
result = summarize_text(user_input)
# Display AI response
with st.chat_message("assistant"):
st.markdown(result)
st.session_state.chat_history.append({"role": "assistant", "content": result}) |