nanova commited on
Commit
942e73f
·
1 Parent(s): bcf0f93

update format

Browse files
Files changed (1) hide show
  1. app.py +24 -4
app.py CHANGED
@@ -69,29 +69,37 @@ def respond(
69
 
70
  if len(current_response) > 16:
71
  if '<think>' in current_response:
72
- current_response = current_response.replace('<think>', '???+ Thinking\n```')
73
  if '</think>' in current_response:
74
- current_response = current_response.replace('</think>', '```')
75
  if '**Final Answer**' in current_response:
76
  current_response = current_response.replace('**Final Answer**', '')
77
 
78
  formatted_response = current_response[:-16]
79
 
80
  formatted_response = formatted_response.replace('<', '&lt;').replace('>', '&gt;')
 
 
 
 
81
  formatted_response = formatted_response.replace('*', '\\*')
82
  yield formatted_response
83
  except json.JSONDecodeError:
84
  continue
85
  if current_response:
86
  if '<think>' in current_response:
87
- current_response = current_response.replace('<think>', '???+ Thinking\n```')
88
  if '</think>' in current_response:
89
- current_response = current_response.replace('</think>', '```')
90
  if '**Final Answer**' in current_response:
91
  current_response = current_response.replace('**Final Answer**', '')
92
 
93
  formatted_response = current_response
94
  formatted_response = formatted_response.replace('<', '&lt;').replace('>', '&gt;')
 
 
 
 
95
  formatted_response = formatted_response.replace('*', '\\*')
96
  yield formatted_response
97
  else:
@@ -139,6 +147,18 @@ demo = gr.ChatInterface(
139
  overflow-wrap: break-word !important;
140
  max-width: 100% !important;
141
  }
 
 
 
 
 
 
 
 
 
 
 
 
142
  """
143
  )
144
 
 
69
 
70
  if len(current_response) > 16:
71
  if '<think>' in current_response:
72
+ current_response = current_response.replace('<think>', '<details open><summary>思考过程</summary>\n\n```')
73
  if '</think>' in current_response:
74
+ current_response = current_response.replace('</think>', '```\n\n</details>')
75
  if '**Final Answer**' in current_response:
76
  current_response = current_response.replace('**Final Answer**', '')
77
 
78
  formatted_response = current_response[:-16]
79
 
80
  formatted_response = formatted_response.replace('<', '&lt;').replace('>', '&gt;')
81
+ formatted_response = formatted_response.replace('&lt;details open&gt;', '<details open>')
82
+ formatted_response = formatted_response.replace('&lt;/details&gt;', '</details>')
83
+ formatted_response = formatted_response.replace('&lt;summary&gt;', '<summary>')
84
+ formatted_response = formatted_response.replace('&lt;/summary&gt;', '</summary>')
85
  formatted_response = formatted_response.replace('*', '\\*')
86
  yield formatted_response
87
  except json.JSONDecodeError:
88
  continue
89
  if current_response:
90
  if '<think>' in current_response:
91
+ current_response = current_response.replace('<think>', '<details open><summary>思考过程</summary>\n\n```')
92
  if '</think>' in current_response:
93
+ current_response = current_response.replace('</think>', '```\n\n</details>')
94
  if '**Final Answer**' in current_response:
95
  current_response = current_response.replace('**Final Answer**', '')
96
 
97
  formatted_response = current_response
98
  formatted_response = formatted_response.replace('<', '&lt;').replace('>', '&gt;')
99
+ formatted_response = formatted_response.replace('&lt;details open&gt;', '<details open>')
100
+ formatted_response = formatted_response.replace('&lt;/details&gt;', '</details>')
101
+ formatted_response = formatted_response.replace('&lt;summary&gt;', '<summary>')
102
+ formatted_response = formatted_response.replace('&lt;/summary&gt;', '</summary>')
103
  formatted_response = formatted_response.replace('*', '\\*')
104
  yield formatted_response
105
  else:
 
147
  overflow-wrap: break-word !important;
148
  max-width: 100% !important;
149
  }
150
+ .accordion {
151
+ margin: 0 !important;
152
+ border: none !important;
153
+ }
154
+ .accordion-header {
155
+ background: #f0f0f0 !important;
156
+ padding: 8px !important;
157
+ cursor: pointer !important;
158
+ }
159
+ .accordion-content {
160
+ padding: 8px !important;
161
+ }
162
  """
163
  )
164