Oysiyl commited on
Commit
add68a2
·
verified ·
1 Parent(s): ef83945

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -88,6 +88,7 @@ def respond(
88
  # Tags
89
  start_tag = "<start_working_out>"
90
  sol_start = "<SOLUTION>"
 
91
 
92
  thinking = ""
93
  final_answer = ""
@@ -105,7 +106,12 @@ def respond(
105
  # Extract "Final answer" section: everything after <SOLUTION>
106
  if sol_start in output:
107
  sol_start_idx = output.find(sol_start) + len(sol_start)
108
- final_answer = output[sol_start_idx:].strip()
 
 
 
 
 
109
 
110
  # Build formatted output
111
  formatted_output = ""
@@ -120,6 +126,10 @@ def respond(
120
 
121
  yield formatted_output
122
 
 
 
 
 
123
 
124
  """
125
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
 
88
  # Tags
89
  start_tag = "<start_working_out>"
90
  sol_start = "<SOLUTION>"
91
+ sol_end = "</SOLUTION>"
92
 
93
  thinking = ""
94
  final_answer = ""
 
106
  # Extract "Final answer" section: everything after <SOLUTION>
107
  if sol_start in output:
108
  sol_start_idx = output.find(sol_start) + len(sol_start)
109
+ # If </SOLUTION> is present, stop at it
110
+ if sol_end in output:
111
+ sol_end_idx = output.find(sol_end)
112
+ final_answer = output[sol_start_idx:sol_end_idx].strip()
113
+ else:
114
+ final_answer = output[sol_start_idx:].strip()
115
 
116
  # Build formatted output
117
  formatted_output = ""
 
126
 
127
  yield formatted_output
128
 
129
+ # If </SOLUTION> is found, end the response
130
+ if sol_end in output:
131
+ break
132
+
133
 
134
  """
135
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface