rivapereira123 commited on
Commit
8cc4721
Β·
verified Β·
1 Parent(s): c6b4d5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -69
app.py CHANGED
@@ -93,9 +93,11 @@ def recall_from_memory(user_id, goal):
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()
100
  roadmap_unlock = RoadmapUnlockManager()
101
  start_date = gr.Textbox(label="πŸ“… Start Date", value=str(datetime.date.today()))
@@ -103,16 +105,17 @@ with gr.Blocks(theme="NoCrypt/[email protected]",css="theme.css") as app:
103
  with gr.Tabs():
104
  with gr.Tab("✨ Welcome"):
105
  with gr.Row(equal_height=True):
106
- # LEFT: Intro
107
  with gr.Column(scale=2):
108
  gr.Markdown("""
109
  # πŸ‘‹ Welcome to Career Buddy!
110
- **Your AI-powered career planner** for LinkedIn, GitHub, and goal-tracking.**
111
- If you enjoy this project and want to help me beat OpenAI costs; support me below
112
  """)
113
-
114
- gr.HTML('''<a href="https://ko-fi.com/wishingonstars" target="_blank"><img src="https://unfetteredpatterns.blog/wp-content/uploads/2025/05/support_me_on_kofi_badge_dark.webp" style="height: 72px; padding: 4px;" alt="Support me on Ko-fi" /></a>''')
115
-
 
 
116
  gr.Markdown("""
117
  ### πŸš€ Get Started
118
  1. **Enter your nickname** to personalize your journey.
@@ -120,7 +123,6 @@ with gr.Blocks(theme="NoCrypt/[email protected]",css="theme.css") as app:
120
  3. **Explore the tabs** for LinkedIn/GitHub analysis, smart planning, and more!
121
  """)
122
 
123
- # RIGHT: User Input
124
  with gr.Column(scale=1, elem_id="user-card"):
125
  gr.Markdown("## Your Journey Starts Here")
126
  nickname_input = gr.Textbox(label="Enter your Nickname", placeholder="e.g., DataScientistPro", interactive=True)
@@ -128,14 +130,14 @@ with gr.Blocks(theme="NoCrypt/[email protected]",css="theme.css") as app:
128
  with gr.Row():
129
  save_btn = gr.Button("Save Profile")
130
  load_btn = gr.Button("Load Profile")
131
-
132
- gr.Markdown("### Your Progress")
133
  progress_output = gr.Markdown("", elem_id="progress-output")
134
-
135
- save_btn.click(fn=lambda nickname, goal: (save_user_profile(nickname, goal), nickname.strip().lower().replace(' ', '_')),inputs=[nickname_input, weekly_goal_input],outputs=[progress_output, user_id_state])
136
-
 
 
137
  load_btn.click(
138
- fn=lambda: load_user_profile(),
139
  inputs=[],
140
  outputs=[nickname_input, weekly_goal_input, progress_output, user_id_state]
141
  )
@@ -149,17 +151,8 @@ with gr.Blocks(theme="NoCrypt/[email protected]",css="theme.css") as app:
149
  apify_dataset_btn = gr.Button("Analyze Apify Dataset (CSV)")
150
  with gr.Column(scale=2):
151
  linkedin_analysis_output = gr.Markdown("", label="LinkedIn Analysis Results")
152
-
153
- analyze_linkedin_btn.click(
154
- fn=fetch_and_analyze_linkedin,
155
- inputs=[linkedin_url_input],
156
- outputs=linkedin_analysis_output
157
- )
158
- apify_dataset_btn.click(
159
- fn=analyze_apify_dataset_ui,
160
- inputs=[],
161
- outputs=linkedin_analysis_output
162
- )
163
 
164
  with gr.Tab("πŸ™ GitGuru (GitHub Reviewer)", elem_id="gitguru-tab"):
165
  with gr.Row():
@@ -168,12 +161,7 @@ with gr.Blocks(theme="NoCrypt/[email protected]",css="theme.css") as app:
168
  analyze_github_btn = gr.Button("Analyze GitHub README")
169
  with gr.Column(scale=2):
170
  github_analysis_output = gr.Markdown("", label="GitHub Analysis Results")
171
-
172
- analyze_github_btn.click(
173
- fn=analyze_github,
174
- inputs=[github_readme_input],
175
- outputs=github_analysis_output
176
- )
177
 
178
  with gr.Tab("🧠 Smart Planner", elem_id="planner-card"):
179
  with gr.Row():
@@ -185,13 +173,11 @@ with gr.Blocks(theme="NoCrypt/[email protected]",css="theme.css") as app:
185
  roadmap_output = gr.Markdown("", label="Career Roadmap")
186
  planner_step_dropdown = gr.Dropdown(label="Planned Steps", choices=[], multiselect=True, visible=False)
187
  planner_week_marker = gr.Textbox(label="Current Week", value="πŸ“… Week 1", visible=False)
188
-
189
-
190
  planner_generate_btn.click(
191
  fn=generate_smart_plan,
192
  inputs=[user_id_state, start_date, planner_goal_input],
193
- outputs=[roadmap_output, planner_step_dropdown, planner_week_marker])
194
-
195
 
196
  with gr.Tab("🎯 Task Tracker", elem_id="gitguru-tab"):
197
  with gr.Row():
@@ -199,40 +185,32 @@ with gr.Blocks(theme="NoCrypt/[email protected]",css="theme.css") as app:
199
  task_name_input = gr.Textbox(label="Task Name", placeholder="e.g., Complete Python course", interactive=True)
200
  task_type_input = gr.Dropdown(label="Task Type", choices=["Learning", "Networking", "Project", "Application"], value="Learning", interactive=True)
201
  task_add_btn = gr.Button("Add Task")
202
-
203
  gr.Markdown("### Mark Task Steps Completed")
204
  task_step_input = gr.Textbox(label="Step to Mark Completed", placeholder="e.g., Chapter 1 of Python course", interactive=True)
205
  task_mark_completed_btn = gr.Button("Mark Step Completed")
206
-
207
  gr.Markdown("### Rewards")
208
  reward_amount_input = gr.Number(label="Reward Amount", value=10, interactive=True)
209
  reward_claim_btn = gr.Button("Claim Reward")
210
-
211
  reset_weekly_btn = gr.Button("Reset Weekly Data")
212
-
213
  with gr.Column(scale=2):
214
  tasks_display = gr.Markdown("", label="Your Tasks")
215
  progress_bar = gr.HTML("", label="Weekly Progress")
216
  rewards_display = gr.Markdown("", label="Your Rewards")
217
-
218
  task_add_btn.click(
219
- fn=lambda user_id, task_name, task_type: add_task(user_id, task_name, task_type),
 
220
  outputs=[tasks_display, progress_bar, rewards_display]
221
-
222
  )
223
-
224
  task_mark_completed_btn.click(
225
  fn=lambda user_id, step: mark_step_completed(user_id, step, tasks_display, progress_bar, rewards_display),
226
  inputs=[user_id_state, task_step_input],
227
  outputs=[tasks_display, progress_bar, rewards_display]
228
  )
229
-
230
  reward_claim_btn.click(
231
  fn=lambda user_id, amount: claim_reward(user_id, amount, rewards_display),
232
  inputs=[user_id_state, reward_amount_input],
233
  outputs=rewards_display
234
  )
235
-
236
  reset_weekly_btn.click(
237
  fn=lambda user_id: reset_weekly_data(user_id, tasks_display, progress_bar, rewards_display),
238
  inputs=[user_id_state],
@@ -250,7 +228,6 @@ with gr.Blocks(theme="NoCrypt/[email protected]",css="theme.css") as app:
250
  memo_add_course_btn = gr.Button("Add Course")
251
  with gr.Column(scale=2):
252
  memo_output = gr.Markdown("", label="Course Recommendations")
253
-
254
  memo_search_btn.click(
255
  fn=lambda query: memo_rag_engine(query, pine_index, embedding_model, client, summarizer),
256
  inputs=[memo_query_input],
@@ -269,47 +246,27 @@ with gr.Blocks(theme="NoCrypt/[email protected]",css="theme.css") as app:
269
  visualizer_generate_btn = gr.Button("Generate Visual Roadmap")
270
  with gr.Column(scale=2):
271
  visualizer_output = gr.Plot(label="Visual Roadmap")
272
-
273
  visualizer_generate_btn.click(
274
  fn=lambda goal: generate_visual_roadmap(goal, visual_steps),
275
  inputs=[visualizer_goal_input],
276
  outputs=visualizer_output
277
  )
278
 
279
-
280
  def save_user_profile(nickname, weekly_goal):
281
  user_id = nickname.lower().replace(" ", "_")
282
  user_id_state.value = user_id
283
- # In a real app, you\\'d save this to a database
284
  return f"Profile for **{nickname}** saved! Weekly goal: **{weekly_goal}**"
285
 
286
  def load_user_profile():
287
- # In a real app, you\\'d load this from a database
288
- # For now, just return some dummy data
289
  return "DataScientistPro", "Apply to 5 jobs, finish a Python course", "Loaded dummy profile."
290
 
291
- def generate_roadmap(goal, difficulty, pc, pine_index, client):
292
- # This function would use the RAG system to generate a roadmap
293
- # For now, return a placeholder
294
- steps = [
295
- "Learn Python Basics",
296
- "Understand Data Structures & Algorithms",
297
- "Master SQL",
298
- "Explore Machine Learning Fundamentals",
299
- "Build a Portfolio Project",
300
- "Apply for Jobs"
301
- ]
302
- return render_text_roadmap(goal, steps)
303
-
304
  def generate_visual_roadmap(goal, steps):
305
- # This function would generate a visual roadmap using matplotlib or similar
306
- # For now, return a placeholder plot
307
  import matplotlib.pyplot as plt
308
  fig, ax = plt.subplots()
309
- ax.barh(steps, [1]*len(steps))
310
  ax.set_title(f"Visual Roadmap for {goal}")
311
  return fig
312
 
313
-
314
  app.launch(debug=True)
315
-
 
93
 
94
  return f"""### πŸ” Recalled Plan for {goal}
95
 
96
+
97
+
98
 
99
 
100
+ with gr.Blocks(theme="NoCrypt/[email protected]", css="theme.css") as app:
101
  user_id_state = gr.State()
102
  roadmap_unlock = RoadmapUnlockManager()
103
  start_date = gr.Textbox(label="πŸ“… Start Date", value=str(datetime.date.today()))
 
105
  with gr.Tabs():
106
  with gr.Tab("✨ Welcome"):
107
  with gr.Row(equal_height=True):
 
108
  with gr.Column(scale=2):
109
  gr.Markdown("""
110
  # πŸ‘‹ Welcome to Career Buddy!
111
+ **Your AI-powered career planner** for LinkedIn, GitHub, and goal-tracking.
112
+ If you enjoy this project and want to help me beat OpenAI costs, support me below:
113
  """)
114
+ gr.HTML('''
115
+ <a href="https://ko-fi.com/wishingonstars" target="_blank">
116
+ <img src="https://unfetteredpatterns.blog/wp-content/uploads/2025/05/support_me_on_kofi_badge_dark.webp"
117
+ style="height: 72px; padding: 4px;" alt="Support me on Ko-fi" />
118
+ </a>''')
119
  gr.Markdown("""
120
  ### πŸš€ Get Started
121
  1. **Enter your nickname** to personalize your journey.
 
123
  3. **Explore the tabs** for LinkedIn/GitHub analysis, smart planning, and more!
124
  """)
125
 
 
126
  with gr.Column(scale=1, elem_id="user-card"):
127
  gr.Markdown("## Your Journey Starts Here")
128
  nickname_input = gr.Textbox(label="Enter your Nickname", placeholder="e.g., DataScientistPro", interactive=True)
 
130
  with gr.Row():
131
  save_btn = gr.Button("Save Profile")
132
  load_btn = gr.Button("Load Profile")
 
 
133
  progress_output = gr.Markdown("", elem_id="progress-output")
134
+ save_btn.click(
135
+ fn=lambda nickname, goal: (save_user_profile(nickname, goal), nickname.strip().lower().replace(' ', '_')),
136
+ inputs=[nickname_input, weekly_goal_input],
137
+ outputs=[progress_output, user_id_state]
138
+ )
139
  load_btn.click(
140
+ fn=load_user_profile,
141
  inputs=[],
142
  outputs=[nickname_input, weekly_goal_input, progress_output, user_id_state]
143
  )
 
151
  apify_dataset_btn = gr.Button("Analyze Apify Dataset (CSV)")
152
  with gr.Column(scale=2):
153
  linkedin_analysis_output = gr.Markdown("", label="LinkedIn Analysis Results")
154
+ analyze_linkedin_btn.click(fetch_and_analyze_linkedin, [linkedin_url_input], linkedin_analysis_output)
155
+ apify_dataset_btn.click(analyze_apify_dataset_ui, [], linkedin_analysis_output)
 
 
 
 
 
 
 
 
 
156
 
157
  with gr.Tab("πŸ™ GitGuru (GitHub Reviewer)", elem_id="gitguru-tab"):
158
  with gr.Row():
 
161
  analyze_github_btn = gr.Button("Analyze GitHub README")
162
  with gr.Column(scale=2):
163
  github_analysis_output = gr.Markdown("", label="GitHub Analysis Results")
164
+ analyze_github_btn.click(analyze_github, [github_readme_input], github_analysis_output)
 
 
 
 
 
165
 
166
  with gr.Tab("🧠 Smart Planner", elem_id="planner-card"):
167
  with gr.Row():
 
173
  roadmap_output = gr.Markdown("", label="Career Roadmap")
174
  planner_step_dropdown = gr.Dropdown(label="Planned Steps", choices=[], multiselect=True, visible=False)
175
  planner_week_marker = gr.Textbox(label="Current Week", value="πŸ“… Week 1", visible=False)
 
 
176
  planner_generate_btn.click(
177
  fn=generate_smart_plan,
178
  inputs=[user_id_state, start_date, planner_goal_input],
179
+ outputs=[roadmap_output, planner_step_dropdown, planner_week_marker]
180
+ )
181
 
182
  with gr.Tab("🎯 Task Tracker", elem_id="gitguru-tab"):
183
  with gr.Row():
 
185
  task_name_input = gr.Textbox(label="Task Name", placeholder="e.g., Complete Python course", interactive=True)
186
  task_type_input = gr.Dropdown(label="Task Type", choices=["Learning", "Networking", "Project", "Application"], value="Learning", interactive=True)
187
  task_add_btn = gr.Button("Add Task")
 
188
  gr.Markdown("### Mark Task Steps Completed")
189
  task_step_input = gr.Textbox(label="Step to Mark Completed", placeholder="e.g., Chapter 1 of Python course", interactive=True)
190
  task_mark_completed_btn = gr.Button("Mark Step Completed")
 
191
  gr.Markdown("### Rewards")
192
  reward_amount_input = gr.Number(label="Reward Amount", value=10, interactive=True)
193
  reward_claim_btn = gr.Button("Claim Reward")
 
194
  reset_weekly_btn = gr.Button("Reset Weekly Data")
 
195
  with gr.Column(scale=2):
196
  tasks_display = gr.Markdown("", label="Your Tasks")
197
  progress_bar = gr.HTML("", label="Weekly Progress")
198
  rewards_display = gr.Markdown("", label="Your Rewards")
 
199
  task_add_btn.click(
200
+ fn=lambda user_id, name, task_type: add_task(user_id, name, task_type),
201
+ inputs=[user_id_state, task_name_input, task_type_input],
202
  outputs=[tasks_display, progress_bar, rewards_display]
 
203
  )
 
204
  task_mark_completed_btn.click(
205
  fn=lambda user_id, step: mark_step_completed(user_id, step, tasks_display, progress_bar, rewards_display),
206
  inputs=[user_id_state, task_step_input],
207
  outputs=[tasks_display, progress_bar, rewards_display]
208
  )
 
209
  reward_claim_btn.click(
210
  fn=lambda user_id, amount: claim_reward(user_id, amount, rewards_display),
211
  inputs=[user_id_state, reward_amount_input],
212
  outputs=rewards_display
213
  )
 
214
  reset_weekly_btn.click(
215
  fn=lambda user_id: reset_weekly_data(user_id, tasks_display, progress_bar, rewards_display),
216
  inputs=[user_id_state],
 
228
  memo_add_course_btn = gr.Button("Add Course")
229
  with gr.Column(scale=2):
230
  memo_output = gr.Markdown("", label="Course Recommendations")
 
231
  memo_search_btn.click(
232
  fn=lambda query: memo_rag_engine(query, pine_index, embedding_model, client, summarizer),
233
  inputs=[memo_query_input],
 
246
  visualizer_generate_btn = gr.Button("Generate Visual Roadmap")
247
  with gr.Column(scale=2):
248
  visualizer_output = gr.Plot(label="Visual Roadmap")
 
249
  visualizer_generate_btn.click(
250
  fn=lambda goal: generate_visual_roadmap(goal, visual_steps),
251
  inputs=[visualizer_goal_input],
252
  outputs=visualizer_output
253
  )
254
 
255
+ # Backend logic for saving/loading
256
  def save_user_profile(nickname, weekly_goal):
257
  user_id = nickname.lower().replace(" ", "_")
258
  user_id_state.value = user_id
 
259
  return f"Profile for **{nickname}** saved! Weekly goal: **{weekly_goal}**"
260
 
261
  def load_user_profile():
 
 
262
  return "DataScientistPro", "Apply to 5 jobs, finish a Python course", "Loaded dummy profile."
263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  def generate_visual_roadmap(goal, steps):
 
 
265
  import matplotlib.pyplot as plt
266
  fig, ax = plt.subplots()
267
+ ax.barh(steps, [1] * len(steps))
268
  ax.set_title(f"Visual Roadmap for {goal}")
269
  return fig
270
 
271
+ # Start the app
272
  app.launch(debug=True)