FractalAIR commited on
Commit
6b29f7a
·
verified ·
1 Parent(s): 6b3a0d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -87,10 +87,10 @@ def generate_response(user_message, max_tokens, temperature, top_p, history_stat
87
  yield new_history, new_history
88
 
89
  example_messages = {
90
- "JEE Main 2025 Combinatorics": "From all the English alphabets, five letters are chosen and are arranged in alphabetical order. The total number of ways, in which the middle letter is 'M', is?",
91
- "JEE Main 2025 Coordinate Geometry": "A circle \\(C\\) of radius 2 lies in the second quadrant and touches both the coordinate axes. Let \\(r\\) be the radius of a circle that has centre at the point \\((2, 5)\\) and intersects the circle \\(C\\) at exactly two points. If the set of all possible values of \\(r\\) is the interval \\((\\alpha, \\beta)\\), then \\(3\\beta - 2\\alpha\\) is?",
92
- "JEE Main 2025 Probability & Statistics": "A coin is tossed three times. Let \(X\) denote the number of times a tail follows a head. If \\(\\mu\\) and \\(\\sigma^2\\) denote the mean and variance of \\(X\\), then the value of \\(64(\\mu + \\sigma^2)\\) is?",
93
- "JEE Main 2025 Laws of Motion": "A massless spring gets elongated by amount x_1 under a tension of 5 N . Its elongation is x_2 under the tension of 7 N . For the elongation of 5x_1 - 2x_2 , the tension in the spring will be?"
94
  }
95
 
96
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
@@ -131,10 +131,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
131
  clear_button = gr.Button("Clear", scale=1)
132
  gr.Markdown("**Try these examples:**")
133
  with gr.Row():
134
- example1_button = gr.Button("JEE Main 2025 Combinatorics")
135
- example2_button = gr.Button("JEE Main 2025 Coordinate Geometry")
136
- example3_button = gr.Button("JEE Main 2025 Probability & Statistics")
137
- example4_button = gr.Button("JEE Main 2025 Laws of Motion")
138
 
139
  def update_conversation_list():
140
  return [conversations[cid]["title"] for cid in conversations]
@@ -155,7 +155,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
155
  title = user_message.strip().split("\n")[0][:40]
156
  conversations[convo_id] = {"title": title, "messages": history}
157
  if conversations[convo_id]["title"].startswith("New Conversation"):
158
- conversations[convo_id]["title"] = user_message.strip().split("\n")[0][:40]
 
159
  for updated_history, new_history in generate_response(user_message, max_tokens, temperature, top_p, history):
160
  conversations[convo_id]["messages"] = new_history
161
  yield updated_history, new_history, gr.update(choices=update_conversation_list(), value=conversations[convo_id]["title"])
@@ -188,9 +189,9 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
188
  outputs=[current_convo_id, history_state, chatbot]
189
  )
190
 
191
- example1_button.click(fn=lambda: gr.update(value=example_messages["JEE Main 2025 Combinatorics"]), inputs=None, outputs=user_input)
192
- example2_button.click(fn=lambda: gr.update(value=example_messages["JEE Main 2025 Coordinate Geometry"]), inputs=None, outputs=user_input)
193
- example3_button.click(fn=lambda: gr.update(value=example_messages["JEE Main 2025 Probability & Statistics"]), inputs=None, outputs=user_input)
194
- example4_button.click(fn=lambda: gr.update(value=example_messages["JEE Main 2025 Laws of Motion"]), inputs=None, outputs=user_input)
195
 
196
  demo.launch(share=True, ssr_mode=False)
 
87
  yield new_history, new_history
88
 
89
  example_messages = {
90
+ "JEE Main 2025 \nCombinatorics": "From all the English alphabets, five letters are chosen and are arranged in alphabetical order. The total number of ways, in which the middle letter is 'M', is?",
91
+ "JEE Main 2025 \nCoordinate Geometry": "A circle \\(C\\) of radius 2 lies in the second quadrant and touches both the coordinate axes. Let \\(r\\) be the radius of a circle that has centre at the point \\((2, 5)\\) and intersects the circle \\(C\\) at exactly two points. If the set of all possible values of \\(r\\) is the interval \\((\\alpha, \\beta)\\), then \\(3\\beta - 2\\alpha\\) is?",
92
+ "JEE Main 2025 \nProbability & Statistics": "A coin is tossed three times. Let \(X\) denote the number of times a tail follows a head. If \\(\\mu\\) and \\(\\sigma^2\\) denote the mean and variance of \\(X\\), then the value of \\(64(\\mu + \\sigma^2)\\) is?",
93
+ "JEE Main 2025 \nLaws of Motion": "A massless spring gets elongated by amount x_1 under a tension of 5 N . Its elongation is x_2 under the tension of 7 N . For the elongation of 5x_1 - 2x_2 , the tension in the spring will be?"
94
  }
95
 
96
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
 
131
  clear_button = gr.Button("Clear", scale=1)
132
  gr.Markdown("**Try these examples:**")
133
  with gr.Row():
134
+ example1_button = gr.Button("JEE Main 2025 \nCombinatorics")
135
+ example2_button = gr.Button("JEE Main 2025 \nCoordinate Geometry")
136
+ example3_button = gr.Button("JEE Main 2025 \nProbability & Statistics")
137
+ example4_button = gr.Button("JEE Main 2025 \nLaws of Motion")
138
 
139
  def update_conversation_list():
140
  return [conversations[cid]["title"] for cid in conversations]
 
155
  title = user_message.strip().split("\n")[0][:40]
156
  conversations[convo_id] = {"title": title, "messages": history}
157
  if conversations[convo_id]["title"].startswith("New Conversation"):
158
+ #conversations[convo_id]["title"] = user_message.strip().split("\n")[0][:40]
159
+ conversations[convo_id]["title"] = " ".join(user_message.strip().split()[:5])
160
  for updated_history, new_history in generate_response(user_message, max_tokens, temperature, top_p, history):
161
  conversations[convo_id]["messages"] = new_history
162
  yield updated_history, new_history, gr.update(choices=update_conversation_list(), value=conversations[convo_id]["title"])
 
189
  outputs=[current_convo_id, history_state, chatbot]
190
  )
191
 
192
+ example1_button.click(fn=lambda: gr.update(value=example_messages["JEE Main 2025 \nCombinatorics"]), inputs=None, outputs=user_input)
193
+ example2_button.click(fn=lambda: gr.update(value=example_messages["JEE Main 2025 \nCoordinate Geometry"]), inputs=None, outputs=user_input)
194
+ example3_button.click(fn=lambda: gr.update(value=example_messages["JEE Main 2025 \nProbability & Statistics"]), inputs=None, outputs=user_input)
195
+ example4_button.click(fn=lambda: gr.update(value=example_messages["JEE Main 2025 \nLaws of Motion"]), inputs=None, outputs=user_input)
196
 
197
  demo.launch(share=True, ssr_mode=False)