rivapereira123 commited on
Commit
c6b4d5a
Β·
verified Β·
1 Parent(s): 40e915d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -64
app.py CHANGED
@@ -93,68 +93,7 @@ def recall_from_memory(user_id, goal):
93
 
94
  return f"""### πŸ” Recalled Plan for {goal}
95
 
96
- import textwrap
97
-
98
- def generate_smart_plan(user_id, start_date_str, goal):
99
- import datetime
100
- import difflib
101
- import re
102
-
103
- start_date = datetime.datetime.strptime(start_date_str, "%Y-%m-%d").date()
104
-
105
- if not user_id:
106
- return "❌ Please enter a nickname in the Welcome tab.", "", "πŸ“… Week 1"
107
-
108
- user_key = user_id.strip().lower()
109
- goal_key = goal.lower().strip()
110
-
111
- if goal_key not in course_suggestions:
112
- close_matches = difflib.get_close_matches(goal_key, course_suggestions.keys(), n=1, cutoff=0.6)
113
- if close_matches:
114
- goal_key = close_matches[0]
115
-
116
- plan_markdown = f"""### Plan for {goal}
117
-
118
- {diagram}
119
-
120
- {summary}{course_section}
121
-
122
- _Source: See planner source_"""
123
-
124
- plan_source = "Loaded from memory"
125
- save_to_memory(user_id, goal, summary, steps, courses)
126
-
127
- # 2️⃣ Try Tavilly fallback
128
- if not steps:
129
- try:
130
- print("πŸ§ͺ Trying Tavilly fallback for:", goal_key)
131
- result = call_tavilly_rag(user_id, goal_key)
132
- print("βœ… Tavilly returned something:", result)
133
- tav_plan = re.sub(r'(Create a weekly roadmap.*?)\1+', r'\1', result[0], flags=re.DOTALL)
134
- tav_steps = [smart_label_converter(s) for s in result[2] if isinstance(s, str) and len(s.strip()) > 1]
135
- if tav_steps:
136
- steps = tav_steps
137
- diagram = render_text_roadmap(goal, steps)
138
- summary = summarizer(f"Create a weekly roadmap for {goal}.", max_new_tokens=300, do_sample=False)[0]["generated_text"]
139
- courses = get_courses_for_goal(goal_key)
140
- course_section = "\n\n### πŸ“š Recommended Courses\n" + "\n".join([f"- [{name}]({url})" for name, url in courses]) if courses else ""
141
- plan_markdown = f"""### Plan for {goal}
142
-
143
- {diagram}
144
-
145
- {summary}{course_section}
146
-
147
- _Source: See planner source_"""
148
- plan_source = "Loaded from memory"
149
-
150
- for step in steps:
151
- if isinstance(step, str) and len(step.strip()) > 1:
152
- add_task(user_id, task=step, duration=2, difficulty="Moderate", tag=None, source="career")
153
-
154
- print("βœ… Returning", len(steps), "steps for goal:", goal)
155
- return plan_markdown, gr.update(choices=steps, value=[]), "πŸ“… Week 1"
156
-
157
-
158
 
159
  with gr.Blocks(theme="NoCrypt/[email protected]",css="theme.css") as app:
160
  user_id_state = gr.State()
@@ -374,5 +313,3 @@ with gr.Blocks(theme="NoCrypt/[email protected]",css="theme.css") as app:
374
 
375
  app.launch(debug=True)
376
 
377
-
378
- """
 
93
 
94
  return f"""### πŸ” Recalled Plan for {goal}
95
 
96
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
  with gr.Blocks(theme="NoCrypt/[email protected]",css="theme.css") as app:
99
  user_id_state = gr.State()
 
313
 
314
  app.launch(debug=True)
315