aicodingfun commited on
Commit
ab50cdb
·
verified ·
1 Parent(s): 0bb773c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -25,15 +25,17 @@ import re
25
 
26
  def remove_think_tags(content):
27
  """刪除 <think>...</think> 標籤及其內容的正規表達式解法"""
28
- pattern = r'<think>.*?</think>'
29
- cleaned_content = re.sub(pattern, '', content, flags=re.DOTALL)
30
 
31
  # # 刪除所有 <think> 標籤及其內容
32
  # cleaned_content = re.sub(r'<\s*think[^>]*>.*?<\s*/\s*think\s*>', '', content, flags=re.DOTALL)
33
  # # 清除殘留空行 (連續兩個以上換行符)
34
  # cleaned_content = re.sub(r'\n{3,}', '\n\n', cleaned_content)
 
 
35
 
36
- return cleaned_content.strip()
37
 
38
  def random_questions_with_limit(data, limit=20000):
39
  """
@@ -194,7 +196,7 @@ with gr.Blocks() as app:
194
 
195
  # 產生題目的按鈕與輸出區塊
196
  generate_button = gr.Button("🚀 Generate Questions")
197
- output = gr.Textbox("📝 Your questions will appear here!", label="📝 Your questions")
198
 
199
  # 按下按鈕後呼叫 generate_math_questions 函式並顯示結果
200
  generate_button.click(generate_math_questions, inputs=[grade, term, qtype, num_questions], outputs=output)
 
25
 
26
  def remove_think_tags(content):
27
  """刪除 <think>...</think> 標籤及其內容的正規表達式解法"""
28
+ # pattern = r'<think>.*?</think>'
29
+ # cleaned_content = re.sub(pattern, '', content, flags=re.DOTALL)
30
 
31
  # # 刪除所有 <think> 標籤及其內容
32
  # cleaned_content = re.sub(r'<\s*think[^>]*>.*?<\s*/\s*think\s*>', '', content, flags=re.DOTALL)
33
  # # 清除殘留空行 (連續兩個以上換行符)
34
  # cleaned_content = re.sub(r'\n{3,}', '\n\n', cleaned_content)
35
+ cleaned_content = content.replace('<think>', '').replace('</think>', '')
36
+ cleaned_content = cleaned_content.strip()
37
 
38
+ return cleaned_content
39
 
40
  def random_questions_with_limit(data, limit=20000):
41
  """
 
196
 
197
  # 產生題目的按鈕與輸出區塊
198
  generate_button = gr.Button("🚀 Generate Questions")
199
+ output = gr.Markdown("📝 Your questions will appear here!", label="📝 Your questions")
200
 
201
  # 按下按鈕後呼叫 generate_math_questions 函式並顯示結果
202
  generate_button.click(generate_math_questions, inputs=[grade, term, qtype, num_questions], outputs=output)