Repository navigation
Expand file tree
/
Copy pathutils.py
More file actions
115 lines (78 loc) · 2.12 KB
/
Copy pathutils.py
File metadata and controls
115 lines (78 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
from langchain_google_genai import ChatGoogleGenerativeAI
from resources import RESOURCE_LINKS
def run_agent_sync(
google_api_key: str,
user_goal: str,
progress_callback=None
):
"""
Generate a personalized learning roadmap using Gemini.
"""
try:
if progress_callback:
progress_callback("Initializing Gemini AI...")
llm = ChatGoogleGenerativeAI(
model="gemini-2.5-flash",
google_api_key=google_api_key
)
# Find matching resources
goal_lower = user_goal.lower()
resource_text = ""
for keyword, links in RESOURCE_LINKS.items():
if keyword in goal_lower:
resource_text = "\nRecommended Resources:\n"
for name, url in links.items():
resource_text += f"- {name}: {url}\n"
break
if progress_callback:
progress_callback("Generating your learning roadmap...")
prompt = f"""
You are an expert learning coach.
Create a detailed day-wise learning roadmap.
Goal:
{user_goal}
{resource_text}
Instructions:
- Create a structured roadmap.
- Use Day 1, Day 2, Day 3 format.
- Include topic name.
- Include learning objectives.
- Include recommended learning resources.
- Include practical task/project for each day.
- Include a mini project wherever relevant.
- Keep progression logical.
- Make roadmap beginner friendly.
- Use the provided resources whenever possible.
- End with a final capstone project.
Output format:
# Learning Roadmap
Day 1
Topic:
Objectives:
- objective 1
- objective 2
Resources:
- resource 1
- resource 2
Practice Task:
Mini Project:
Day 2
Topic:
Objectives:
- objective 1
- objective 2
Resources:
- resource 1
- resource 2
Practice Task:
Mini Project:
Continue until roadmap completion.
At the end add:
# Final Capstone Project
"""
response = llm.invoke(prompt)
if progress_callback:
progress_callback("Learning roadmap generated successfully!")
return response.content
except Exception as e:
raise Exception(f"Error generating roadmap: {str(e)}")