Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,8 +43,8 @@ MIN_AGE = 5
|
|
| 43 |
MAX_AGE = 120
|
| 44 |
SESSION_TOKEN_LENGTH = 32
|
| 45 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 46 |
-
SESSION_TIMEOUT = 3600 * 3 # 3 hour session timeout
|
| 47 |
ENCRYPTION_KEY = os.getenv("ENCRYPTION_KEY", Fernet.generate_key().decode())
|
|
|
|
| 48 |
MAX_CONTEXT_HISTORY = 10
|
| 49 |
MAX_PROFILE_LOAD_ATTEMPTS = 3
|
| 50 |
|
|
@@ -987,13 +987,13 @@ class AcademicAnalyzer:
|
|
| 987 |
total_required = sum(
|
| 988 |
float(req.get('required', 0))
|
| 989 |
for req in parsed_data.get('requirements', {}).values()
|
| 990 |
-
if req and str(req.get('required', '0')).replace('.',
|
| 991 |
)
|
| 992 |
|
| 993 |
total_completed = sum(
|
| 994 |
float(req.get('completed', 0))
|
| 995 |
for req in parsed_data.get('requirements', {}).values()
|
| 996 |
-
if req and str(req.get('completed', '0')).replace('.',
|
| 997 |
)
|
| 998 |
|
| 999 |
analysis['completion_percentage'] = (total_completed / total_required) * 100 if total_required > 0 else 0
|
|
@@ -1624,7 +1624,7 @@ class EnhancedProfileManager:
|
|
| 1624 |
"transcript": transcript, # Already sanitized during parsing
|
| 1625 |
"learning_style": learning_style,
|
| 1626 |
"favorites": favorites,
|
| 1627 |
-
"blog": self.encryptor.encrypt(sanitize_input(blog)) if blog else "",
|
| 1628 |
"study_plan": study_plan if study_plan else {},
|
| 1629 |
"session_token": self.current_session,
|
| 1630 |
"last_updated": time.time(),
|
|
@@ -2073,7 +2073,7 @@ class EnhancedTeachingAssistant:
|
|
| 2073 |
response.extend([
|
| 2074 |
"- Khan Academy (free lessons on many subjects)",
|
| 2075 |
"- Quizlet (flashcards and study tools)",
|
| 2076 |
-
"- Wolfram Alpha
|
| 2077 |
])
|
| 2078 |
|
| 2079 |
# Subject-specific resources
|
|
@@ -2935,6 +2935,7 @@ def create_enhanced_interface():
|
|
| 2935 |
gr.Markdown("## 💬 Your Personalized Learning Assistant")
|
| 2936 |
gr.Markdown("Ask me anything about studying, your courses, grades, or learning strategies.")
|
| 2937 |
|
|
|
|
| 2938 |
chatbot = gr.ChatInterface(
|
| 2939 |
fn=lambda msg, hist: teaching_assistant.generate_response(msg, hist, session_token.value),
|
| 2940 |
examples=[
|
|
@@ -2944,8 +2945,7 @@ def create_enhanced_interface():
|
|
| 2944 |
"Study tips for my learning style",
|
| 2945 |
"What colleges should I consider?"
|
| 2946 |
],
|
| 2947 |
-
title=""
|
| 2948 |
-
undo_btn=None
|
| 2949 |
)
|
| 2950 |
|
| 2951 |
# ===== TAB 6: GOALS & PLANNING =====
|
|
|
|
| 43 |
MAX_AGE = 120
|
| 44 |
SESSION_TOKEN_LENGTH = 32
|
| 45 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
|
|
|
| 46 |
ENCRYPTION_KEY = os.getenv("ENCRYPTION_KEY", Fernet.generate_key().decode())
|
| 47 |
+
SESSION_TIMEOUT = 3600 * 3 # 3 hour session timeout
|
| 48 |
MAX_CONTEXT_HISTORY = 10
|
| 49 |
MAX_PROFILE_LOAD_ATTEMPTS = 3
|
| 50 |
|
|
|
|
| 987 |
total_required = sum(
|
| 988 |
float(req.get('required', 0))
|
| 989 |
for req in parsed_data.get('requirements', {}).values()
|
| 990 |
+
if req and str(req.get('required', '0')).replace('.','').isdigit()
|
| 991 |
)
|
| 992 |
|
| 993 |
total_completed = sum(
|
| 994 |
float(req.get('completed', 0))
|
| 995 |
for req in parsed_data.get('requirements', {}).values()
|
| 996 |
+
if req and str(req.get('completed', '0')).replace('.','').isdigit()
|
| 997 |
)
|
| 998 |
|
| 999 |
analysis['completion_percentage'] = (total_completed / total_required) * 100 if total_required > 0 else 0
|
|
|
|
| 1624 |
"transcript": transcript, # Already sanitized during parsing
|
| 1625 |
"learning_style": learning_style,
|
| 1626 |
"favorites": favorites,
|
| 1627 |
+
"blog": self.encryptor.encrypt(sanitize_input(blog))) if blog else "",
|
| 1628 |
"study_plan": study_plan if study_plan else {},
|
| 1629 |
"session_token": self.current_session,
|
| 1630 |
"last_updated": time.time(),
|
|
|
|
| 2073 |
response.extend([
|
| 2074 |
"- Khan Academy (free lessons on many subjects)",
|
| 2075 |
"- Quizlet (flashcards and study tools)",
|
| 2076 |
+
"- Wolfram Alpha for math help"
|
| 2077 |
])
|
| 2078 |
|
| 2079 |
# Subject-specific resources
|
|
|
|
| 2935 |
gr.Markdown("## 💬 Your Personalized Learning Assistant")
|
| 2936 |
gr.Markdown("Ask me anything about studying, your courses, grades, or learning strategies.")
|
| 2937 |
|
| 2938 |
+
# Create chatbot interface without undo_btn
|
| 2939 |
chatbot = gr.ChatInterface(
|
| 2940 |
fn=lambda msg, hist: teaching_assistant.generate_response(msg, hist, session_token.value),
|
| 2941 |
examples=[
|
|
|
|
| 2945 |
"Study tips for my learning style",
|
| 2946 |
"What colleges should I consider?"
|
| 2947 |
],
|
| 2948 |
+
title=""
|
|
|
|
| 2949 |
)
|
| 2950 |
|
| 2951 |
# ===== TAB 6: GOALS & PLANNING =====
|