ValueFX9507 commited on
Commit
c8874d9
·
verified ·
1 Parent(s): 896713b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -20
app.py CHANGED
@@ -53,7 +53,8 @@ def format_message(content):
53
  final_content = re.sub(r"(<br>)*</details>(<br>)*", "</details>", final_content)
54
  final_content = re.sub(r"(<br>)*(<div class=[^>]+>)(<br>)*", r"\2", final_content)
55
 
56
- return final_content
 
57
 
58
  def user_input(user_message, history):
59
  if history is None:
@@ -126,26 +127,27 @@ def predict(message, chat_history, system_msg, temperature, top_p, repetition_pe
126
 
127
  # JavaScript to ensure the details tag is working properly
128
  js_script = """
129
- <script>
130
- function initDetails() {
131
- document.querySelectorAll('.think-container').forEach(detail => {
132
- // 默认关闭所有思考框
133
- detail.open = false;
134
-
135
- // 添加箭头图标交互
136
- const summary = detail.querySelector('.think-summary');
137
- summary.style.listStyle = 'disclosure-closed';
138
-
139
- detail.addEventListener('toggle', () => {
140
- summary.style.listStyle = detail.open ? 'disclosure-open' : 'disclosure-closed';
141
- });
142
  });
143
- }
144
-
145
- // 初始化及每次聊天更新后执行
146
- document.addEventListener('DOMContentLoaded', initDetails);
147
- window.addEventListener('vue:mounted', initDetails); // Gradio 的 DOM 更新事件
148
- </script>
 
149
  """
150
 
151
  with gr.Blocks(css=CSS, title="Tifa-Deepsex-COT-14B") as demo:
 
53
  final_content = re.sub(r"(<br>)*</details>(<br>)*", "</details>", final_content)
54
  final_content = re.sub(r"(<br>)*(<div class=[^>]+>)(<br>)*", r"\2", final_content)
55
 
56
+ # Return as gr.HTML to ensure proper rendering
57
+ return gr.HTML(final_content)
58
 
59
  def user_input(user_message, history):
60
  if history is None:
 
127
 
128
  # JavaScript to ensure the details tag is working properly
129
  js_script = """
130
+ <script>
131
+ function initDetails() {
132
+ const detailsElements = document.querySelectorAll('.think-container');
133
+ detailsElements.forEach((detail) => {
134
+ // 默认关闭所有思考框
135
+ detail.open = false;
136
+
137
+ // 添加箭头图标交互
138
+ const summary = detail.querySelector('.think-summary');
139
+ summary.style.listStyle = 'disclosure-closed';
140
+
141
+ detail.addEventListener('toggle', () => {
142
+ summary.style.listStyle = detail.open ? 'disclosure-open' : 'disclosure-closed';
143
  });
144
+ });
145
+ }
146
+
147
+ // 初始化及每次聊天更新后执行
148
+ document.addEventListener('DOMContentLoaded', initDetails);
149
+ window.addEventListener('vue:mounted', initDetails); // Gradio 的 DOM 更新事件
150
+ </script>
151
  """
152
 
153
  with gr.Blocks(css=CSS, title="Tifa-Deepsex-COT-14B") as demo: