yasserrmd commited on
Commit
d59827f
·
verified ·
1 Parent(s): 70416a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -26
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 chat application helps with math problems by providing hints and guidance. "
87
- "It keeps a history of your conversation and ensures no direct answers are given."
88
  )
89
 
90
- with gr.Row():
91
- with gr.Column():
92
- user_input = gr.Textbox(
93
- label="Your Math Query",
94
- placeholder="Ask about a math problem (e.g., Solve for x: 4x + 5 = 6x + 7)",
95
- lines=2
96
- )
97
- send_button = gr.Button("Send")
98
- with gr.Column():
99
- chat_history = gr.Textbox(
100
- label="Chat History",
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=[history_state, user_input],
113
- outputs=[chat_history, history_state]
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