|
62 | 62 | },
|
63 | 63 | {
|
64 | 64 | "cell_type": "code",
|
65 |
| - "execution_count": null, |
| 65 | + "execution_count": 4, |
66 | 66 | "metadata": {},
|
67 |
| - "outputs": [], |
| 67 | + "outputs": [ |
| 68 | + { |
| 69 | + "name": "stdout", |
| 70 | + "output_type": "stream", |
| 71 | + "text": [ |
| 72 | + "Adding dependency \u001b[0m\u001b[1m\u001b[32morg.slf4j:slf4j-jdk14:2.0.9\n", |
| 73 | + "\u001b[0mAdding dependency \u001b[0m\u001b[1m\u001b[32morg.bsc.langgraph4j:langgraph4j-core:1.2-SNAPSHOT\n", |
| 74 | + "\u001b[0mAdding dependency \u001b[0m\u001b[1m\u001b[32morg.bsc.langgraph4j:langgraph4j-langchain4j:1.2-SNAPSHOT\n", |
| 75 | + "\u001b[0mAdding dependency \u001b[0m\u001b[1m\u001b[32mdev.langchain4j:langchain4j:0.36.2\n", |
| 76 | + "\u001b[0mAdding dependency \u001b[0m\u001b[1m\u001b[32mdev.langchain4j:langchain4j-open-ai:0.36.2\n", |
| 77 | + "\u001b[0mSolving dependencies\n", |
| 78 | + "Resolved artifacts count: 26\n", |
| 79 | + "Add to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/org/slf4j/slf4j-jdk14/2.0.9/slf4j-jdk14-2.0.9.jar\u001b[0m\n", |
| 80 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/org/slf4j/slf4j-api/2.0.9/slf4j-api-2.0.9.jar\u001b[0m\n", |
| 81 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/org/bsc/langgraph4j/langgraph4j-core/1.2-SNAPSHOT/langgraph4j-core-1.2-SNAPSHOT.jar\u001b[0m\n", |
| 82 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/org/bsc/async/async-generator/3.0-SNAPSHOT/async-generator-3.0-SNAPSHOT.jar\u001b[0m\n", |
| 83 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/org/bsc/langgraph4j/langgraph4j-langchain4j/1.2-SNAPSHOT/langgraph4j-langchain4j-1.2-SNAPSHOT.jar\u001b[0m\n", |
| 84 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/dev/langchain4j/langchain4j/0.36.2/langchain4j-0.36.2.jar\u001b[0m\n", |
| 85 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/dev/langchain4j/langchain4j-core/0.36.2/langchain4j-core-0.36.2.jar\u001b[0m\n", |
| 86 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/com/google/code/gson/gson/2.10.1/gson-2.10.1.jar\u001b[0m\n", |
| 87 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/org/apache/opennlp/opennlp-tools/1.9.4/opennlp-tools-1.9.4.jar\u001b[0m\n", |
| 88 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/dev/langchain4j/langchain4j-open-ai/0.36.2/langchain4j-open-ai-0.36.2.jar\u001b[0m\n", |
| 89 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/dev/ai4j/openai4j/0.23.0/openai4j-0.23.0.jar\u001b[0m\n", |
| 90 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/com/squareup/retrofit2/retrofit/2.9.0/retrofit-2.9.0.jar\u001b[0m\n", |
| 91 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/com/squareup/retrofit2/converter-jackson/2.9.0/converter-jackson-2.9.0.jar\u001b[0m\n", |
| 92 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/com/fasterxml/jackson/core/jackson-databind/2.17.2/jackson-databind-2.17.2.jar\u001b[0m\n", |
| 93 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/com/fasterxml/jackson/core/jackson-annotations/2.17.2/jackson-annotations-2.17.2.jar\u001b[0m\n", |
| 94 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/com/fasterxml/jackson/core/jackson-core/2.17.2/jackson-core-2.17.2.jar\u001b[0m\n", |
| 95 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/com/squareup/okhttp3/okhttp/4.12.0/okhttp-4.12.0.jar\u001b[0m\n", |
| 96 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/com/squareup/okio/okio/3.6.0/okio-3.6.0.jar\u001b[0m\n", |
| 97 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/com/squareup/okio/okio-jvm/3.6.0/okio-jvm-3.6.0.jar\u001b[0m\n", |
| 98 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/org/jetbrains/kotlin/kotlin-stdlib-common/1.9.10/kotlin-stdlib-common-1.9.10.jar\u001b[0m\n", |
| 99 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/com/squareup/okhttp3/okhttp-sse/4.12.0/okhttp-sse-4.12.0.jar\u001b[0m\n", |
| 100 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.9.25/kotlin-stdlib-jdk8-1.9.25.jar\u001b[0m\n", |
| 101 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/org/jetbrains/kotlin/kotlin-stdlib/1.9.25/kotlin-stdlib-1.9.25.jar\u001b[0m\n", |
| 102 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/org/jetbrains/annotations/13.0/annotations-13.0.jar\u001b[0m\n", |
| 103 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.9.25/kotlin-stdlib-jdk7-1.9.25.jar\u001b[0m\n", |
| 104 | + "\u001b[0mAdd to classpath: \u001b[0m\u001b[32m/Users/bsorrentino/Library/Jupyter/kernels/rapaio-jupyter-kernel/mima_cache/com/knuddels/jtokkit/1.1.0/jtokkit-1.1.0.jar\u001b[0m\n", |
| 105 | + "\u001b[0m" |
| 106 | + ] |
| 107 | + } |
| 108 | + ], |
68 | 109 | "source": [
|
69 | 110 | "%dependency /add org.slf4j:slf4j-jdk14:2.0.9\n",
|
70 | 111 | "%dependency /add org.bsc.langgraph4j:langgraph4j-core:\\{langgraph4jVersion}\n",
|
|
106 | 147 | },
|
107 | 148 | {
|
108 | 149 | "cell_type": "code",
|
109 |
| - "execution_count": null, |
| 150 | + "execution_count": 6, |
110 | 151 | "metadata": {},
|
111 |
| - "outputs": [], |
| 152 | + "outputs": [ |
| 153 | + { |
| 154 | + "name": "stderr", |
| 155 | + "output_type": "stream", |
| 156 | + "text": [ |
| 157 | + "StreamingOutput{chunk=} \n", |
| 158 | + "StreamingOutput{chunk=Why} \n", |
| 159 | + "StreamingOutput{chunk= did} \n", |
| 160 | + "StreamingOutput{chunk= the} \n", |
| 161 | + "StreamingOutput{chunk= scare} \n", |
| 162 | + "StreamingOutput{chunk=crow} \n", |
| 163 | + "StreamingOutput{chunk= win} \n", |
| 164 | + "StreamingOutput{chunk= an} \n", |
| 165 | + "StreamingOutput{chunk= award} \n", |
| 166 | + "StreamingOutput{chunk=?\n", |
| 167 | + "\n", |
| 168 | + "} \n", |
| 169 | + "StreamingOutput{chunk=Because} \n", |
| 170 | + "StreamingOutput{chunk= he} \n", |
| 171 | + "StreamingOutput{chunk= was} \n", |
| 172 | + "StreamingOutput{chunk= outstanding} \n", |
| 173 | + "StreamingOutput{chunk= in} \n", |
| 174 | + "StreamingOutput{chunk= his} \n", |
| 175 | + "StreamingOutput{chunk= field} \n", |
| 176 | + "StreamingOutput{chunk=!} \n", |
| 177 | + "RESULT: {content=AiMessage { text = \"Why did the scarecrow win an award?\n", |
| 178 | + "\n", |
| 179 | + "Because he was outstanding in his field!\" toolExecutionRequests = null }} \n" |
| 180 | + ] |
| 181 | + } |
| 182 | + ], |
112 | 183 | "source": [
|
113 | 184 | "import dev.langchain4j.model.StreamingResponseHandler;\n",
|
114 | 185 | "import dev.langchain4j.model.chat.StreamingChatLanguageModel;\n",
|
|
202 | 273 | },
|
203 | 274 | {
|
204 | 275 | "cell_type": "code",
|
205 |
| - "execution_count": null, |
| 276 | + "execution_count": 8, |
206 | 277 | "metadata": {},
|
207 |
| - "outputs": [], |
| 278 | + "outputs": [ |
| 279 | + { |
| 280 | + "data": { |
| 281 | + "text/plain": [ |
| 282 | + "SerializerMapper: \n", |
| 283 | + "java.util.Map\n", |
| 284 | + "java.util.Collection\n", |
| 285 | + "dev.langchain4j.agent.tool.ToolExecutionRequest\n", |
| 286 | + "dev.langchain4j.data.message.ChatMessage" |
| 287 | + ] |
| 288 | + }, |
| 289 | + "execution_count": 8, |
| 290 | + "metadata": {}, |
| 291 | + "output_type": "execute_result" |
| 292 | + } |
| 293 | + ], |
208 | 294 | "source": [
|
209 | 295 | "import dev.langchain4j.data.message.AiMessage;\n",
|
210 | 296 | "import dev.langchain4j.data.message.SystemMessage;\n",
|
|
367 | 453 | },
|
368 | 454 | {
|
369 | 455 | "cell_type": "code",
|
370 |
| - "execution_count": 15, |
| 456 | + "execution_count": 11, |
371 | 457 | "metadata": {},
|
372 | 458 | "outputs": [
|
373 | 459 | {
|
|
377 | 463 | "START \n",
|
378 | 464 | "CallModel:\n",
|
379 | 465 | "[UserMessage { name = null contents = [TextContent { text = \"what is the whether today?\" }] }] \n",
|
380 |
| - "MapResult: Response { content = AiMessage { text = null toolExecutionRequests = [ToolExecutionRequest { id = \"call_ycvEnAG6NCrreo0WqSoxS5jJ\", name = \"execQuery\", arguments = \"{\"query\":\"current weather\"}\" }] }, tokenUsage = TokenUsage { inputTokenCount = 71, outputTokenCount = 15, totalTokenCount = 86 }, finishReason = TOOL_EXECUTION, metadata = {} } \n", |
| 466 | + "MapResult: Response { content = AiMessage { text = null toolExecutionRequests = [ToolExecutionRequest { id = \"call_YszBAtYhA4nlonJG9BFogPkC\", name = \"execQuery\", arguments = \"{\"query\":\"current weather\"}\" }] }, tokenUsage = TokenUsage { inputTokenCount = 71, outputTokenCount = 15, totalTokenCount = 86 }, finishReason = TOOL_EXECUTION, metadata = {} } \n", |
381 | 467 | "routeMessage:\n",
|
382 |
| - "[AiMessage { text = null toolExecutionRequests = [ToolExecutionRequest { id = \"call_ycvEnAG6NCrreo0WqSoxS5jJ\", name = \"execQuery\", arguments = \"{\"query\":\"current weather\"}\" }] }] \n", |
| 468 | + "[AiMessage { text = null toolExecutionRequests = [ToolExecutionRequest { id = \"call_YszBAtYhA4nlonJG9BFogPkC\", name = \"execQuery\", arguments = \"{\"query\":\"current weather\"}\" }] }] \n", |
383 | 469 | "NodeOutput{node=__START__, state={messages=[UserMessage { name = null contents = [TextContent { text = \"what is the whether today?\" }] }]}} \n",
|
384 | 470 | "invokeTool:\n",
|
385 |
| - "[AiMessage { text = null toolExecutionRequests = [ToolExecutionRequest { id = \"call_ycvEnAG6NCrreo0WqSoxS5jJ\", name = \"execQuery\", arguments = \"{\"query\":\"current weather\"}\" }] }] \n", |
| 471 | + "[AiMessage { text = null toolExecutionRequests = [ToolExecutionRequest { id = \"call_YszBAtYhA4nlonJG9BFogPkC\", name = \"execQuery\", arguments = \"{\"query\":\"current weather\"}\" }] }] \n", |
386 | 472 | "execute: execQuery \n",
|
387 |
| - "NodeOutput{node=agent, state={messages=[AiMessage { text = null toolExecutionRequests = [ToolExecutionRequest { id = \"call_ycvEnAG6NCrreo0WqSoxS5jJ\", name = \"execQuery\", arguments = \"{\"query\":\"current weather\"}\" }] }]}} \n", |
| 473 | + "NodeOutput{node=agent, state={messages=[AiMessage { text = null toolExecutionRequests = [ToolExecutionRequest { id = \"call_YszBAtYhA4nlonJG9BFogPkC\", name = \"execQuery\", arguments = \"{\"query\":\"current weather\"}\" }] }]}} \n", |
388 | 474 | "CallModel:\n",
|
389 |
| - "[AiMessage { text = null toolExecutionRequests = [ToolExecutionRequest { id = \"call_ycvEnAG6NCrreo0WqSoxS5jJ\", name = \"execQuery\", arguments = \"{\"query\":\"current weather\"}\" }] }, ToolExecutionResultMessage { id = \"call_ycvEnAG6NCrreo0WqSoxS5jJ\" toolName = \"execQuery\" text = \"Cold, with a low of 13 degrees\" }] \n", |
390 |
| - "NodeOutput{node=tools, state={messages=[AiMessage { text = null toolExecutionRequests = [ToolExecutionRequest { id = \"call_ycvEnAG6NCrreo0WqSoxS5jJ\", name = \"execQuery\", arguments = \"{\"query\":\"current weather\"}\" }] }, ToolExecutionResultMessage { id = \"call_ycvEnAG6NCrreo0WqSoxS5jJ\" toolName = \"execQuery\" text = \"Cold, with a low of 13 degrees\" }]}} \n", |
| 475 | + "[AiMessage { text = null toolExecutionRequests = [ToolExecutionRequest { id = \"call_YszBAtYhA4nlonJG9BFogPkC\", name = \"execQuery\", arguments = \"{\"query\":\"current weather\"}\" }] }, ToolExecutionResultMessage { id = \"call_YszBAtYhA4nlonJG9BFogPkC\" toolName = \"execQuery\" text = \"Cold, with a low of 13 degrees\" }] \n", |
| 476 | + "NodeOutput{node=tools, state={messages=[AiMessage { text = null toolExecutionRequests = [ToolExecutionRequest { id = \"call_YszBAtYhA4nlonJG9BFogPkC\", name = \"execQuery\", arguments = \"{\"query\":\"current weather\"}\" }] }, ToolExecutionResultMessage { id = \"call_YszBAtYhA4nlonJG9BFogPkC\" toolName = \"execQuery\" text = \"Cold, with a low of 13 degrees\" }]}} \n", |
391 | 477 | "StreamingOutput{node=agent, chunk= } \n",
|
392 | 478 | "StreamingOutput{node=agent, chunk=The } \n",
|
393 | 479 | "StreamingOutput{node=agent, chunk= current } \n",
|
|
419 | 505 | "StreamingOutput{node=agent, chunk= feel } \n",
|
420 | 506 | "StreamingOutput{node=agent, chunk= free } \n",
|
421 | 507 | "StreamingOutput{node=agent, chunk= to } \n",
|
422 |
| - "StreamingOutput{node=agent, chunk= ask } \n", |
423 | 508 | "MapResult: Response { content = AiMessage { text = \"The current weather is cold, with a low of 13 degrees. If you need more specific information or details about a particular location, feel free to ask!\" toolExecutionRequests = null }, tokenUsage = TokenUsage { inputTokenCount = 93, outputTokenCount = 33, totalTokenCount = 126 }, finishReason = STOP, metadata = {} } \n",
|
| 509 | + "StreamingOutput{node=agent, chunk= ask } \n", |
424 | 510 | "routeMessage:\n",
|
425 | 511 | "[AiMessage { text = \"The current weather is cold, with a low of 13 degrees. If you need more specific information or details about a particular location, feel free to ask!\" toolExecutionRequests = null }] \n",
|
426 | 512 | "StreamingOutput{node=agent, chunk=! } \n",
|
|
0 commit comments