Skip to content

Commit c64712d

Browse files
put LLM endpoint URL in env
1 parent aaa4399 commit c64712d

5 files changed

Lines changed: 46 additions & 32 deletions

File tree

day1.1_python-tools/02_ai-assistant.ipynb

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,37 @@
1414
"\n",
1515
"## API Access\n",
1616
"\n",
17-
"As explained in the [slides](ai-assistant.pdf), we want to use an LLM provider API that our AI assistant can connect to. For this, we need to provide an according API key. To do this for JuypterLab in a virtual environment managed by `uv`:\n",
17+
"As explained in the [slides](ai-assistant.pdf), we want to use an LLM provider API that our AI assistant can connect to. \n",
18+
"For this, we need to provide the URL for the LLM endpoint (API), and an according API key. \n",
19+
"To do this for JuypterLab in a virtual environment managed by `uv`:\n",
1820
"* Create a file `.env` (hidden file) in the environments' directory\n",
21+
"* Add the line: `ENDPOINT_URL=url` (replace _url_ with the actual URL to the API)\n",
1922
"* Add the line: `OPENAI_API_KEY=your-api-key` (replace _your-api-key_ with the actual key)\n",
2023
"* Start JupyterLab with the content of this `.env` file via:\n",
2124
"```bash\n",
2225
"uv run --env-file path/to/.env -- jupyter lab\n",
2326
"```"
2427
]
2528
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": null,
32+
"id": "9d048f5a-3d78-4527-a3db-1103d5bcfbcc",
33+
"metadata": {},
34+
"outputs": [],
35+
"source": [
36+
"# Running this cell should now print the endpoint URL\n",
37+
"%env ENDPOINT_URL"
38+
]
39+
},
2640
{
2741
"cell_type": "code",
2842
"execution_count": null,
2943
"id": "e203246d-f5ef-42a5-82c8-7c29f296bee2",
3044
"metadata": {},
3145
"outputs": [],
3246
"source": [
33-
"# Running this cell should now print your API key\n",
47+
"# Running this cell should now print the API key\n",
3448
"%env OPENAI_API_KEY"
3549
]
3650
},
@@ -44,11 +58,13 @@
4458
},
4559
{
4660
"cell_type": "code",
47-
"execution_count": null,
61+
"execution_count": 15,
4862
"id": "c4ba2f0e-9f59-46c9-a063-f0654bde4808",
4963
"metadata": {},
5064
"outputs": [],
5165
"source": [
66+
"# Import os to read env vars\n",
67+
"import os\n",
5268
"# Import bia-bob as bob\n",
5369
"from bia_bob import bob\n",
5470
"# Import additional helper functions from bia_bob\n",
@@ -65,7 +81,7 @@
6581
},
6682
{
6783
"cell_type": "code",
68-
"execution_count": 3,
84+
"execution_count": 16,
6985
"id": "4c378c01-fabf-4fdc-ba2f-19eb5eded34d",
7086
"metadata": {},
7187
"outputs": [
@@ -88,7 +104,7 @@
88104
}
89105
],
90106
"source": [
91-
"bob.initialize(endpoint='https://kiara.sc.uni-leipzig.de/api/v1')"
107+
"bob.initialize(endpoint=os.getenv('ENDPOINT_URL'))"
92108
]
93109
},
94110
{
@@ -101,7 +117,7 @@
101117
},
102118
{
103119
"cell_type": "code",
104-
"execution_count": 4,
120+
"execution_count": 17,
105121
"id": "92bcf410-2728-4826-8646-e6bef54eab4b",
106122
"metadata": {},
107123
"outputs": [
@@ -121,13 +137,13 @@
121137
" 'vllm-nvidia-llama-3-3-70b-instruct-fp8']"
122138
]
123139
},
124-
"execution_count": 4,
140+
"execution_count": 17,
125141
"metadata": {},
126142
"output_type": "execute_result"
127143
}
128144
],
129145
"source": [
130-
"available_models(endpoint='https://kiara.sc.uni-leipzig.de/api/v1')"
146+
"available_models(endpoint=os.getenv('ENDPOINT_URL'))"
131147
]
132148
},
133149
{
@@ -140,7 +156,7 @@
140156
},
141157
{
142158
"cell_type": "code",
143-
"execution_count": 5,
159+
"execution_count": 18,
144160
"id": "b70c98b4-b436-45ee-9ff1-19921584774e",
145161
"metadata": {},
146162
"outputs": [
@@ -164,7 +180,7 @@
164180
],
165181
"source": [
166182
"bob.initialize(\n",
167-
" endpoint='https://kiara.sc.uni-leipzig.de/api/v1', \n",
183+
" endpoint=os.getenv('ENDPOINT_URL'),\n",
168184
" model=\"vllm-llama-4-scout-17b-16e-instruct\",\n",
169185
")"
170186
]
@@ -196,7 +212,7 @@
196212
},
197213
{
198214
"cell_type": "code",
199-
"execution_count": 6,
215+
"execution_count": 19,
200216
"id": "34bfa465-828c-4cfa-85e6-0f2e491b76cc",
201217
"metadata": {},
202218
"outputs": [
@@ -205,15 +221,13 @@
205221
"text/markdown": [
206222
"**Machine Learning Overview**\n",
207223
"\n",
208-
"Machine learning is a subset of artificial intelligence that involves training algorithms to learn from data and make predictions or decisions without being explicitly programmed. It enables computers to improve their performance on a task over time, based on experience and data.\n",
209-
"\n",
210-
"In machine learning, there are several key concepts:\n",
224+
"Machine learning is a subset of artificial intelligence that involves training algorithms to learn patterns and relationships in data, enabling them to make predictions, classify objects, or make decisions without being explicitly programmed. It encompasses various techniques, including:\n",
211225
"\n",
212-
"* **Supervised learning**: The algorithm learns from labeled data to make predictions on new, unseen data.\n",
213-
"* **Unsupervised learning**: The algorithm discovers patterns or relationships in unlabeled data.\n",
214-
"* **Reinforcement learning**: The algorithm learns through trial and error by interacting with an environment and receiving feedback.\n",
226+
"* **Supervised Learning**: Learning from labeled data to make predictions on new, unseen data.\n",
227+
"* **Unsupervised Learning**: Discovering hidden patterns or relationships in unlabeled data.\n",
228+
"* **Reinforcement Learning**: Learning through trial and error by interacting with an environment.\n",
215229
"\n",
216-
"Machine learning has numerous applications in various fields, including medical diagnosis, image classification, natural language processing, and more."
230+
"Machine learning has numerous applications in medical data science, such as disease diagnosis, patient outcome prediction, and personalized medicine."
217231
],
218232
"text/plain": [
219233
"<IPython.core.display.Markdown object>"

day1.3_ml-basics/01_regression.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
{
2222
"cell_type": "code",
23-
"execution_count": 4,
23+
"execution_count": 3,
2424
"id": "8e15a245-d6b7-45f1-a101-7e8dcc523e89",
2525
"metadata": {},
2626
"outputs": [
@@ -45,26 +45,26 @@
4545
"source": [
4646
"# Just in case we need help\n",
4747
"# Import bia-bob as a helpful Python & Medical AI expert\n",
48-
"from bia_bob import bob\n",
4948
"import os\n",
49+
"from bia_bob import bob\n",
5050
"\n",
5151
"bob.initialize(\n",
52-
" endpoint='https://kiara.sc.uni-leipzig.de/api/v1', \n",
52+
" endpoint=os.getenv('ENDPOINT_URL'),\n",
5353
" model=\"vllm-llama-4-scout-17b-16e-instruct\",\n",
5454
" system_prompt=os.getenv('SYSTEM_PROMPT_MEDICAL_AI')\n",
5555
")"
5656
]
5757
},
5858
{
5959
"cell_type": "code",
60-
"execution_count": 5,
60+
"execution_count": 2,
6161
"id": "600e5273-de44-4b5d-b8fd-776e120d0cbc",
6262
"metadata": {},
6363
"outputs": [
6464
{
6565
"data": {
6666
"text/markdown": [
67-
"I am a medical data science AI assistant, an expert in Python programming and data analysis with extensive experience working with various medical datasets."
67+
"I'm an expert in medical data science and a skilled Python programmer and data analyst with extensive experience working with various medical datasets and applying data analysis, machine learning, and deep learning techniques."
6868
],
6969
"text/plain": [
7070
"<IPython.core.display.Markdown object>"

day1.3_ml-basics/02_random-forest.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545
"source": [
4646
"# Just in case we need help\n",
4747
"# Import bia-bob as a helpful Python & Medical AI expert\n",
48-
"from bia_bob import bob\n",
4948
"import os\n",
49+
"from bia_bob import bob\n",
5050
"\n",
5151
"bob.initialize(\n",
52-
" endpoint='https://kiara.sc.uni-leipzig.de/api/v1', \n",
52+
" endpoint=os.getenv('ENDPOINT_URL'),\n",
5353
" model=\"vllm-llama-4-scout-17b-16e-instruct\",\n",
5454
" system_prompt=os.getenv('SYSTEM_PROMPT_MEDICAL_AI')\n",
5555
")"
@@ -64,7 +64,7 @@
6464
{
6565
"data": {
6666
"text/markdown": [
67-
"I'm a medical data science AI assistant, an expert in Python programming and data analysis, specializing in tasks like data preprocessing, feature engineering, machine learning, and deep learning for medical datasets."
67+
"I'm an expert in medical data science and a skilled Python programmer and data analyst with extensive experience working with various medical datasets and applying data analysis, machine learning, and deep learning techniques."
6868
],
6969
"text/plain": [
7070
"<IPython.core.display.Markdown object>"

day1.3_ml-basics/03_clustering.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545
"source": [
4646
"# Just in case we need help\n",
4747
"# Import bia-bob as a helpful Python & Medical AI expert\n",
48-
"from bia_bob import bob\n",
4948
"import os\n",
49+
"from bia_bob import bob\n",
5050
"\n",
5151
"bob.initialize(\n",
52-
" endpoint='https://kiara.sc.uni-leipzig.de/api/v1', \n",
52+
" endpoint=os.getenv('ENDPOINT_URL'),\n",
5353
" model=\"vllm-llama-4-scout-17b-16e-instruct\",\n",
5454
" system_prompt=os.getenv('SYSTEM_PROMPT_MEDICAL_AI')\n",
5555
")"
@@ -64,7 +64,7 @@
6464
{
6565
"data": {
6666
"text/markdown": [
67-
"I'm a medical data science AI assistant, an expert in Python programming and data analysis with extensive experience working with various medical datasets."
67+
"I'm an expert in medical data science and a skilled Python programmer and data analyst with extensive experience working with various medical datasets and applying data analysis, machine learning, and deep learning techniques."
6868
],
6969
"text/plain": [
7070
"<IPython.core.display.Markdown object>"

day1.3_ml-basics/04_dimension.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@
4646
"source": [
4747
"# Just in case we need help\n",
4848
"# Import bia-bob as a helpful Python & Medical AI expert\n",
49-
"from bia_bob import bob\n",
5049
"import os\n",
50+
"from bia_bob import bob\n",
5151
"\n",
5252
"bob.initialize(\n",
53-
" endpoint='https://kiara.sc.uni-leipzig.de/api/v1', \n",
53+
" endpoint=os.getenv('ENDPOINT_URL'),\n",
5454
" model=\"vllm-llama-4-scout-17b-16e-instruct\",\n",
5555
" system_prompt=os.getenv('SYSTEM_PROMPT_MEDICAL_AI')\n",
5656
")"
@@ -65,7 +65,7 @@
6565
{
6666
"data": {
6767
"text/markdown": [
68-
"I am a medical data science AI assistant, an expert in Python programming and data analysis with extensive experience working with various medical datasets."
68+
"I'm an expert in medical data science and a skilled Python programmer and data analyst with extensive experience working with various medical datasets and applying data analysis, machine learning, and deep learning techniques."
6969
],
7070
"text/plain": [
7171
"<IPython.core.display.Markdown object>"

0 commit comments

Comments
 (0)