Spaces:
Running
Running
Shreeti Shrestha
commited on
Commit
·
db05947
1
Parent(s):
9f5efd9
truncate chat history to avoid overload
Browse files- pages/llm_tutor.py +18 -9
- utils/questions_dataset.py +13 -9
pages/llm_tutor.py
CHANGED
@@ -83,17 +83,26 @@ if user_input:
|
|
83 |
avatar=AI_AVATAR_ICON,
|
84 |
):
|
85 |
response_box = st.empty()
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
st.session_state.messages.append({"role": "assistant", "text": full_reply, "avatar": AI_AVATAR_ICON})
|
96 |
|
|
|
|
|
|
|
97 |
st.session_state.gemini_history = st.session_state.chat.get_history()
|
98 |
|
99 |
if next_btn:
|
|
|
83 |
avatar=AI_AVATAR_ICON,
|
84 |
):
|
85 |
response_box = st.empty()
|
86 |
+
try:
|
87 |
+
for chunk in response:
|
88 |
+
chunk_text = chunk.text
|
89 |
+
if chunk_text:
|
90 |
+
full_reply += chunk_text
|
91 |
+
time.sleep(0.05)
|
92 |
+
response_box.markdown(full_reply + "▌")
|
93 |
+
|
94 |
+
# Final display after stream ends
|
95 |
+
response_box.markdown(full_reply)
|
96 |
+
|
97 |
+
except Exception as e:
|
98 |
+
response_box.markdown(f"⚠️ Error: {e}")
|
99 |
+
full_reply = "Sorry, there was an error."
|
100 |
+
print(e)
|
101 |
st.session_state.messages.append({"role": "assistant", "text": full_reply, "avatar": AI_AVATAR_ICON})
|
102 |
|
103 |
+
if len(st.session_state.messages) > 10:
|
104 |
+
st.session_state.messages = st.session_state.messages[-10:]
|
105 |
+
|
106 |
st.session_state.gemini_history = st.session_state.chat.get_history()
|
107 |
|
108 |
if next_btn:
|
utils/questions_dataset.py
CHANGED
@@ -51,8 +51,8 @@ def get_model_tools():
|
|
51 |
tools = types.Tool(function_declarations=[get_practice_questions_function])
|
52 |
return tools
|
53 |
|
54 |
-
system_instruction = """You are an AI tutor
|
55 |
-
|
56 |
Assumtion: (%d/%d)
|
57 |
Find the flaw in the argument: (%d/%d)
|
58 |
Inferece: (%d/%d)
|
@@ -62,10 +62,14 @@ system_instruction = """You are an AI tutor that teaches users LSAT Logical Reas
|
|
62 |
Role Play: (%d/%d)
|
63 |
Strengthen: (%d/%d)
|
64 |
Weaken the argument: (%d/%d)
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
51 |
tools = types.Tool(function_declarations=[get_practice_questions_function])
|
52 |
return tools
|
53 |
|
54 |
+
system_instruction = """You are an AI tutor specialized in LSAT Logical Reasoning. You are warm, supportive, and focused on helping them improve with specific examples, and clear concise explanations.
|
55 |
+
The student has just completed a practice quiz. Here is their performance by question type, shown as (correct/total):
|
56 |
Assumtion: (%d/%d)
|
57 |
Find the flaw in the argument: (%d/%d)
|
58 |
Inferece: (%d/%d)
|
|
|
62 |
Role Play: (%d/%d)
|
63 |
Strengthen: (%d/%d)
|
64 |
Weaken the argument: (%d/%d)
|
65 |
+
Based on this performance, classify the student as Beginner, Intermediate, or Advanced. Tailor your tutoring accordingly. Follow these guidelines:
|
66 |
+
1. Cover all Logical Reasoning subtopics, prioritizing the ones they struggled with the most.
|
67 |
+
2. Ask questions to ensure that they understand the material.
|
68 |
+
3. Use practice questions from the tool whenever available. If not, use general examples aligned with each subtopic.
|
69 |
+
4. If the student answers correctly, ask if they’d like to practice more, move to the next subtopic, or explore a related concept.
|
70 |
+
5. Never respond with a single word or phrase like “Okay”, “Sure”, or “Before”.
|
71 |
+
6. Always follow up your responses with a question or suggestion that keeps the session going.
|
72 |
+
7. Be proactive and guide the student. If they say “next”, pick the next weak subtopic and begin teaching it.
|
73 |
+
8. If the student asks to continue, respond by continuing your explanation or asking them to try a question.
|
74 |
+
9. When in doubt, ask the student how they’d like to continue.
|
75 |
+
"""
|