|
import gradio as gr |
|
from utils.quiz_generator import generate_quiz |
|
from utils.chatbot import ask_ai |
|
from utils.summarizer import summarize_text, get_youtube_transcript, extract_text_from_pdf |
|
from utils.translator import translate_text |
|
from utils.plagiarism_checker import check_plagiarism |
|
from utils.weakness_analyzer import analyze_weakness |
|
from utils.engagement_predictor import predict_engagement |
|
from utils.badge import assign_badges |
|
|
|
|
|
chat_history = [] |
|
|
|
|
|
|
|
with gr.Blocks(title="π Smart LMS AI Suite") as demo: |
|
|
|
gr.Markdown("# π Smart LMS AI Suite\nYour AI-powered Learning Assistant π") |
|
|
|
with gr.Tabs(): |
|
|
|
|
|
with gr.TabItem("π§ Quiz Generator"): |
|
with gr.Row(): |
|
topic_input = gr.Textbox(label="Paste Topic Content") |
|
num_qs = gr.Slider(1, 10, value=5, label="Number of Questions") |
|
quiz_output = gr.Textbox(label="Generated Quiz") |
|
quiz_button = gr.Button("Generate Quiz") |
|
quiz_button.click(fn=generate_quiz, inputs=[topic_input, num_qs], outputs=quiz_output) |
|
|
|
|
|
with gr.TabItem("π€ AI Teaching Assistant"): |
|
with gr.Row(): |
|
question_input = gr.Textbox(label="Ask your question") |
|
chatbot_output = gr.Textbox(label="AI Answer") |
|
chat_button = gr.Button("Ask") |
|
def chat_interface(q): |
|
global chat_history |
|
response, chat_history = ask_ai(q, chat_history) |
|
return response |
|
chat_button.click(fn=chat_interface, inputs=question_input, outputs=chatbot_output) |
|
|
|
|
|
with gr.TabItem("π Summarizer"): |
|
with gr.Row(): |
|
summarizer_input = gr.Textbox(lines=4, label="Paste Text to Summarize") |
|
yt_url = gr.Textbox(label="Or Enter YouTube Video URL") |
|
pdf_input = gr.File(label="Or Upload PDF", file_types=[".pdf"]) |
|
summary_output = gr.Textbox(label="Summary") |
|
summary_button = gr.Button("Summarize") |
|
|
|
def summarize_all(text, url, pdf): |
|
if pdf: |
|
content = extract_text_from_pdf(pdf.name) |
|
elif url: |
|
content = get_youtube_transcript(url) |
|
else: |
|
content = text |
|
return summarize_text(content) |
|
|
|
summary_button.click(fn=summarize_all, inputs=[summarizer_input, yt_url, pdf_input], outputs=summary_output) |
|
|
|
|
|
with gr.TabItem("π Translator"): |
|
text_input = gr.Textbox(label="Enter English Text") |
|
lang = gr.Dropdown(choices=["te", "hi", "ta", "bn", "kn", "gu", "ur"], label="Target Language") |
|
translated = gr.Textbox(label="Translated Text") |
|
translate_button = gr.Button("Translate") |
|
translate_button.click(fn=translate_text, inputs=[text_input, lang], outputs=translated) |
|
|
|
|
|
with gr.TabItem("π΅οΈ Plagiarism Checker"): |
|
with gr.Row(): |
|
plag_input1 = gr.Textbox(label="Text 1") |
|
plag_input2 = gr.Textbox(label="Text 2") |
|
plag_output = gr.Textbox(label="Plagiarism Result") |
|
plag_btn = gr.Button("Check") |
|
plag_btn.click(fn=check_plagiarism, inputs=[plag_input1, plag_input2], outputs=plag_output) |
|
|
|
|
|
with gr.TabItem("π Weakness Analyzer"): |
|
weakness_file = gr.File(label="Upload Quiz Scores CSV") |
|
weakness_result = gr.Textbox(label="Analysis Result") |
|
weakness_btn = gr.Button("Analyze") |
|
weakness_btn.click(fn=analyze_weakness, inputs=weakness_file, outputs=weakness_result) |
|
|
|
|
|
with gr.TabItem("π Engagement Predictor"): |
|
engagement_file = gr.File(label="Upload Student Log CSV") |
|
engagement_output = gr.Textbox(label="Prediction Report") |
|
engagement_btn = gr.Button("Predict Engagement") |
|
engagement_btn.click(fn=predict_engagement, inputs=engagement_file, outputs=engagement_output) |
|
|
|
|
|
with gr.TabItem("π
Badge Generator"): |
|
badge_file = gr.File(label="Upload Performance CSV") |
|
badge_output = gr.Textbox(label="Badge Report") |
|
badge_btn = gr.Button("Generate Badges") |
|
badge_btn.click(fn=assign_badges, inputs=badge_file, outputs=badge_output) |
|
|
|
|
|
|
|
demo.launch() |
|
|