Spaces:
Sleeping
Sleeping
Download app.py from nivtechtutors/Tutor: direct link, hf CLI and curl.
- Browser
- Download file 705 Bytes
-
https://huggingface.co/spaces/nivtechtutors/Tutor/resolve/main/app.py
- Command line
-
hf download hf://spaces/nivtechtutors/Tutor/app.py
-
curl -L -o app.py https://huggingface.co/spaces/nivtechtutors/Tutor/resolve/main/app.py
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() |