Toya0421 commited on
Commit
6b8059c
·
verified ·
1 Parent(s): d0d7640

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -4,6 +4,7 @@ from datasets import Dataset
4
  from datetime import datetime, timedelta
5
  import pandas as pd
6
  import time, os, random, uuid, tempfile, json
 
7
 
8
  # --- API設定 ---
9
  API_KEY = os.getenv("API_KEY")
@@ -67,9 +68,14 @@ def check_answer_with_ai(text, question, user_answer):
67
  )
68
  result = response.choices[0].message.content.strip().lower()
69
 
70
- # ここ「部分一致」変更
71
- if "correct" in result:
 
 
 
72
  return True
 
 
73
  return False
74
 
75
  # --- 自動難易度調整 ---
 
4
  from datetime import datetime, timedelta
5
  import pandas as pd
6
  import time, os, random, uuid, tempfile, json
7
+ import re
8
 
9
  # --- API設定 ---
10
  API_KEY = os.getenv("API_KEY")
 
68
  )
69
  result = response.choices[0].message.content.strip().lower()
70
 
71
+ # まず "incorrect" 検出("incorrect" の中 "correct" が含まれるため先に判定する必要がある)
72
+ if re.search(r"\bincorrect\b", result):
73
+ return False
74
+ # 次に "correct" を検出
75
+ if re.search(r"\bcorrect\b", result):
76
  return True
77
+
78
+ # どちらでも判断できない場合は安全側(不正解)
79
  return False
80
 
81
  # --- 自動難易度調整 ---