Tutor / app.py
nivtechtutors's picture
Update app.py
dffe0d6 verified
Raw History Blame Contribute Delete
705 Bytes
import gradio as gr
from transformers import pipeline
# Use supported task
teacher = pipeline(
"text-generation",
model="google/flan-t5-base"
)
def teacher_ai(user_input):
prompt = (
"You are a helpful teacher. "
"Explain simply and clearly.\n\n"
f"Student question: {user_input}\n"
"Answer:"
)
result = teacher(
prompt,
max_new_tokens=120,
do_sample=True,
temperature=0.7
)
return result[0]["generated_text"]
demo = gr.Interface(
fn=teacher_ai,
inputs=gr.Textbox(placeholder="Ask anything (math, science, coding...)"),
outputs="text",
title="NivTech AI Teacher (Fixed Mode)"
)
demo.launch()