JanickVision commited on
Commit
323454e
·
verified ·
1 Parent(s): c315347

Update career_conversations app

Browse files
Files changed (2) hide show
  1. Pract_Lab1.ipynb +237 -210
  2. app.py +17 -11
Pract_Lab1.ipynb CHANGED
@@ -1,210 +1,237 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": 2,
6
- "id": "fe1c6cff",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "from dotenv import load_dotenv\n",
11
- "from openai import OpenAI\n",
12
- "from IPython.display import Markdown, display"
13
- ]
14
- },
15
- {
16
- "cell_type": "code",
17
- "execution_count": 3,
18
- "id": "5a5709b1",
19
- "metadata": {},
20
- "outputs": [
21
- {
22
- "data": {
23
- "text/plain": [
24
- "True"
25
- ]
26
- },
27
- "execution_count": 3,
28
- "metadata": {},
29
- "output_type": "execute_result"
30
- }
31
- ],
32
- "source": [
33
- "load_dotenv(override = True)"
34
- ]
35
- },
36
- {
37
- "cell_type": "code",
38
- "execution_count": 4,
39
- "id": "321a7c0f",
40
- "metadata": {},
41
- "outputs": [
42
- {
43
- "data": {
44
- "text/markdown": [
45
- "Absolutely! Cape Town is a fantastic destination with plenty to offer even if you're on a limited budget. Here are some of the best budget-friendly spots and activities in Cape Town:\n",
46
- "\n",
47
- "### 1. **Table Mountain (Hiking)**\n",
48
- "- Instead of taking the cable car, hike up Table Mountain via popular trails like **Platteklip Gorge** or **Skeleton Gorge** for free.\n",
49
- "- The hike offers stunning views of the city and coastline.\n",
50
- "- Remember to start early and bring water, snacks, and sunscreen.\n",
51
- "\n",
52
- "### 2. **Lion's Head**\n",
53
- "- Another iconic hike in Cape Town.\n",
54
- "- The hike takes about 2-3 hours round trip, offering panoramic views, especially beautiful at sunrise or sunset.\n",
55
- "- Free and well-marked trail, but some parts are a bit steep—wear good shoes!\n",
56
- "\n",
57
- "### 3. **Kirstenbosch National Botanical Garden (Entry Fee)**\n",
58
- "- Entrance is affordable (around R60-80 for locals; slightly more for visitors).\n",
59
- "- Beautiful gardens showcasing indigenous plants with scenic mountain backdrops.\n",
60
- "- Great for picnics or a relaxing walk.\n",
61
- "\n",
62
- "### 4. **Beaches**\n",
63
- "- **Boulders Beach** – Famous for the penguin colony; entry fee is modest (about R160).\n",
64
- "- **Clifton Beaches** – Four pristine sandy beaches, completely free.\n",
65
- "- **Muizenberg Beach** – Known for colorful beach huts and surfing, free to access.\n",
66
- "\n",
67
- "### 5. **Bo-Kaap Neighborhood**\n",
68
- "- Walk around Bo-Kaap to enjoy the vibrant colorful houses and learn about Cape Malay culture.\n",
69
- "- Free self-guided walking tours available (just explore and take photos).\n",
70
- "- You can also visit the Bo-Kaap Museum with a small entry fee.\n",
71
- "\n",
72
- "### 6. **V&A Waterfront**\n",
73
- "- Free to explore and window shop.\n",
74
- "- Street performers, markets, and affordable eateries.\n",
75
- "- You can visit the *Zeitz MOCAA* (Museum of Contemporary Art Africa) — entrance fee applies but it’s one of the best modern art museums in Africa.\n",
76
- "\n",
77
- "### 7. **Company’s Garden**\n",
78
- "- Historic public garden in the city center.\n",
79
- "- Free to enter, with benches, a rose garden, and local squirrels.\n",
80
- "- Close to museums and the South African National Gallery.\n",
81
- "\n",
82
- "### 8. **Greenmarket Square**\n",
83
- "- A bustling market in the city center.\n",
84
- "- Great for bargain souvenirs, artwork, and crafts.\n",
85
- "- Browsing is free; bargaining is expected.\n",
86
- "\n",
87
- "### 9. **Chapman's Peak Drive**\n",
88
- "- One of the world’s most scenic coastal drives.\n",
89
- "- There is a small toll fee (around R50 one way).\n",
90
- "- Stop at various lookouts for incredible photo opportunities.\n",
91
- "\n",
92
- "### 10. **District Six Museum**\n",
93
- "- Entry fee is reasonable (about R45).\n",
94
- "- Offers a poignant history of apartheid and forced removals in Cape Town.\n",
95
- "\n",
96
- "---\n",
97
- "\n",
98
- "### Bonus Tips for Saving Money:\n",
99
- "- Use **MyCiTi buses** to get around cheaply and safely.\n",
100
- "- Buy groceries and prepare your own meals.\n",
101
- "- Visit free walking tours (tip-based) to learn about the city.\n",
102
- "- Visit during the shoulder seasons (spring and autumn) for better deals on accommodation.\n",
103
- "\n",
104
- "Enjoy your trip to Cape Town! Let me know if you want recommendations for budget accommodation or food spots!"
105
- ],
106
- "text/plain": [
107
- "<IPython.core.display.Markdown object>"
108
- ]
109
- },
110
- "metadata": {},
111
- "output_type": "display_data"
112
- }
113
- ],
114
- "source": [
115
- "Question = \"Can you provide the best spots to visit in Cape Town in limited Budget\"\n",
116
- "messages = [{\"role\":\"user\", \"content\":Question}]\n",
117
- "\n",
118
- "openai = OpenAI()\n",
119
- "response = openai.chat.completions.create(\n",
120
- " model = \"gpt-4.1-mini\",\n",
121
- " messages = messages\n",
122
- ")\n",
123
- "\n",
124
- "output = response.choices[0].message.content\n",
125
- "\n",
126
- "display(Markdown(output))"
127
- ]
128
- },
129
- {
130
- "cell_type": "code",
131
- "execution_count": 5,
132
- "id": "7cc29f57",
133
- "metadata": {},
134
- "outputs": [
135
- {
136
- "data": {
137
- "text/markdown": [
138
- "Certainly! If you’re visiting Cape Town on a limited budget, here are the **top 3 must-visit spots** that offer incredible experiences without breaking the bank:\n",
139
- "\n",
140
- "1. **Table Mountain (via Platteklip Gorge Hiking Trail)** \n",
141
- " - *Why visit*: Iconic landmark with stunning panoramic views of Cape Town and the coastline. \n",
142
- " - *Cost*: Free if you hike up (cable car is extra but optional). \n",
143
- " - *Tip*: Start early to avoid crowds and midday heat.\n",
144
- "\n",
145
- "2. **Bo-Kaap Neighborhood** \n",
146
- " - *Why visit*: Famous for its colorful houses, rich history, and vibrant culture. Great for photography and exploring local markets and eateries. \n",
147
- " - *Cost*: Free to walk around; optional small fees for museum visits. \n",
148
- " - *Tip*: Try traditional Cape Malay food at affordable local spots.\n",
149
- "\n",
150
- "3. **Kirstenbosch National Botanical Garden** \n",
151
- " - *Why visit*: Beautiful gardens showcasing South Africa’s unique flora with stunning mountain backdrop. Great for picnics and nature walks. \n",
152
- " - *Cost*: Low entrance fee (around R75 for locals, slightly higher for tourists). \n",
153
- " - *Tip*: Bring your own snacks to save money.\n",
154
- "\n",
155
- "These spots provide a perfect mix of natural beauty, culture, and history, all accessible on a budget!"
156
- ],
157
- "text/plain": [
158
- "<IPython.core.display.Markdown object>"
159
- ]
160
- },
161
- "metadata": {},
162
- "output_type": "display_data"
163
- }
164
- ],
165
- "source": [
166
- "messages = [{\"role\":\"user\", \"content\":Question},\n",
167
- " {\"role\":\"user\",\"content\":\"Choose only Top 3 spots only\"}]\n",
168
- "\n",
169
- "openai = OpenAI()\n",
170
- "response = openai.chat.completions.create(\n",
171
- " model = \"gpt-4.1-mini\",\n",
172
- " messages = messages\n",
173
- ")\n",
174
- "\n",
175
- "output = response.choices[0].message.content\n",
176
- "\n",
177
- "display(Markdown(output))"
178
- ]
179
- },
180
- {
181
- "cell_type": "code",
182
- "execution_count": null,
183
- "id": "c644660b",
184
- "metadata": {},
185
- "outputs": [],
186
- "source": []
187
- }
188
- ],
189
- "metadata": {
190
- "kernelspec": {
191
- "display_name": "agents (3.12.5)",
192
- "language": "python",
193
- "name": "python3"
194
- },
195
- "language_info": {
196
- "codemirror_mode": {
197
- "name": "ipython",
198
- "version": 3
199
- },
200
- "file_extension": ".py",
201
- "mimetype": "text/x-python",
202
- "name": "python",
203
- "nbconvert_exporter": "python",
204
- "pygments_lexer": "ipython3",
205
- "version": "3.12.5"
206
- }
207
- },
208
- "nbformat": 4,
209
- "nbformat_minor": 5
210
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 2,
6
+ "id": "fe1c6cff",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "from dotenv import load_dotenv\n",
11
+ "from openai import OpenAI\n",
12
+ "from IPython.display import Markdown, display"
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "code",
17
+ "execution_count": 3,
18
+ "id": "5a5709b1",
19
+ "metadata": {},
20
+ "outputs": [
21
+ {
22
+ "data": {
23
+ "text/plain": [
24
+ "True"
25
+ ]
26
+ },
27
+ "execution_count": 3,
28
+ "metadata": {},
29
+ "output_type": "execute_result"
30
+ }
31
+ ],
32
+ "source": [
33
+ "load_dotenv(override = True)"
34
+ ]
35
+ },
36
+ {
37
+ "cell_type": "code",
38
+ "execution_count": 4,
39
+ "id": "321a7c0f",
40
+ "metadata": {},
41
+ "outputs": [
42
+ {
43
+ "data": {
44
+ "text/markdown": [
45
+ "Absolutely! Cape Town is a fantastic destination with plenty to offer even if you're on a limited budget. Here are some of the best budget-friendly spots and activities in Cape Town:\n",
46
+ "\n",
47
+ "### 1. **Table Mountain (Hiking)**\n",
48
+ "- Instead of taking the cable car, hike up Table Mountain via popular trails like **Platteklip Gorge** or **Skeleton Gorge** for free.\n",
49
+ "- The hike offers stunning views of the city and coastline.\n",
50
+ "- Remember to start early and bring water, snacks, and sunscreen.\n",
51
+ "\n",
52
+ "### 2. **Lion's Head**\n",
53
+ "- Another iconic hike in Cape Town.\n",
54
+ "- The hike takes about 2-3 hours round trip, offering panoramic views, especially beautiful at sunrise or sunset.\n",
55
+ "- Free and well-marked trail, but some parts are a bit steep—wear good shoes!\n",
56
+ "\n",
57
+ "### 3. **Kirstenbosch National Botanical Garden (Entry Fee)**\n",
58
+ "- Entrance is affordable (around R60-80 for locals; slightly more for visitors).\n",
59
+ "- Beautiful gardens showcasing indigenous plants with scenic mountain backdrops.\n",
60
+ "- Great for picnics or a relaxing walk.\n",
61
+ "\n",
62
+ "### 4. **Beaches**\n",
63
+ "- **Boulders Beach** – Famous for the penguin colony; entry fee is modest (about R160).\n",
64
+ "- **Clifton Beaches** – Four pristine sandy beaches, completely free.\n",
65
+ "- **Muizenberg Beach** – Known for colorful beach huts and surfing, free to access.\n",
66
+ "\n",
67
+ "### 5. **Bo-Kaap Neighborhood**\n",
68
+ "- Walk around Bo-Kaap to enjoy the vibrant colorful houses and learn about Cape Malay culture.\n",
69
+ "- Free self-guided walking tours available (just explore and take photos).\n",
70
+ "- You can also visit the Bo-Kaap Museum with a small entry fee.\n",
71
+ "\n",
72
+ "### 6. **V&A Waterfront**\n",
73
+ "- Free to explore and window shop.\n",
74
+ "- Street performers, markets, and affordable eateries.\n",
75
+ "- You can visit the *Zeitz MOCAA* (Museum of Contemporary Art Africa) — entrance fee applies but it’s one of the best modern art museums in Africa.\n",
76
+ "\n",
77
+ "### 7. **Company’s Garden**\n",
78
+ "- Historic public garden in the city center.\n",
79
+ "- Free to enter, with benches, a rose garden, and local squirrels.\n",
80
+ "- Close to museums and the South African National Gallery.\n",
81
+ "\n",
82
+ "### 8. **Greenmarket Square**\n",
83
+ "- A bustling market in the city center.\n",
84
+ "- Great for bargain souvenirs, artwork, and crafts.\n",
85
+ "- Browsing is free; bargaining is expected.\n",
86
+ "\n",
87
+ "### 9. **Chapman's Peak Drive**\n",
88
+ "- One of the world’s most scenic coastal drives.\n",
89
+ "- There is a small toll fee (around R50 one way).\n",
90
+ "- Stop at various lookouts for incredible photo opportunities.\n",
91
+ "\n",
92
+ "### 10. **District Six Museum**\n",
93
+ "- Entry fee is reasonable (about R45).\n",
94
+ "- Offers a poignant history of apartheid and forced removals in Cape Town.\n",
95
+ "\n",
96
+ "---\n",
97
+ "\n",
98
+ "### Bonus Tips for Saving Money:\n",
99
+ "- Use **MyCiTi buses** to get around cheaply and safely.\n",
100
+ "- Buy groceries and prepare your own meals.\n",
101
+ "- Visit free walking tours (tip-based) to learn about the city.\n",
102
+ "- Visit during the shoulder seasons (spring and autumn) for better deals on accommodation.\n",
103
+ "\n",
104
+ "Enjoy your trip to Cape Town! Let me know if you want recommendations for budget accommodation or food spots!"
105
+ ],
106
+ "text/plain": [
107
+ "<IPython.core.display.Markdown object>"
108
+ ]
109
+ },
110
+ "metadata": {},
111
+ "output_type": "display_data"
112
+ }
113
+ ],
114
+ "source": [
115
+ "Question = \"Can you provide the best spots to visit in Cape Town in limited Budget\"\n",
116
+ "messages = [{\"role\":\"user\", \"content\":Question}]\n",
117
+ "\n",
118
+ "openai = OpenAI()\n",
119
+ "response = openai.chat.completions.create(\n",
120
+ " model = \"gpt-4.1-mini\",\n",
121
+ " messages = messages\n",
122
+ ")\n",
123
+ "\n",
124
+ "output = response.choices[0].message.content\n",
125
+ "\n",
126
+ "display(Markdown(output))"
127
+ ]
128
+ },
129
+ {
130
+ "cell_type": "code",
131
+ "execution_count": 5,
132
+ "id": "7cc29f57",
133
+ "metadata": {},
134
+ "outputs": [
135
+ {
136
+ "data": {
137
+ "text/markdown": [
138
+ "Certainly! If you’re visiting Cape Town on a limited budget, here are the **top 3 must-visit spots** that offer incredible experiences without breaking the bank:\n",
139
+ "\n",
140
+ "1. **Table Mountain (via Platteklip Gorge Hiking Trail)** \n",
141
+ " - *Why visit*: Iconic landmark with stunning panoramic views of Cape Town and the coastline. \n",
142
+ " - *Cost*: Free if you hike up (cable car is extra but optional). \n",
143
+ " - *Tip*: Start early to avoid crowds and midday heat.\n",
144
+ "\n",
145
+ "2. **Bo-Kaap Neighborhood** \n",
146
+ " - *Why visit*: Famous for its colorful houses, rich history, and vibrant culture. Great for photography and exploring local markets and eateries. \n",
147
+ " - *Cost*: Free to walk around; optional small fees for museum visits. \n",
148
+ " - *Tip*: Try traditional Cape Malay food at affordable local spots.\n",
149
+ "\n",
150
+ "3. **Kirstenbosch National Botanical Garden** \n",
151
+ " - *Why visit*: Beautiful gardens showcasing South Africa’s unique flora with stunning mountain backdrop. Great for picnics and nature walks. \n",
152
+ " - *Cost*: Low entrance fee (around R75 for locals, slightly higher for tourists). \n",
153
+ " - *Tip*: Bring your own snacks to save money.\n",
154
+ "\n",
155
+ "These spots provide a perfect mix of natural beauty, culture, and history, all accessible on a budget!"
156
+ ],
157
+ "text/plain": [
158
+ "<IPython.core.display.Markdown object>"
159
+ ]
160
+ },
161
+ "metadata": {},
162
+ "output_type": "display_data"
163
+ }
164
+ ],
165
+ "source": [
166
+ "messages = [{\"role\":\"user\", \"content\":Question},\n",
167
+ " {\"role\":\"user\",\"content\":\"Choose only Top 3 spots only\"}]\n",
168
+ "\n",
169
+ "openai = OpenAI()\n",
170
+ "response = openai.chat.completions.create(\n",
171
+ " model = \"gpt-4.1-mini\",\n",
172
+ " messages = messages\n",
173
+ ")\n",
174
+ "\n",
175
+ "output = response.choices[0].message.content\n",
176
+ "\n",
177
+ "display(Markdown(output))"
178
+ ]
179
+ },
180
+ {
181
+ "cell_type": "code",
182
+ "execution_count": 2,
183
+ "id": "c644660b",
184
+ "metadata": {},
185
+ "outputs": [],
186
+ "source": [
187
+ "import os\n",
188
+ "import requests\n",
189
+ "\n",
190
+ "def send_telegram_message(message):\n",
191
+ " token = os.getenv(\"TELEGRAM_BOT_TOKEN\")\n",
192
+ " chat_id = os.getenv(\"TELEGRAM_CHAT_ID\")\n",
193
+ "\n",
194
+ " url = f\"https://api.telegram.org/bot{token}/sendMessage\"\n",
195
+ "\n",
196
+ " payload = {\n",
197
+ " \"chat_id\": chat_id,\n",
198
+ " \"text\": message\n",
199
+ " }\n",
200
+ "\n",
201
+ " requests.post(url, data=payload)\n",
202
+ "\n",
203
+ "send_telegram_message(\" Telegram bot is working!\")\n",
204
+ "send_telegram_message(\"Hello World Vicky\")"
205
+ ]
206
+ },
207
+ {
208
+ "cell_type": "code",
209
+ "execution_count": null,
210
+ "id": "869abe4e",
211
+ "metadata": {},
212
+ "outputs": [],
213
+ "source": []
214
+ }
215
+ ],
216
+ "metadata": {
217
+ "kernelspec": {
218
+ "display_name": "agents (3.12.5)",
219
+ "language": "python",
220
+ "name": "python3"
221
+ },
222
+ "language_info": {
223
+ "codemirror_mode": {
224
+ "name": "ipython",
225
+ "version": 3
226
+ },
227
+ "file_extension": ".py",
228
+ "mimetype": "text/x-python",
229
+ "name": "python",
230
+ "nbconvert_exporter": "python",
231
+ "pygments_lexer": "ipython3",
232
+ "version": "3.12.5"
233
+ }
234
+ },
235
+ "nbformat": 4,
236
+ "nbformat_minor": 5
237
+ }
app.py CHANGED
@@ -10,23 +10,27 @@ from pathlib import Path
10
 
11
  load_dotenv(override=True)
12
 
13
- def push(text):
14
- requests.post(
15
- "https://api.pushover.net/1/messages.json",
16
- data={
17
- "token": os.getenv("PUSHOVER_TOKEN"),
18
- "user": os.getenv("PUSHOVER_USER"),
19
- "message": text,
20
- }
21
- )
22
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  def record_user_details(email, name="Name not provided", notes="not provided"):
25
- push(f"Recording {name} with email {email} and notes {notes}")
26
  return {"recorded": "ok"}
27
 
28
  def record_unknown_question(question):
29
- push(f"Recording {question}")
30
  return {"recorded": "ok"}
31
 
32
  record_user_details_json = {
@@ -131,6 +135,8 @@ Be professional and engaging, as if talking to a potential client or future empl
131
  If you don't know the answer to any question, use your record_unknown_question tool to record the question that you couldn't answer, even if it's about something trivial or unrelated to career. \
132
  If the user is engaging in discussion, try to steer them towards getting in touch via email; ask for their email and record it using your record_user_details tool. "
133
 
 
 
134
  system_prompt += f"\n\n## Summary:\n{self.summary}\n\n## LinkedIn Profile:\n{self.linkedin}\n\n"
135
  system_prompt += f"With this context, please chat with the user, always staying in character as {self.name}."
136
  return system_prompt
 
10
 
11
  load_dotenv(override=True)
12
 
13
+ def send_telegram_message(message):
14
+ token = os.getenv("TELEGRAM_BOT_TOKEN")
15
+ chat_id = os.getenv("TELEGRAM_CHAT_ID")
 
 
 
 
 
 
16
 
17
+ if not token or not chat_id:
18
+ raise RuntimeError("Missing TELEGRAM_BOT_TOKEN or TELEGRAM_CHAT_ID")
19
+
20
+ url = f"https://api.telegram.org/bot{token}/sendMessage"
21
+ payload = {
22
+ "chat_id": chat_id,
23
+ "text": message,
24
+ }
25
+
26
+ requests.post(url, data=payload, timeout=10)
27
 
28
  def record_user_details(email, name="Name not provided", notes="not provided"):
29
+ send_telegram_message(f"Recording {name} with email {email} and notes {notes}")
30
  return {"recorded": "ok"}
31
 
32
  def record_unknown_question(question):
33
+ send_telegram_message(f"Recording {question}")
34
  return {"recorded": "ok"}
35
 
36
  record_user_details_json = {
 
135
  If you don't know the answer to any question, use your record_unknown_question tool to record the question that you couldn't answer, even if it's about something trivial or unrelated to career. \
136
  If the user is engaging in discussion, try to steer them towards getting in touch via email; ask for their email and record it using your record_user_details tool. "
137
 
138
+
139
+
140
  system_prompt += f"\n\n## Summary:\n{self.summary}\n\n## LinkedIn Profile:\n{self.linkedin}\n\n"
141
  system_prompt += f"With this context, please chat with the user, always staying in character as {self.name}."
142
  return system_prompt