File size: 1,627 Bytes
5469939
 
 
 
 
 
 
8474e0e
5469939
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8474e0e
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
43
44
import streamlit as st
from transformers import pipeline
from langdetect import detect

# Initialize models
summarizer = pipeline("summarization")
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-ur")
grammar_corrector = pipeline("text2text-generation", model="vennify/t5-base-grammar-correction")

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:
        corrected = grammar_corrector("grammar: " + precis_input)[