Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,8 +16,7 @@ tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
16 |
|
17 |
# System instruction
|
18 |
SYSTEM_INSTRUCTION = (
|
19 |
-
"You are a math tutor providing hints and guidance. "
|
20 |
-
"Do not reveal final answers. Offer step-by-step assistance only."
|
21 |
)
|
22 |
|
23 |
def apply_chat_template(messages):
|
@@ -83,34 +82,24 @@ def create_chat_interface():
|
|
83 |
with gr.Blocks() as chat_app:
|
84 |
gr.Markdown("## Math Hint Chat")
|
85 |
gr.Markdown(
|
86 |
-
"This
|
87 |
-
"It keeps a history of your conversation and ensures no direct answers are given."
|
88 |
)
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
placeholder="Chat history will appear here.",
|
102 |
-
lines=20,
|
103 |
-
interactive=False
|
104 |
-
)
|
105 |
-
|
106 |
-
# Hidden state for storing conversation history
|
107 |
-
history_state = gr.State([])
|
108 |
-
|
109 |
-
# Button interaction
|
110 |
send_button.click(
|
111 |
fn=generate_response,
|
112 |
-
inputs=[
|
113 |
-
outputs=[
|
114 |
)
|
115 |
|
116 |
return chat_app
|
|
|
16 |
|
17 |
# System instruction
|
18 |
SYSTEM_INSTRUCTION = (
|
19 |
+
"You are a helpful and patient math tutor tasked with providing step-by-step hints and guidance for solving math problems. Your primary role is to assist learners in understanding how to approach and solve problems without revealing the final answer, even if explicitly requested. Always encourage the learner to solve the problem themselves by offering incremental hints and explanations. Under no circumstances should you provide the complete solution or final answer."
|
|
|
20 |
)
|
21 |
|
22 |
def apply_chat_template(messages):
|
|
|
82 |
with gr.Blocks() as chat_app:
|
83 |
gr.Markdown("## Math Hint Chat")
|
84 |
gr.Markdown(
|
85 |
+
"This chatbot provides hints and step-by-step guidance for solving math problems. "
|
|
|
86 |
)
|
87 |
|
88 |
+
chatbot = gr.Chatbot(label="Math Tutor Chat")
|
89 |
+
user_input = gr.Textbox(
|
90 |
+
placeholder="Ask your math question here (e.g., guide me to solve x: 4x + 5 = 6x + 7)",
|
91 |
+
label="Your Query"
|
92 |
+
)
|
93 |
+
send_button = gr.Button("Send")
|
94 |
+
|
95 |
+
# Hidden state to manage chat history
|
96 |
+
chat_history = gr.State([])
|
97 |
+
|
98 |
+
# Button interaction for chat
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
send_button.click(
|
100 |
fn=generate_response,
|
101 |
+
inputs=[chat_history, user_input],
|
102 |
+
outputs=[chatbot, chat_history]
|
103 |
)
|
104 |
|
105 |
return chat_app
|