Spaces:
Sleeping
Sleeping
# app.py | |
import streamlit as st | |
from transformers import pipeline | |
from langdetect import detect | |
from gingerit.gingerit import GingerIt | |
# Initialize models | |
summarizer = pipeline("summarization") | |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-ur") | |
corrector = GingerIt() | |
st.set_page_config(page_title="CSS AI Assistant by Komal", layout="wide") | |
st.title("π CSS AI Assistant π΅π°") | |
st.write("Helping students with news summaries, precis, essays & more β for free!") | |
menu = st.sidebar.radio("Select Feature", [ | |
"Daily News Summary", | |
"Precis Evaluation", | |
"Essay Feedback", | |
"Saved Notes" | |
]) | |
# --- Daily News Summary --- | |
if menu == "Daily News Summary": | |
st.header("π° AI-Powered News Summarizer") | |
user_news = st.text_area("Paste or write today's news:", height=200) | |
lang = st.radio("Language", ["English", "Urdu"]) | |
if st.button("Summarize") and user_news: | |
summary = summarizer(user_news, max_length=100, min_length=30, do_sample=False)[0]['summary_text'] | |
if lang == "Urdu": | |
translation = translator(summary)[0]['translation_text'] | |
st.success("Summary in Urdu:") | |
st.write(translation) | |
else: | |
st.success("Summary in English:") | |
st.write(summary) | |
# --- Precis Evaluation --- | |
elif menu == "Precis Evaluation": | |
st.header("βοΈ Precis Evaluation Tool") | |
precis_input = st.text_area("Enter your precis for evaluation:", height=200) | |
if st.button("Evaluate Precis") and precis_input: | |
result = corrector.parse(precis_input) | |
st.success("β Corrected Precis:") | |
st.write(result['result']) | |
# --- Essay Feedback --- | |
elif menu == "Essay Feedback": | |
st.header("ποΈ Essay Evaluation Tool") | |
essay_input = st.text_area("Paste your essay here:", height=300) | |
if st.button("Evaluate Essay") and essay_input: | |
result = corrector.parse(essay_input) | |
st.success("β Suggestions:") | |
st.write(result['result']) | |
# --- Saved Notes (Stub) --- | |
elif menu == "Saved Notes": | |
st.header("πΎ Saved Notes") | |
st.info("Note saving functionality coming soon!") | |
st.write("You will be able to store and download your summaries and corrected answers here.") | |