Skip to content

Commit b25fd0a

Browse files
authored
update notebooks (#40)
* update Evaluator-Optimizer notebook: simplify langchain4j configuration, add execution metadata, and refine feedback logic * update notebooks: refine langchain4j configuration, adjust execution metadata, and streamline content alignment across workflows * update notebooks: bump `kinference` to 0.2.27 and `ktor` to 3.3.3, refine metadata, and adjust cache handling logic * update LangChain4j notebook: refine configuration, adjust execution metadata, and streamline content for better clarity and alignment * update OpenAI Java SDK notebooks: bump SDK to 4.8.0, refine execution metadata, enhance Kotlin coroutine examples, and align content across workflows * update Spring-AI notebooks: refine execution metadata, align haiku content, improve text-to-audio examples, and update model configurations
1 parent a0bc232 commit b25fd0a

23 files changed

+2131
-1806
lines changed

notebooks/agents/Evaluator-Optimizer Workflow.ipynb

Lines changed: 320 additions & 38 deletions
Large diffs are not rendered by default.

notebooks/agents/Orchestrator-Workers Workflow.ipynb

Lines changed: 89 additions & 76 deletions
Large diffs are not rendered by default.

notebooks/agents/Parallelization Workflow.ipynb

Lines changed: 225 additions & 377 deletions
Large diffs are not rendered by default.

notebooks/agents/Prompt-Chaining Workflow.ipynb

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,23 @@
4040
"metadata": {
4141
"collapsed": true,
4242
"ExecuteTime": {
43-
"end_time": "2025-05-11T21:48:44.069877Z",
44-
"start_time": "2025-05-11T21:48:43.106474Z"
43+
"end_time": "2025-11-30T13:48:49.259877Z",
44+
"start_time": "2025-11-30T13:48:48.611866Z"
45+
},
46+
"executionRelatedData": {
47+
"compiledClasses": [
48+
"Line_3_jupyter",
49+
"Line_4_jupyter",
50+
"Line_5_jupyter",
51+
"Line_6_jupyter"
52+
]
4553
}
4654
},
4755
"cell_type": "code",
4856
"source": [
4957
"%useLatestDescriptors\n",
5058
"%use coroutines\n",
51-
"%use langchain4j(1.0.0-beta3, anthropic)"
59+
"%use langchain4j(model = anthropic)"
5260
],
5361
"outputs": [],
5462
"execution_count": 1
@@ -61,8 +69,13 @@
6169
{
6270
"metadata": {
6371
"ExecuteTime": {
64-
"end_time": "2025-05-11T21:48:44.100358Z",
65-
"start_time": "2025-05-11T21:48:44.073812Z"
72+
"end_time": "2025-11-30T13:48:49.295090Z",
73+
"start_time": "2025-11-30T13:48:49.260582Z"
74+
},
75+
"executionRelatedData": {
76+
"compiledClasses": [
77+
"Line_7_jupyter"
78+
]
6679
}
6780
},
6881
"cell_type": "code",
@@ -82,14 +95,19 @@
8295
{
8396
"metadata": {
8497
"ExecuteTime": {
85-
"end_time": "2025-05-11T21:48:49.867603Z",
86-
"start_time": "2025-05-11T21:48:49.653724Z"
98+
"end_time": "2025-11-30T13:48:49.530413Z",
99+
"start_time": "2025-11-30T13:48:49.295646Z"
100+
},
101+
"executionRelatedData": {
102+
"compiledClasses": [
103+
"Line_8_jupyter"
104+
]
87105
}
88106
},
89107
"cell_type": "code",
90108
"source": [
91-
"import dev.langchain4j.data.message.SystemMessage.systemMessage\n",
92-
"import dev.langchain4j.data.message.UserMessage.userMessage\n",
109+
"import dev.langchain4j.data.message.SystemMessage\n",
110+
"import dev.langchain4j.data.message.UserMessage\n",
93111
"\n",
94112
"suspend fun llmCall(\n",
95113
" prompt: String,\n",
@@ -104,10 +122,11 @@
104122
" .build()\n",
105123
"\n",
106124
" return withContext(Dispatchers.IO) {\n",
107-
" val response = client.chat {\n",
108-
" systemPrompt?.let { messages += systemMessage(it) }\n",
109-
" messages += userMessage(prompt)\n",
125+
" val messages = buildList {\n",
126+
" systemPrompt?.let { add(SystemMessage(it)) }\n",
127+
" add(UserMessage(prompt))\n",
110128
" }\n",
129+
" val response = client.chat(messages)\n",
111130
" response.aiMessage().text()\n",
112131
" }\n",
113132
"}"
@@ -127,8 +146,13 @@
127146
{
128147
"metadata": {
129148
"ExecuteTime": {
130-
"end_time": "2025-05-11T21:48:51.193436Z",
131-
"start_time": "2025-05-11T21:48:51.107695Z"
149+
"end_time": "2025-11-30T13:48:49.661604Z",
150+
"start_time": "2025-11-30T13:48:49.533742Z"
151+
},
152+
"executionRelatedData": {
153+
"compiledClasses": [
154+
"Line_9_jupyter"
155+
]
132156
}
133157
},
134158
"cell_type": "code",
@@ -165,8 +189,13 @@
165189
{
166190
"metadata": {
167191
"ExecuteTime": {
168-
"end_time": "2025-05-11T21:48:52.902515Z",
169-
"start_time": "2025-05-11T21:48:52.879801Z"
192+
"end_time": "2025-11-30T13:48:49.747609Z",
193+
"start_time": "2025-11-30T13:48:49.666371Z"
194+
},
195+
"executionRelatedData": {
196+
"compiledClasses": [
197+
"Line_10_jupyter"
198+
]
170199
}
171200
},
172201
"cell_type": "code",
@@ -221,8 +250,13 @@
221250
{
222251
"metadata": {
223252
"ExecuteTime": {
224-
"end_time": "2025-05-11T21:48:54.455677Z",
225-
"start_time": "2025-05-11T21:48:54.431018Z"
253+
"end_time": "2025-11-30T13:48:49.807284Z",
254+
"start_time": "2025-11-30T13:48:49.751656Z"
255+
},
256+
"executionRelatedData": {
257+
"compiledClasses": [
258+
"Line_11_jupyter"
259+
]
226260
}
227261
},
228262
"cell_type": "code",
@@ -251,8 +285,13 @@
251285
{
252286
"metadata": {
253287
"ExecuteTime": {
254-
"end_time": "2025-05-11T21:49:08.576050Z",
255-
"start_time": "2025-05-11T21:48:57.097290Z"
288+
"end_time": "2025-11-30T13:48:56.353802Z",
289+
"start_time": "2025-11-30T13:48:49.816409Z"
290+
},
291+
"executionRelatedData": {
292+
"compiledClasses": [
293+
"Line_12_jupyter"
294+
]
256295
}
257296
},
258297
"cell_type": "code",

notebooks/agents/Routing Workflow.ipynb

Lines changed: 70 additions & 67 deletions
Large diffs are not rendered by default.

notebooks/kinference/KIClassification.ipynb

Lines changed: 76 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,22 @@
55
"metadata": {
66
"collapsed": true,
77
"ExecuteTime": {
8-
"end_time": "2025-02-10T13:00:12.108015Z",
9-
"start_time": "2025-02-10T13:00:11.530587Z"
8+
"end_time": "2025-11-30T14:10:40.342805Z",
9+
"start_time": "2025-11-30T14:10:33.108236Z"
10+
},
11+
"executionRelatedData": {
12+
"compiledClasses": [
13+
"Line_3_jupyter",
14+
"Line_4_jupyter",
15+
"Line_5_jupyter"
16+
]
1017
}
1118
},
1219
"source": [
1320
"%use kotlin-dl\n",
1421
"\n",
15-
"val kinferenceVersion = \"0.2.26\"\n",
16-
"val ktorVersion = \"3.0.3\"\n",
22+
"val kinferenceVersion = \"0.2.27\"\n",
23+
"val ktorVersion = \"3.3.3\"\n",
1724
"\n",
1825
"USE {\n",
1926
" repositories {\n",
@@ -39,8 +46,13 @@
3946
{
4047
"metadata": {
4148
"ExecuteTime": {
42-
"end_time": "2025-02-10T13:00:12.347215Z",
43-
"start_time": "2025-02-10T13:00:12.295281Z"
49+
"end_time": "2025-11-30T14:10:40.394384Z",
50+
"start_time": "2025-11-30T14:10:40.344734Z"
51+
},
52+
"executionRelatedData": {
53+
"compiledClasses": [
54+
"Line_6_jupyter"
55+
]
4456
}
4557
},
4658
"cell_type": "code",
@@ -76,8 +88,13 @@
7688
{
7789
"metadata": {
7890
"ExecuteTime": {
79-
"end_time": "2025-02-10T13:00:34.395122Z",
80-
"start_time": "2025-02-10T13:00:34.137897Z"
91+
"end_time": "2025-11-30T14:10:40.671158Z",
92+
"start_time": "2025-11-30T14:10:40.398352Z"
93+
},
94+
"executionRelatedData": {
95+
"compiledClasses": [
96+
"Line_7_jupyter"
97+
]
8198
}
8299
},
83100
"cell_type": "code",
@@ -144,8 +161,13 @@
144161
{
145162
"metadata": {
146163
"ExecuteTime": {
147-
"end_time": "2025-02-10T13:00:42.121114Z",
148-
"start_time": "2025-02-10T13:00:42.095847Z"
164+
"end_time": "2025-11-30T14:10:40.710096Z",
165+
"start_time": "2025-11-30T14:10:40.672181Z"
166+
},
167+
"executionRelatedData": {
168+
"compiledClasses": [
169+
"Line_8_jupyter"
170+
]
149171
}
150172
},
151173
"cell_type": "code",
@@ -160,8 +182,13 @@
160182
{
161183
"metadata": {
162184
"ExecuteTime": {
163-
"end_time": "2025-02-10T13:00:48.526585Z",
164-
"start_time": "2025-02-10T13:00:48.451536Z"
185+
"end_time": "2025-11-30T14:10:40.833103Z",
186+
"start_time": "2025-11-30T14:10:40.711316Z"
187+
},
188+
"executionRelatedData": {
189+
"compiledClasses": [
190+
"Line_9_jupyter"
191+
]
165192
}
166193
},
167194
"cell_type": "code",
@@ -183,8 +210,13 @@
183210
{
184211
"metadata": {
185212
"ExecuteTime": {
186-
"end_time": "2025-02-10T13:00:53.440965Z",
187-
"start_time": "2025-02-10T13:00:52.959882Z"
213+
"end_time": "2025-11-30T14:10:41.338242Z",
214+
"start_time": "2025-11-30T14:10:40.833958Z"
215+
},
216+
"executionRelatedData": {
217+
"compiledClasses": [
218+
"Line_10_jupyter"
219+
]
188220
}
189221
},
190222
"cell_type": "code",
@@ -198,8 +230,13 @@
198230
{
199231
"metadata": {
200232
"ExecuteTime": {
201-
"end_time": "2025-02-10T13:00:58.001898Z",
202-
"start_time": "2025-02-10T13:00:57.796134Z"
233+
"end_time": "2025-11-30T14:10:41.694368Z",
234+
"start_time": "2025-11-30T14:10:41.339067Z"
235+
},
236+
"executionRelatedData": {
237+
"compiledClasses": [
238+
"Line_11_jupyter"
239+
]
203240
}
204241
},
205242
"cell_type": "code",
@@ -245,8 +282,13 @@
245282
{
246283
"metadata": {
247284
"ExecuteTime": {
248-
"end_time": "2025-02-10T13:01:04.122663Z",
249-
"start_time": "2025-02-10T13:01:04.003458Z"
285+
"end_time": "2025-11-30T14:10:41.922928Z",
286+
"start_time": "2025-11-30T14:10:41.695266Z"
287+
},
288+
"executionRelatedData": {
289+
"compiledClasses": [
290+
"Line_12_jupyter"
291+
]
250292
}
251293
},
252294
"cell_type": "code",
@@ -276,8 +318,13 @@
276318
{
277319
"metadata": {
278320
"ExecuteTime": {
279-
"end_time": "2025-02-10T13:01:20.419350Z",
280-
"start_time": "2025-02-10T13:01:20.390133Z"
321+
"end_time": "2025-11-30T14:10:41.987595Z",
322+
"start_time": "2025-11-30T14:10:41.926778Z"
323+
},
324+
"executionRelatedData": {
325+
"compiledClasses": [
326+
"Line_13_jupyter"
327+
]
281328
}
282329
},
283330
"cell_type": "code",
@@ -292,8 +339,13 @@
292339
{
293340
"metadata": {
294341
"ExecuteTime": {
295-
"end_time": "2025-02-10T13:02:55.575404Z",
296-
"start_time": "2025-02-10T13:02:41.686551Z"
342+
"end_time": "2025-11-30T14:11:04.065051Z",
343+
"start_time": "2025-11-30T14:10:41.989196Z"
344+
},
345+
"executionRelatedData": {
346+
"compiledClasses": [
347+
"Line_14_jupyter"
348+
]
297349
}
298350
},
299351
"cell_type": "code",
@@ -327,9 +379,8 @@
327379
"output_type": "stream",
328380
"text": [
329381
"Downloading model from: https://github.com/onnx/models/raw/main/validated/vision/classification/caffenet/model/caffenet-12.onnx\n",
330-
"File already exists at /Users/pavel.gorgulov/Projects/Kotlin/Kotlin-AI-Examples/notebooks/kinference/.cache/CaffeNet.onnx. Skipping download.\n",
382+
"Predefined directory doesn't exist. Creating directory at /Users/pavel.gorgulov/Projects/main_project/AI/Kotlin-AI-Examples/notebooks/kinference//.cache/.\n",
331383
"Downloading synset from: https://s3.amazonaws.com/onnx-model-zoo/synset.txt\n",
332-
"File already exists at /Users/pavel.gorgulov/Projects/Kotlin/Kotlin-AI-Examples/notebooks/kinference/.cache/synset.txt. Skipping download.\n",
333384
"Loading model...\n",
334385
"Creating inputs...\n",
335386
"Starting inference...\n",
@@ -1136,7 +1187,7 @@
11361187
]
11371188
}
11381189
],
1139-
"execution_count": 11
1190+
"execution_count": 10
11401191
}
11411192
],
11421193
"metadata": {

0 commit comments

Comments
 (0)