Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2934,18 +2934,18 @@ def create_enhanced_interface():
|
|
2934 |
gr.Markdown("## π¬ Your Personalized Learning Assistant")
|
2935 |
gr.Markdown("Ask me anything about studying, your courses, grades, or learning strategies.")
|
2936 |
|
2937 |
-
# Create chatbot interface
|
2938 |
-
chatbot = gr.
|
2939 |
-
|
2940 |
-
|
2941 |
-
|
2942 |
-
|
2943 |
-
|
2944 |
-
|
2945 |
-
|
2946 |
-
|
2947 |
-
|
2948 |
-
)
|
2949 |
|
2950 |
# ===== TAB 6: GOALS & PLANNING =====
|
2951 |
with gr.Tab("Goals & Planning", id=5):
|
@@ -2959,12 +2959,12 @@ def create_enhanced_interface():
|
|
2959 |
value="GPA Improvement"
|
2960 |
)
|
2961 |
goal_description = gr.Textbox(label="Goal Description")
|
2962 |
-
goal_target_date = gr.
|
2963 |
goal_target_value = gr.Number(label="Target Value (if applicable)", visible=False)
|
2964 |
add_goal_btn = gr.Button("Add Goal", variant="primary")
|
2965 |
|
2966 |
gr.Markdown("### π
Study Calendar")
|
2967 |
-
calendar_start_date = gr.
|
2968 |
generate_calendar_btn = gr.Button("Generate Study Calendar")
|
2969 |
|
2970 |
with gr.Column(scale=2):
|
@@ -3011,7 +3011,15 @@ def create_enhanced_interface():
|
|
3011 |
gr.update(visible=goal_tracker.create_goal_visualization(goals) is not None)
|
3012 |
)
|
3013 |
|
3014 |
-
def update_calendar_display(profile_name,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3015 |
profile = profile_manager.load_profile(profile_name, session_token.value)
|
3016 |
if not profile:
|
3017 |
return (
|
@@ -3068,7 +3076,7 @@ def create_enhanced_interface():
|
|
3068 |
# Add goal functionality
|
3069 |
add_goal_btn.click(
|
3070 |
fn=lambda gt, desc, date, val: (
|
3071 |
-
goal_tracker.add_goal(name.value, gt, desc, date
|
3072 |
update_goals_display(name.value)
|
3073 |
),
|
3074 |
inputs=[goal_type, goal_description, goal_target_date, goal_target_value],
|
@@ -3085,9 +3093,7 @@ def create_enhanced_interface():
|
|
3085 |
|
3086 |
# Generate calendar functionality
|
3087 |
generate_calendar_btn.click(
|
3088 |
-
fn=lambda date: (
|
3089 |
-
update_calendar_display(name.value, date)
|
3090 |
-
),
|
3091 |
inputs=calendar_start_date,
|
3092 |
outputs=[calendar_output, calendar_viz]
|
3093 |
)
|
@@ -3164,5 +3170,4 @@ app = create_enhanced_interface()
|
|
3164 |
|
3165 |
if __name__ == "__main__":
|
3166 |
app.launch(server_name="0.0.0.0", server_port=7860)
|
3167 |
-
|
3168 |
|
|
|
2934 |
gr.Markdown("## π¬ Your Personalized Learning Assistant")
|
2935 |
gr.Markdown("Ask me anything about studying, your courses, grades, or learning strategies.")
|
2936 |
|
2937 |
+
# Create custom chatbot interface
|
2938 |
+
chatbot = gr.Chatbot(height=500)
|
2939 |
+
msg = gr.Textbox(label="Your Message")
|
2940 |
+
clear = gr.Button("Clear")
|
2941 |
+
|
2942 |
+
def respond(message, chat_history):
|
2943 |
+
bot_message = teaching_assistant.generate_response(message, chat_history, session_token.value)
|
2944 |
+
chat_history.append((message, bot_message))
|
2945 |
+
return "", chat_history
|
2946 |
+
|
2947 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
2948 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
2949 |
|
2950 |
# ===== TAB 6: GOALS & PLANNING =====
|
2951 |
with gr.Tab("Goals & Planning", id=5):
|
|
|
2959 |
value="GPA Improvement"
|
2960 |
)
|
2961 |
goal_description = gr.Textbox(label="Goal Description")
|
2962 |
+
goal_target_date = gr.Textbox(label="Target Date (YYYY-MM-DD)", placeholder="2025-12-31")
|
2963 |
goal_target_value = gr.Number(label="Target Value (if applicable)", visible=False)
|
2964 |
add_goal_btn = gr.Button("Add Goal", variant="primary")
|
2965 |
|
2966 |
gr.Markdown("### π
Study Calendar")
|
2967 |
+
calendar_start_date = gr.Textbox(label="Calendar Start Date (YYYY-MM-DD)", value=datetime.date.today().isoformat())
|
2968 |
generate_calendar_btn = gr.Button("Generate Study Calendar")
|
2969 |
|
2970 |
with gr.Column(scale=2):
|
|
|
3011 |
gr.update(visible=goal_tracker.create_goal_visualization(goals) is not None)
|
3012 |
)
|
3013 |
|
3014 |
+
def update_calendar_display(profile_name, start_date_str):
|
3015 |
+
try:
|
3016 |
+
start_date = datetime.date.fromisoformat(start_date_str)
|
3017 |
+
except ValueError:
|
3018 |
+
return (
|
3019 |
+
"<div class='error-message'>Invalid date format. Please use YYYY-MM-DD</div>",
|
3020 |
+
gr.update(visible=False)
|
3021 |
+
)
|
3022 |
+
|
3023 |
profile = profile_manager.load_profile(profile_name, session_token.value)
|
3024 |
if not profile:
|
3025 |
return (
|
|
|
3076 |
# Add goal functionality
|
3077 |
add_goal_btn.click(
|
3078 |
fn=lambda gt, desc, date, val: (
|
3079 |
+
goal_tracker.add_goal(name.value, gt, desc, date, val),
|
3080 |
update_goals_display(name.value)
|
3081 |
),
|
3082 |
inputs=[goal_type, goal_description, goal_target_date, goal_target_value],
|
|
|
3093 |
|
3094 |
# Generate calendar functionality
|
3095 |
generate_calendar_btn.click(
|
3096 |
+
fn=lambda date: update_calendar_display(name.value, date),
|
|
|
|
|
3097 |
inputs=calendar_start_date,
|
3098 |
outputs=[calendar_output, calendar_viz]
|
3099 |
)
|
|
|
3170 |
|
3171 |
if __name__ == "__main__":
|
3172 |
app.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
3173 |
|