Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 "
|
|
|
|
|
|
|
|
|
|
| 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 |
# --- 自動難易度調整 ---
|