Update src/streamlit_app.py
Browse files- src/streamlit_app.py +19 -1
src/streamlit_app.py
CHANGED
|
@@ -45,6 +45,24 @@ MODEL = "deepseek-ai/DeepSeek-R1-0528"
|
|
| 45 |
SUBJECT = "Precalculus"
|
| 46 |
WORD_LIMIT = 180
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
class ConfigManager:
|
| 49 |
def __init__(self):
|
| 50 |
self.hf_token = os.getenv("HF_TOKEN")
|
|
@@ -726,7 +744,7 @@ def main():
|
|
| 726 |
border-radius: 8px;
|
| 727 |
transition: all 0.3s ease;
|
| 728 |
border: none;
|
| 729 |
-
font-weight: 500
|
| 730 |
}
|
| 731 |
|
| 732 |
.stButton > button:hover {
|
|
|
|
| 45 |
SUBJECT = "Precalculus"
|
| 46 |
WORD_LIMIT = 180
|
| 47 |
|
| 48 |
+
def _load_questions_json(path: str):
|
| 49 |
+
try:
|
| 50 |
+
with open(path, "r", encoding="utf-8") as f:
|
| 51 |
+
data = json.load(f)
|
| 52 |
+
subj = data.get("Subject")
|
| 53 |
+
qs = data.get("Questions")
|
| 54 |
+
if isinstance(subj, str) and isinstance(qs, list) and len(qs) > 0 and all(isinstance(x, str) for x in qs):
|
| 55 |
+
return subj, qs
|
| 56 |
+
except Exception as e:
|
| 57 |
+
logger.error(f"Error loading questions JSON: {e}")
|
| 58 |
+
return None, None
|
| 59 |
+
|
| 60 |
+
QUESTIONS_JSON_PATH = os.getenv("QUESTIONS_JSON", "src/questions.json")
|
| 61 |
+
_loaded_subject, _loaded_questions = _load_questions_json(QUESTIONS_JSON_PATH)
|
| 62 |
+
if _loaded_subject and _loaded_questions:
|
| 63 |
+
SUBJECT = _loaded_subject
|
| 64 |
+
DEFAULT_QUESTIONS = _loaded_questions
|
| 65 |
+
|
| 66 |
class ConfigManager:
|
| 67 |
def __init__(self):
|
| 68 |
self.hf_token = os.getenv("HF_TOKEN")
|
|
|
|
| 744 |
border-radius: 8px;
|
| 745 |
transition: all 0.3s ease;
|
| 746 |
border: none;
|
| 747 |
+
font-weight: 500.
|
| 748 |
}
|
| 749 |
|
| 750 |
.stButton > button:hover {
|