Spaces:
Sleeping
Sleeping
Farhan1572
commited on
Commit
•
20529d4
1
Parent(s):
ddf5961
Upload 3 files
Browse files- .gitignore +1 -0
- app_edu.py +67 -0
- requirements.txt +2 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
utils.py
|
app_edu.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from utils import generate_tutor_output
|
3 |
+
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
with gr.Blocks() as demo:
|
9 |
+
gr.Markdown("# 🎓 Your AI Tutor by Farhan")
|
10 |
+
|
11 |
+
with gr.Row():
|
12 |
+
with gr.Column(scale=2):
|
13 |
+
subject = gr.Dropdown(
|
14 |
+
["Math", "Science", "History", "Literature", "Code", "AI"],
|
15 |
+
label="Subject",
|
16 |
+
info="Choose the subject of your lesson"
|
17 |
+
)
|
18 |
+
difficulty = gr.Radio(
|
19 |
+
["Beginner", "Intermediate", "Advanced"],
|
20 |
+
label="Difficulty Level",
|
21 |
+
info="Select your proficiency level"
|
22 |
+
)
|
23 |
+
student_input = gr.Textbox(
|
24 |
+
placeholder="Type your query here...",
|
25 |
+
label="Your Input",
|
26 |
+
info="Enter the topic you want to learn"
|
27 |
+
)
|
28 |
+
|
29 |
+
model = gr.Dropdown(
|
30 |
+
["LLAMA3 8B", "LLAMA3 70B", "Mixtral 8x7B"],
|
31 |
+
label="LLM",
|
32 |
+
info="Choose the language model"
|
33 |
+
)
|
34 |
+
|
35 |
+
|
36 |
+
submit_button = gr.Button("Generate Lesson", variant="primary")
|
37 |
+
|
38 |
+
with gr.Column(scale=3):
|
39 |
+
lesson_output = gr.Markdown(label="Lesson")
|
40 |
+
question_output = gr.Markdown(label="Comprehension Question")
|
41 |
+
feedback_output = gr.Markdown(label="Feedback")
|
42 |
+
|
43 |
+
gr.Markdown("""
|
44 |
+
### How to Use
|
45 |
+
1. Select a subject from the dropdown.
|
46 |
+
2. Choose your difficulty level.
|
47 |
+
3. Enter the topic or question you'd like to explore.
|
48 |
+
4. Click 'Generate Lesson' to receive a personalized lesson, question, and feedback.
|
49 |
+
5. Review the AI-generated content to enhance your learning.
|
50 |
+
6. Feel free to ask follow-up questions or explore new topics!
|
51 |
+
""")
|
52 |
+
|
53 |
+
def process_output(output):
|
54 |
+
try:
|
55 |
+
parsed = eval(output)
|
56 |
+
return parsed["lesson"], parsed["question"], parsed["feedback"]
|
57 |
+
except:
|
58 |
+
return "Error parsing output", "No question available", "No feedback available"
|
59 |
+
|
60 |
+
submit_button.click(
|
61 |
+
fn=lambda s, d, i,m : process_output(generate_tutor_output(s, d, i, m)),
|
62 |
+
inputs=[subject, difficulty, student_input, model],
|
63 |
+
outputs=[lesson_output, question_output, feedback_output]
|
64 |
+
)
|
65 |
+
|
66 |
+
if __name__ == "__main__":
|
67 |
+
demo.launch(server_name="0.0.0.0", server_port=7860, share = True)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
groq
|
2 |
+
gradio
|