Spaces:
Sleeping
Sleeping
File size: 705 Bytes
0d0a0be 0d67553 bac5169 e5fb9b7 bac5169 dffe0d6 e5fb9b7 9673a93 0d0a0be bac5169 9673a93 bac5169 9673a93 0d0a0be bac5169 0d0a0be bac5169 0d0a0be | 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 | 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() |