diff --git a/notebooks/agents/Evaluator-Optimizer Workflow.ipynb b/notebooks/agents/Evaluator-Optimizer Workflow.ipynb index 182a08e..7f9579c 100644 --- a/notebooks/agents/Evaluator-Optimizer Workflow.ipynb +++ b/notebooks/agents/Evaluator-Optimizer Workflow.ipynb @@ -38,14 +38,14 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:46:08.225938Z", - "start_time": "2025-05-11T21:46:07.295891Z" + "end_time": "2025-11-30T13:20:22.703465Z", + "start_time": "2025-11-30T13:20:15.346910Z" } }, "cell_type": "code", "source": [ "%useLatestDescriptors\n", - "%use langchain4j(1.0.0-beta3, model = anthropic)" + "%use langchain4j(model = anthropic)" ], "outputs": [], "execution_count": 1 @@ -62,8 +62,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:46:08.461594Z", - "start_time": "2025-05-11T21:46:08.229458Z" + "end_time": "2025-11-30T13:20:25.141761Z", + "start_time": "2025-11-30T13:20:24.969066Z" } }, "cell_type": "code", @@ -108,8 +108,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:46:08.637414Z", - "start_time": "2025-05-11T21:46:08.465153Z" + "end_time": "2025-11-30T13:20:28.117881Z", + "start_time": "2025-11-30T13:20:28.006636Z" } }, "cell_type": "code", @@ -139,8 +139,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:46:08.722975Z", - "start_time": "2025-05-11T21:46:08.640704Z" + "end_time": "2025-11-30T13:20:31.091545Z", + "start_time": "2025-11-30T13:20:31.004560Z" } }, "cell_type": "code", @@ -183,8 +183,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:46:08.762663Z", - "start_time": "2025-05-11T21:46:08.726240Z" + "end_time": "2025-11-30T13:20:35.601724Z", + "start_time": "2025-11-30T13:20:35.549535Z" } }, "cell_type": "code", @@ -224,8 +224,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:46:08.888126Z", - "start_time": "2025-05-11T21:46:08.765699Z" + "end_time": "2025-11-30T13:20:39.744914Z", + "start_time": "2025-11-30T13:20:39.625080Z" } }, "cell_type": "code", @@ -273,8 +273,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:46:08.918310Z", - "start_time": "2025-05-11T21:46:08.890955Z" + "end_time": "2025-11-30T13:20:41.651758Z", + "start_time": "2025-11-30T13:20:41.614141Z" } }, "cell_type": "code", @@ -335,8 +335,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:46:27.793062Z", - "start_time": "2025-05-11T21:46:08.922090Z" + "end_time": "2025-11-30T13:21:30.022737Z", + "start_time": "2025-11-30T13:20:48.034137Z" } }, "cell_type": "code", @@ -390,11 +390,11 @@ "Status:\n", "NEEDS_IMPROVEMENT\n", "Feedback:\n", - "The implementation is mostly correct but has a critical bug. When comparing elements with '==' in the pop() method, it checks for reference equality, not value equality. For non-primitive types, this could lead to incorrect behavior where a minimum value isn't removed from minStack. Should use 'equals()' or the '==' operator with proper equals() implementation. Also, using MutableList as a stack implementation is not ideal - while it works, using ArrayDeque would be more appropriate as it's designed for stack operations. Time complexity is O(1) for all operations as required.\n", + "The implementation is mostly correct but has a critical issue: using == for comparison in pop() can lead to incorrect behavior with duplicate values. If we push the same minimum value twice and then pop one, the minStack will incorrectly remove its minimum. Instead, we should compare references or track indices. Also, while mutableListOf provides amortized O(1) operations for add/removeAt from the end, it would be more idiomatic to use ArrayDeque for a stack implementation. The time complexity is O(1) for all operations as required.\n", "=== EVALUATION END ===\n", "=== GENERATION START ===\n", "Thoughts:\n", - "The previous implementation had a critical bug with equality comparison in the pop() method. I'll fix this by using equals() for comparison. I'll also switch from MutableList to ArrayDeque which is more appropriate for stack operations. I'll maintain the O(1) time complexity for all operations by keeping a separate min stack that tracks the minimum values.\n", + "The previous implementation had a critical issue with handling duplicate minimum values. When popping an element that equals the current minimum, we incorrectly removed the minimum from minStack even if there were other instances of that minimum value still in the main stack. I'll fix this by using ArrayDeque for better stack semantics and properly handling duplicates by pushing the current minimum to minStack with every push operation, ensuring we always have the correct minimum after any pop operation.\n", "Result:\n", "class MinStack> {\n", " private val mainStack = ArrayDeque()\n", @@ -403,33 +403,173 @@ " fun push(x: T) {\n", " mainStack.addLast(x)\n", " \n", - " // If minStack is empty or x is smaller than or equal to current min, add x to minStack\n", + " // If minStack is empty or x is smaller/equal to current min, add x to minStack\n", " if (minStack.isEmpty() || x <= minStack.last()) {\n", " minStack.addLast(x)\n", + " } else {\n", + " // Otherwise duplicate the current minimum\n", + " minStack.addLast(minStack.last())\n", " }\n", " }\n", " \n", " fun pop(): T? {\n", " if (mainStack.isEmpty()) return null\n", " \n", + " // Always remove from minStack when popping from mainStack\n", + " minStack.removeLast()\n", + " return mainStack.removeLast()\n", + " }\n", + " \n", + " fun getMin(): T? {\n", + " if (minStack.isEmpty()) return null\n", + " return minStack.last()\n", + " }\n", + " \n", + " fun isEmpty(): Boolean = mainStack.isEmpty()\n", + " \n", + " fun size(): Int = mainStack.size\n", + "}\n", + "=== GENERATION END ===\n", + "=== EVALUATION START ===\n", + "Status:\n", + "NEEDS_IMPROVEMENT\n", + "Feedback:\n", + "The implementation is mostly correct but has an inefficiency in the minStack approach. Currently, minStack duplicates values unnecessarily by adding the current minimum even when the new value is greater than the minimum. This wastes space. A better approach would be to only push to minStack when a new value is less than or equal to the current minimum. The time complexity is O(1) for all operations as required. Also, the code could benefit from adding proper documentation and potentially handling edge cases like checking if the stack is empty before operations.\n", + "=== EVALUATION END ===\n", + "=== GENERATION START ===\n", + "Thoughts:\n", + "The feedback points out that my previous implementation was inefficient by duplicating values in the minStack unnecessarily. I should only add values to minStack when they are less than or equal to the current minimum. I'll also add proper documentation and handle edge cases properly.\n", + "Result:\n", + "/**\n", + " * A stack implementation that supports constant time minimum value retrieval.\n", + " * @param T The type of elements stored in the stack, must be comparable.\n", + " */\n", + "class MinStack> {\n", + " private val mainStack = ArrayDeque()\n", + " private val minStack = ArrayDeque()\n", + " \n", + " /**\n", + " * Pushes an element onto the stack.\n", + " * @param x The element to push\n", + " */\n", + " fun push(x: T) {\n", + " mainStack.addLast(x)\n", + " \n", + " // Only add to minStack if it's empty or x is less than or equal to current min\n", + " if (minStack.isEmpty() || x <= minStack.last()) {\n", + " minStack.addLast(x)\n", + " }\n", + " }\n", + " \n", + " /**\n", + " * Removes and returns the top element from the stack.\n", + " * @return The top element, or null if the stack is empty\n", + " */\n", + " fun pop(): T? {\n", + " if (mainStack.isEmpty()) return null\n", + " \n", " val popped = mainStack.removeLast()\n", " \n", - " // If popped element equals the current minimum, remove from minStack too\n", - " // Using equals() for proper value equality\n", - " if (popped.equals(minStack.last())) {\n", + " // If popped element is the current minimum, remove from minStack too\n", + " if (popped == minStack.last()) {\n", " minStack.removeLast()\n", " }\n", " \n", " return popped\n", " }\n", " \n", + " /**\n", + " * Returns the minimum element in the stack without removing it.\n", + " * @return The minimum element, or null if the stack is empty\n", + " */\n", " fun getMin(): T? {\n", " if (minStack.isEmpty()) return null\n", " return minStack.last()\n", " }\n", " \n", + " /**\n", + " * Checks if the stack is empty.\n", + " * @return true if the stack is empty, false otherwise\n", + " */\n", + " fun isEmpty(): Boolean = mainStack.isEmpty()\n", + " \n", + " /**\n", + " * Returns the number of elements in the stack.\n", + " * @return The size of the stack\n", + " */\n", + " fun size(): Int = mainStack.size\n", + "}\n", + "=== GENERATION END ===\n", + "=== EVALUATION START ===\n", + "Status:\n", + "NEEDS_IMPROVEMENT\n", + "Feedback:\n", + "The implementation is mostly correct and achieves O(1) time complexity for all operations. However, there's a potential bug in the pop() method. When comparing popped == minStack.last(), it uses reference equality which may not work correctly for all types. For value types or custom classes, this could fail even when the values are equal. A safer approach would be to use compareTo() == 0 or equals() method. Additionally, the code could be improved by throwing an exception for pop() and getMin() when the stack is empty instead of returning null, which would be more consistent with standard stack implementations.\n", + "=== EVALUATION END ===\n", + "=== GENERATION START ===\n", + "Thoughts:\n", + "The previous implementation had a potential bug with reference equality in the pop() method. I'll fix this by using equals() for comparison. I'll also improve error handling by throwing exceptions for empty stack operations instead of returning null, which is more consistent with standard stack implementations.\n", + "Result:\n", + "/**\n", + " * A stack implementation that supports constant time minimum value retrieval.\n", + " * @param T The type of elements stored in the stack, must be comparable.\n", + " */\n", + "class MinStack> {\n", + " private val mainStack = ArrayDeque()\n", + " private val minStack = ArrayDeque()\n", + " \n", + " /**\n", + " * Pushes an element onto the stack.\n", + " * @param x The element to push\n", + " */\n", + " fun push(x: T) {\n", + " mainStack.addLast(x)\n", + " \n", + " // Only add to minStack if it's empty or x is less than or equal to current min\n", + " if (minStack.isEmpty() || x.compareTo(minStack.last()) <= 0) {\n", + " minStack.addLast(x)\n", + " }\n", + " }\n", + " \n", + " /**\n", + " * Removes and returns the top element from the stack.\n", + " * @return The top element\n", + " * @throws NoSuchElementException if the stack is empty\n", + " */\n", + " fun pop(): T {\n", + " if (mainStack.isEmpty()) throw NoSuchElementException(\"Cannot pop from an empty stack\")\n", + " \n", + " val popped = mainStack.removeLast()\n", + " \n", + " // If popped element is the current minimum, remove from minStack too\n", + " // Using equals() for proper value comparison\n", + " if (popped.equals(minStack.last())) {\n", + " minStack.removeLast()\n", + " }\n", + " \n", + " return popped\n", + " }\n", + " \n", + " /**\n", + " * Returns the minimum element in the stack without removing it.\n", + " * @return The minimum element\n", + " * @throws NoSuchElementException if the stack is empty\n", + " */\n", + " fun getMin(): T {\n", + " if (minStack.isEmpty()) throw NoSuchElementException(\"Cannot get minimum from an empty stack\")\n", + " return minStack.last()\n", + " }\n", + " \n", + " /**\n", + " * Checks if the stack is empty.\n", + " * @return true if the stack is empty, false otherwise\n", + " */\n", " fun isEmpty(): Boolean = mainStack.isEmpty()\n", " \n", + " /**\n", + " * Returns the number of elements in the stack.\n", + " * @return The size of the stack\n", + " */\n", " fun size(): Int = mainStack.size\n", "}\n", "=== GENERATION END ===\n", @@ -437,33 +577,46 @@ "Status:\n", "PASS\n", "Feedback:\n", - "The implementation correctly uses two stacks to maintain the minimum value in O(1) time. The push, pop, and getMin operations all have O(1) time complexity as required. The code is well-structured, handles edge cases properly, and follows Kotlin best practices with clear naming and appropriate use of language features. The implementation also includes helpful additional methods like isEmpty() and size().\n", + "The implementation correctly maintains a stack with O(1) operations for push, pop, and getMin. It uses two stacks: one for the main elements and another to track minimums. The code is well-documented with proper exception handling, and follows Kotlin best practices. The implementation handles edge cases appropriately and uses proper comparisons for determining minimums.\n", "=== EVALUATION END ===\n" ] }, { "data": { "text/plain": [ - "(class MinStack> {\n", + "(/**\n", + " * A stack implementation that supports constant time minimum value retrieval.\n", + " * @param T The type of elements stored in the stack, must be comparable.\n", + " */\n", + "class MinStack> {\n", " private val mainStack = ArrayDeque()\n", " private val minStack = ArrayDeque()\n", " \n", + " /**\n", + " * Pushes an element onto the stack.\n", + " * @param x The element to push\n", + " */\n", " fun push(x: T) {\n", " mainStack.addLast(x)\n", " \n", - " // If minStack is empty or x is smaller than or equal to current min, add x to minStack\n", - " if (minStack.isEmpty() || x <= minStack.last()) {\n", + " // Only add to minStack if it's empty or x is less than or equal to current min\n", + " if (minStack.isEmpty() || x.compareTo(minStack.last()) <= 0) {\n", " minStack.addLast(x)\n", " }\n", " }\n", " \n", - " fun pop(): T? {\n", - " if (mainStack.isEmpty()) return null\n", + " /**\n", + " * Removes and returns the top element from the stack.\n", + " * @return The top element\n", + " * @throws NoSuchElementException if the stack is empty\n", + " */\n", + " fun pop(): T {\n", + " if (mainStack.isEmpty()) throw NoSuchElementException(\"Cannot pop from an empty stack\")\n", " \n", " val popped = mainStack.removeLast()\n", " \n", - " // If popped element equals the current minimum, remove from minStack too\n", - " // Using equals() for proper value equality\n", + " // If popped element is the current minimum, remove from minStack too\n", + " // Using equals() for proper value comparison\n", " if (popped.equals(minStack.last())) {\n", " minStack.removeLast()\n", " }\n", @@ -471,13 +624,26 @@ " return popped\n", " }\n", " \n", - " fun getMin(): T? {\n", - " if (minStack.isEmpty()) return null\n", + " /**\n", + " * Returns the minimum element in the stack without removing it.\n", + " * @return The minimum element\n", + " * @throws NoSuchElementException if the stack is empty\n", + " */\n", + " fun getMin(): T {\n", + " if (minStack.isEmpty()) throw NoSuchElementException(\"Cannot get minimum from an empty stack\")\n", " return minStack.last()\n", " }\n", " \n", + " /**\n", + " * Checks if the stack is empty.\n", + " * @return true if the stack is empty, false otherwise\n", + " */\n", " fun isEmpty(): Boolean = mainStack.isEmpty()\n", " \n", + " /**\n", + " * Returns the number of elements in the stack.\n", + " * @return The size of the stack\n", + " */\n", " fun size(): Int = mainStack.size\n", "}, [(I need to implement a Stack in Kotlin with push, pop, and getMin operations, all with O(1) time complexity. For push and pop, a standard stack implementation will work. For getMin with O(1), I'll need to maintain a second stack that keeps track of the minimum values. Each time we push a value, we'll compare it with the current minimum and push the smaller one to the minStack. When we pop, we'll also pop from the minStack., class MinStack> {\n", " private val mainStack = mutableListOf()\n", @@ -513,40 +679,156 @@ " fun isEmpty(): Boolean = mainStack.isEmpty()\n", " \n", " fun size(): Int = mainStack.size\n", - "}), (The previous implementation had a critical bug with equality comparison in the pop() method. I'll fix this by using equals() for comparison. I'll also switch from MutableList to ArrayDeque which is more appropriate for stack operations. I'll maintain the O(1) time complexity for all operations by keeping a separate min stack that tracks the minimum values., class MinStack> {\n", + "}), (The previous implementation had a critical issue with handling duplicate minimum values. When popping an element that equals the current minimum, we incorrectly removed the minimum from minStack even if there were other instances of that minimum value still in the main stack. I'll fix this by using ArrayDeque for better stack semantics and properly handling duplicates by pushing the current minimum to minStack with every push operation, ensuring we always have the correct minimum after any pop operation., class MinStack> {\n", + " private val mainStack = ArrayDeque()\n", + " private val minStack = ArrayDeque()\n", + " \n", + " fun push(x: T) {\n", + " mainStack.addLast(x)\n", + " \n", + " // If minStack is empty or x is smaller/equal to current min, add x to minStack\n", + " if (minStack.isEmpty() || x <= minStack.last()) {\n", + " minStack.addLast(x)\n", + " } else {\n", + " // Otherwise duplicate the current minimum\n", + " minStack.addLast(minStack.last())\n", + " }\n", + " }\n", + " \n", + " fun pop(): T? {\n", + " if (mainStack.isEmpty()) return null\n", + " \n", + " // Always remove from minStack when popping from mainStack\n", + " minStack.removeLast()\n", + " return mainStack.removeLast()\n", + " }\n", + " \n", + " fun getMin(): T? {\n", + " if (minStack.isEmpty()) return null\n", + " return minStack.last()\n", + " }\n", + " \n", + " fun isEmpty(): Boolean = mainStack.isEmpty()\n", + " \n", + " fun size(): Int = mainStack.size\n", + "}), (The feedback points out that my previous implementation was inefficient by duplicating values in the minStack unnecessarily. I should only add values to minStack when they are less than or equal to the current minimum. I'll also add proper documentation and handle edge cases properly., /**\n", + " * A stack implementation that supports constant time minimum value retrieval.\n", + " * @param T The type of elements stored in the stack, must be comparable.\n", + " */\n", + "class MinStack> {\n", " private val mainStack = ArrayDeque()\n", " private val minStack = ArrayDeque()\n", " \n", + " /**\n", + " * Pushes an element onto the stack.\n", + " * @param x The element to push\n", + " */\n", " fun push(x: T) {\n", " mainStack.addLast(x)\n", " \n", - " // If minStack is empty or x is smaller than or equal to current min, add x to minStack\n", + " // Only add to minStack if it's empty or x is less than or equal to current min\n", " if (minStack.isEmpty() || x <= minStack.last()) {\n", " minStack.addLast(x)\n", " }\n", " }\n", " \n", + " /**\n", + " * Removes and returns the top element from the stack.\n", + " * @return The top element, or null if the stack is empty\n", + " */\n", " fun pop(): T? {\n", " if (mainStack.isEmpty()) return null\n", " \n", " val popped = mainStack.removeLast()\n", " \n", - " // If popped element equals the current minimum, remove from minStack too\n", - " // Using equals() for proper value equality\n", - " if (popped.equals(minStack.last())) {\n", + " // If popped element is the current minimum, remove from minStack too\n", + " if (popped == minStack.last()) {\n", " minStack.removeLast()\n", " }\n", " \n", " return popped\n", " }\n", " \n", + " /**\n", + " * Returns the minimum element in the stack without removing it.\n", + " * @return The minimum element, or null if the stack is empty\n", + " */\n", " fun getMin(): T? {\n", " if (minStack.isEmpty()) return null\n", " return minStack.last()\n", " }\n", " \n", + " /**\n", + " * Checks if the stack is empty.\n", + " * @return true if the stack is empty, false otherwise\n", + " */\n", + " fun isEmpty(): Boolean = mainStack.isEmpty()\n", + " \n", + " /**\n", + " * Returns the number of elements in the stack.\n", + " * @return The size of the stack\n", + " */\n", + " fun size(): Int = mainStack.size\n", + "}), (The previous implementation had a potential bug with reference equality in the pop() method. I'll fix this by using equals() for comparison. I'll also improve error handling by throwing exceptions for empty stack operations instead of returning null, which is more consistent with standard stack implementations., /**\n", + " * A stack implementation that supports constant time minimum value retrieval.\n", + " * @param T The type of elements stored in the stack, must be comparable.\n", + " */\n", + "class MinStack> {\n", + " private val mainStack = ArrayDeque()\n", + " private val minStack = ArrayDeque()\n", + " \n", + " /**\n", + " * Pushes an element onto the stack.\n", + " * @param x The element to push\n", + " */\n", + " fun push(x: T) {\n", + " mainStack.addLast(x)\n", + " \n", + " // Only add to minStack if it's empty or x is less than or equal to current min\n", + " if (minStack.isEmpty() || x.compareTo(minStack.last()) <= 0) {\n", + " minStack.addLast(x)\n", + " }\n", + " }\n", + " \n", + " /**\n", + " * Removes and returns the top element from the stack.\n", + " * @return The top element\n", + " * @throws NoSuchElementException if the stack is empty\n", + " */\n", + " fun pop(): T {\n", + " if (mainStack.isEmpty()) throw NoSuchElementException(\"Cannot pop from an empty stack\")\n", + " \n", + " val popped = mainStack.removeLast()\n", + " \n", + " // If popped element is the current minimum, remove from minStack too\n", + " // Using equals() for proper value comparison\n", + " if (popped.equals(minStack.last())) {\n", + " minStack.removeLast()\n", + " }\n", + " \n", + " return popped\n", + " }\n", + " \n", + " /**\n", + " * Returns the minimum element in the stack without removing it.\n", + " * @return The minimum element\n", + " * @throws NoSuchElementException if the stack is empty\n", + " */\n", + " fun getMin(): T {\n", + " if (minStack.isEmpty()) throw NoSuchElementException(\"Cannot get minimum from an empty stack\")\n", + " return minStack.last()\n", + " }\n", + " \n", + " /**\n", + " * Checks if the stack is empty.\n", + " * @return true if the stack is empty, false otherwise\n", + " */\n", " fun isEmpty(): Boolean = mainStack.isEmpty()\n", " \n", + " /**\n", + " * Returns the number of elements in the stack.\n", + " * @return The size of the stack\n", + " */\n", " fun size(): Int = mainStack.size\n", "})])" ] diff --git a/notebooks/agents/Orchestrator-Workers Workflow.ipynb b/notebooks/agents/Orchestrator-Workers Workflow.ipynb index 45dc645..a6a3f2d 100644 --- a/notebooks/agents/Orchestrator-Workers Workflow.ipynb +++ b/notebooks/agents/Orchestrator-Workers Workflow.ipynb @@ -39,14 +39,21 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:47:01.734751Z", - "start_time": "2025-05-11T21:47:00.839831Z" + "end_time": "2025-11-30T13:23:14.433039Z", + "start_time": "2025-11-30T13:23:13.930257Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_3_jupyter", + "Line_4_jupyter", + "Line_5_jupyter" + ] } }, "cell_type": "code", "source": [ "%useLatestDescriptors\n", - "%use langchain4j(1.0.0-beta3, anthropic)" + "%use langchain4j(model = anthropic)" ], "outputs": [], "execution_count": 1 @@ -63,8 +70,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:47:01.912515Z", - "start_time": "2025-05-11T21:47:01.738581Z" + "end_time": "2025-11-30T13:23:16.383683Z", + "start_time": "2025-11-30T13:23:16.197937Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_6_jupyter" + ] } }, "cell_type": "code", @@ -117,8 +129,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:47:03.013384Z", - "start_time": "2025-05-11T21:47:02.994335Z" + "end_time": "2025-11-30T13:23:18.373589Z", + "start_time": "2025-11-30T13:23:18.342053Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_7_jupyter" + ] } }, "cell_type": "code", @@ -143,8 +160,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:47:05.762011Z", - "start_time": "2025-05-11T21:47:05.524958Z" + "end_time": "2025-11-30T13:23:21.791474Z", + "start_time": "2025-11-30T13:23:21.565645Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_8_jupyter" + ] } }, "cell_type": "code", @@ -246,8 +268,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:47:14.202741Z", - "start_time": "2025-05-11T21:47:14.089018Z" + "end_time": "2025-11-30T13:23:23.273277Z", + "start_time": "2025-11-30T13:23:23.221449Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_9_jupyter" + ] } }, "cell_type": "code", @@ -274,8 +301,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:47:58.673564Z", - "start_time": "2025-05-11T21:47:17.387443Z" + "end_time": "2025-11-30T13:24:05.854363Z", + "start_time": "2025-11-30T13:23:25.094039Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_10_jupyter" + ] } }, "cell_type": "code", @@ -291,103 +323,84 @@ "output_type": "stream", "text": [ "=== ORCHESTRATOR OUTPUT ===\n", - "ANALYSIS: This task requires creating a product description for an eco-friendly water bottle. The key challenge is to effectively communicate both the functional benefits (durability, capacity, materials) and emotional benefits (environmental impact, lifestyle alignment) of the product. Different approaches would be valuable to address various customer segments and marketing contexts. Some customers may prioritize technical specifications and environmental credentials, while others might be more motivated by lifestyle benefits and emotional appeals. A comprehensive product description strategy should consider these different angles.\n", + "ANALYSIS: This task requires creating a product description for an eco-friendly water bottle. The key challenge is to effectively communicate both the functional benefits (durability, capacity, materials) and emotional benefits (environmental impact, lifestyle alignment) of the product. Different approaches would be valuable to address various customer segments and marketing contexts. Some customers may prioritize technical specifications and environmental credentials, while others might be more motivated by lifestyle benefits and emotional appeals.\n", "\n", - "TASKS: [Task(type=technical-environmental, description=Create a specification-focused description highlighting the bottle's eco-friendly materials, manufacturing process, technical features, and quantifiable environmental impact (e.g., plastic waste reduction metrics)), Task(type=lifestyle-emotional, description=Develop a benefits-oriented description emphasizing how the bottle enhances the customer's daily life, aligns with sustainable values, and makes them feel part of an environmental movement), Task(type=comparative-educational, description=Craft a description that contrasts the eco-bottle with conventional alternatives, educating consumers about environmental issues while positioning this product as a practical solution)]\n", + "TASKS: [Task(type=technical-environmental, description=Create a specification-focused description highlighting the bottle's eco-friendly materials, manufacturing process, and technical features with precise measurements and environmental impact data), Task(type=lifestyle-benefits, description=Develop a benefits-oriented description emphasizing how the bottle enhances the user's daily life while supporting their environmental values through storytelling and relatable scenarios), Task(type=comparative-persuasive, description=Craft a persuasive description that subtly contrasts this eco-friendly bottle with conventional alternatives, emphasizing unique selling points and addressing potential objections about convenience or price)]\n", " === WORKER RESULT (technical-environmental) ===\n", - " # AQUATERRA PRO-SUSTAIN™ HYDRATION VESSEL\n", - "\n", - "## Technical Specifications\n", + " # AQUA-SUSTAIN PRO: Advanced Eco-Conscious Hydration System\n", "\n", - "The AquaTerra Pro-Sustain™ represents the culmination of advanced materials science and environmental engineering, delivering a hydration solution with minimal ecological footprint and maximum functional performance.\n", + "## TECHNICAL SPECIFICATIONS\n", "\n", - "**Material Composition:**\n", - "- Primary vessel: 304-grade recycled stainless steel (87% post-industrial recycled content)\n", - "- Interior lining: Non-leaching, BPA/BPS/phthalate-free silicone membrane (0.5mm thickness)\n", - "- Thermal insulation: Vacuum-sealed double-wall construction with proprietary AeroBarrier™ technology\n", - "- Exterior coating: Water-based, VOC-free ceramic polymer (≤0.01g/L VOC emissions)\n", + "**Composition:** Constructed from 100% post-consumer recycled stainless steel (grade 304/18-8), containing 0% BPA, phthalates, or microplastics. Interior features proprietary SilicaShield™ coating (food-grade, non-leaching).\n", "\n", - "**Performance Metrics:**\n", - "- Thermal retention: Maintains liquid temperature within ±2°C for 24 hours (hot) and 36 hours (cold)\n", - "- Capacity: 750ml ±15ml\n", - "- Weight: 310g (unfilled)\n", - "- Durability rating: Tested to withstand 1,500+ drop cycles from 1.5m height\n", + "**Capacity:** 750ml (25.36 oz) with precision volume markings at 250ml increments\n", "\n", - "## Sustainable Manufacturing Protocol\n", + "**Dimensions:** 270mm height × 73mm diameter (10.63\" × 2.87\")\n", + "**Weight:** 312g (11 oz) empty\n", + "**Wall Thickness:** 1.2mm double-walled vacuum insulation\n", "\n", - "The Pro-Sustain™ is manufactured using our closed-loop production system, which achieves:\n", - "- 93% reduction in water consumption compared to industry standards\n", - "- Energy sourced from 100% renewable inputs (wind/solar grid integration)\n", - "- Carbon-neutral manufacturing certified by Environmental Carbon Offset Alliance\n", - "- Zero landfill waste production facility (ISO 14001:2015 certified)\n", + "**Thermal Performance:**\n", + "- Hot retention: Maintains liquids above 60°C (140°F) for 12 hours\n", + "- Cold retention: Maintains liquids below 7°C (45°F) for 24 hours\n", + "- Condensation-free exterior in ambient temperatures 5-35°C\n", "\n", - "## Environmental Impact Assessment\n", + "## ENVIRONMENTAL IMPACT METRICS\n", "\n", - "**Quantifiable Benefits:**\n", - "- Eliminates approximately 167 single-use plastic bottles per user annually\n", - "- Reduces carbon footprint by 61.2kg CO₂e per year compared to disposable alternatives\n", - "- Lifecycle analysis confirms 97.8% recyclability at end-of-life\n", - "- Biodegradable packaging prevents 0.5kg of landfill waste per unit\n", + "**Carbon Footprint:** 4.2kg CO₂e (cradle-to-gate), representing a 73% reduction compared to conventional single-use plastic bottles over projected 5-year lifespan\n", "\n", - "**Resource Conservation:**\n", - "- Each vessel diverts 0.73kg of virgin steel from extraction\n", - "- Manufacturing process uses 78% less water than conventional bottle production\n", - "- Reduces petroleum consumption by 2.1L per unit compared to plastic bottle alternatives\n", + "**Water Conservation:** Manufacturing process utilizes closed-loop water recycling system, consuming 87% less freshwater than industry standard (2.3L vs 17.8L per unit)\n", "\n", - "## Technical Sustainability Features\n", + "**End-of-Life:** 98.7% recyclable by mass. Disassembly design allows for component separation without specialized tools. Eligible for manufacturer take-back program with 15% discount on replacement purchase.\n", "\n", - "The Pro-Sustain™ incorporates our patented EcoTrack™ QR identification system, allowing users to monitor their personal environmental impact metrics through our companion application. The digital platform quantifies plastic waste reduction, carbon offset, and water conservation achievements based on individual usage patterns.\n", + "## SUSTAINABLE MANUFACTURING\n", "\n", - "*AquaTerra is a certified B-Corporation committed to environmental transparency and third-party verification of all sustainability claims.*\n", - " === WORKER RESULT (lifestyle-emotional) ===\n", - " # Hydro Harmony: Where Your Lifestyle Meets Sustainability\n", + "The Aqua-Sustain Pro is produced in our ISO 14001-certified facility powered by 100% renewable energy (83% solar, 17% wind). Our precision CNC machining process generates minimal waste material (≤0.5% by weight), which is fully recaptured and reintegrated into production.\n", "\n", - "Imagine cradling more than just water in your hands. With the Hydro Harmony eco-friendly water bottle, you're holding a promise – to yourself and to our planet.\n", + "Each unit undergoes 16-point quality assurance testing, including pressure testing at 1.5× rated capacity and accelerated thermal cycling (500 cycles from -20°C to 100°C) to ensure durability that prevents premature disposal.\n", "\n", - "**Transform Your Daily Hydration Into An Act Of Purpose**\n", + "## QUANTIFIABLE IMPACT\n", "\n", - "Every sip becomes a statement when it flows from your Hydro Harmony. Crafted from plant-based materials that feel luxuriously smooth against your lips, this isn't just a water bottle – it's your constant companion in a life lived intentionally. The subtle matte finish catches the light as you reach for hydration during your morning yoga, while its thoughtful design fits perfectly in your car's cupholder during your commute.\n", + "One Aqua-Sustain Pro replaces approximately 1,825 single-use plastic bottles annually, preventing 31.2kg of plastic waste and reducing petroleum consumption by 14.6L per year. The carbon investment is offset after just 47 days of regular use compared to disposable alternatives.\n", "\n", - "**Join A Movement With Every Moment**\n", + "*Certified by the Environmental Product Declaration (EPD) System and Carbon Trust. Meets or exceeds standards for NSF/ANSI 51, California Prop 65, and EU Directive 2011/65/EU (RoHS).*\n", + " === WORKER RESULT (lifestyle-benefits) ===\n", + " # Stay Hydrated, Stay Conscious: The EcoFlow Water Bottle\n", "\n", - "Feel that gentle wave of satisfaction knowing that your everyday choice diverts plastic from our oceans. Each Hydro Harmony bottle prevents approximately 167 single-use plastic bottles from entering landfills yearly. When you carry it into your meeting or place it beside you at the café, you silently inspire others to question their own habits.\n", + "Imagine starting your morning hike, the sun just beginning to warm the trail ahead. You reach for your EcoFlow bottle, its cool surface condensing slightly in your hand. That first sip of crisp, clean water tastes exactly as it should—pure and refreshing, without the metallic hint or plastic aftertaste you've experienced with other bottles.\n", "\n", - "**Align Your Actions With Your Values**\n", + "**Your day flows better when your hydration does.** The EcoFlow's intuitive design means you're drinking more water throughout your day—at your desk, during your commute, or between meetings. The leak-proof seal has saved your laptop and important documents countless times, while the one-handed opening mechanism means you can stay hydrated even while multitasking.\n", "\n", - "We understand the weight of living authentically in today's world. Your Hydro Harmony doesn't just hold your favorite beverages – it holds your integrity. The double-wall insulation keeps your cold drinks refreshing for 24 hours and hot beverages comforting for 12, ensuring that your commitment to sustainability never means compromising on life's simple pleasures.\n", + "When colleagues comment on your stylish bottle, you can't help but share that it's made from reclaimed ocean plastic—each EcoFlow prevents approximately 80 single-use plastic bottles from entering our waterways. That coffee shop barista who always compliments your bottle? They now fill it with water for free, part of our growing network of refill partners supporting the #RefillRevolution.\n", "\n", - "**Feel The Difference Beyond The Physical**\n", + "The insulation technology keeps your morning tea warm during your entire commute and your afternoon water ice-cold even after sitting in a sun-soaked car. Those little moments of satisfaction—a perfectly chilled drink after your workout or hot tea while working in a chilly office—add up to a day that feels more intentional, more cared for.\n", "\n", - "There's an unmistakable peace that comes from knowing your daily choices create ripples of positive change. With every refill, you're not just quenching your thirst – you're nourishing your spirit with the knowledge that you're part of something bigger than yourself.\n", + "At night, as you place your EcoFlow on your nightstand, there's a quiet satisfaction knowing your daily choices align with your values. Every sip is a small reminder that living sustainably doesn't mean sacrificing convenience or style—it simply means choosing better.\n", "\n", - "Hydro Harmony: Drink deeply from life while leaving only footprints of change.\n", - " === WORKER RESULT (comparative-educational) ===\n", - " # The EcoFlow Hydration Vessel: A Sustainable Revolution in Personal Hydration\n", + "**EcoFlow: Hydration that honors your body and our planet.**\n", + " === WORKER RESULT (comparative-persuasive) ===\n", + " # AquaEarth: The Water Bottle That Loves the Planet as Much as You Do\n", "\n", - "In a world where over 1 million plastic bottles are purchased every minute—with the vast majority destined for landfills or oceans—the EcoFlow Hydration Vessel emerges as not merely another water bottle, but a conscious choice for environmental stewardship.\n", + "**Why settle for ordinary when you can sip sustainably?**\n", "\n", - "## Beyond Conventional Bottles: A Comparative Analysis\n", + "Unlike conventional plastic bottles that linger in our landfills for centuries, the AquaEarth water bottle transforms your daily hydration into an act of environmental stewardship. Crafted from 100% biodegradable plant-based materials, this innovative bottle breaks down naturally within 5 years—compared to the 450+ years required for standard plastic bottles.\n", "\n", - "### Material Composition\n", - "While traditional plastic water bottles utilize petroleum-based polymers that persist in our environment for up to 450 years, the EcoFlow is crafted from plant-derived biopolymers that naturally decompose within 3-5 years if accidentally discarded. Unlike stainless steel alternatives that require intensive mining and manufacturing processes, our biopolymer production generates 74% less carbon emissions during manufacturing.\n", + "**Superior by design, not just by mission**\n", "\n", - "### Thermal Performance\n", - "Conventional insulated bottles often rely on manufacturing processes involving harmful chemicals and adhesives. The EcoFlow's double-wall vacuum insulation maintains your beverage's temperature (hot for 12 hours, cold for 24 hours) while utilizing non-toxic, food-grade materials throughout—eliminating the leaching concerns associated with both plastic and certain metal containers.\n", + "While traditional reusable bottles often sacrifice style for sustainability or leak resistance for eco-credentials, AquaEarth refuses such compromises. Our proprietary leak-proof seal technology outperforms leading metal and plastic alternatives in temperature retention tests, keeping your beverages cold for 24 hours or hot for 12—approximately 30% longer than comparable products.\n", "\n", - "### Economic Implications\n", - "The average American spends approximately $260 annually on disposable water bottles. Though the EcoFlow's initial investment of $35 exceeds a single plastic bottle purchase, its 5-year warranty period translates to potential savings exceeding $1,200 while preventing approximately 1,825 plastic bottles from entering the waste stream.\n", + "**Yes, convenience can be conscious**\n", "\n", - "## Educational Impact: Understanding Your Choice\n", + "Some might wonder if eco-friendly means high-maintenance. Not with AquaEarth. Unlike stainless steel options that require special cleaning tools or develop lingering odors, our bottle is dishwasher safe and naturally resistant to bacterial growth. The ergonomic design fits standard cup holders—something bulkier \"eco\" alternatives often overlook.\n", "\n", - "Each EcoFlow purchase diverts approximately 2.3 kg of plastic from production annually. When multiplied across our user community, this represents a significant reduction in microplastic pollution—particles now found in 94% of tap water samples worldwide and linked to concerning health implications.\n", + "**Investment, not expense**\n", "\n", - "The bottle's manufacturing process utilizes 100% renewable energy, closed-loop water systems, and carbon offset programs—creating a truly circular product that educates through example rather than merely through marketing claims.\n", + "At $32.99, AquaEarth costs slightly more upfront than basic reusables. However, our bottles outlast conventional options by an average of 3 years, making the per-use cost significantly lower. Plus, each purchase funds the removal of 25 plastic bottles from oceans—making your hydration habit part of the solution, not the problem.\n", "\n", - "## Practical Functionality Meets Environmental Responsibility\n", + "**Make the switch that makes a difference**\n", "\n", - "The EcoFlow doesn't ask you to compromise convenience for conscience. Its ergonomic design, leak-proof seal, wide-mouth opening for easy cleaning, and compatibility with standard cup holders ensure that sustainable hydration integrates seamlessly into your daily routine.\n", + "When you choose AquaEarth, you're not just buying another water bottle—you're making a statement that convenience doesn't have to come at the planet's expense. Join the thousands who have already prevented over 1.2 million plastic bottles from entering our ecosystems this year alone.\n", "\n", - "By choosing the EcoFlow, you're not simply purchasing a water vessel—you're participating in an educational journey that transforms routine hydration into a daily act of environmental stewardship.\n" + "Hydrate responsibly. Choose AquaEarth.\n" ] } ], diff --git a/notebooks/agents/Parallelization Workflow.ipynb b/notebooks/agents/Parallelization Workflow.ipynb index f4e741e..e018f85 100644 --- a/notebooks/agents/Parallelization Workflow.ipynb +++ b/notebooks/agents/Parallelization Workflow.ipynb @@ -31,15 +31,23 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:47:53.278409Z", - "start_time": "2025-05-11T21:47:52.334861Z" + "end_time": "2025-11-30T13:58:14.631140Z", + "start_time": "2025-11-30T13:58:13.817500Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_3_jupyter", + "Line_4_jupyter", + "Line_5_jupyter", + "Line_6_jupyter" + ] } }, "cell_type": "code", "source": [ "%useLatestDescriptors\n", - "%use coroutines\n", - "%use langchain4j(1.0.0-beta3, anthropic)" + "%use langchain4j(model = anthropic)\n", + "%use coroutines" ], "outputs": [], "execution_count": 1 @@ -52,8 +60,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:47:53.305783Z", - "start_time": "2025-05-11T21:47:53.281896Z" + "end_time": "2025-11-30T13:58:14.675389Z", + "start_time": "2025-11-30T13:58:14.632036Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_7_jupyter" + ] } }, "cell_type": "code", @@ -73,14 +86,19 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:48:11.715775Z", - "start_time": "2025-05-11T21:48:11.560748Z" + "end_time": "2025-11-30T13:58:14.952944Z", + "start_time": "2025-11-30T13:58:14.676091Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_8_jupyter" + ] } }, "cell_type": "code", "source": [ - "import dev.langchain4j.data.message.SystemMessage.systemMessage\n", - "import dev.langchain4j.data.message.UserMessage.userMessage\n", + "import dev.langchain4j.data.message.SystemMessage\n", + "import dev.langchain4j.data.message.UserMessage\n", "\n", "suspend fun llmCall(\n", " prompt: String,\n", @@ -95,16 +113,17 @@ " .build()\n", "\n", " return withContext(Dispatchers.IO) {\n", - " val response = client.chat {\n", - " systemPrompt?.let { messages += systemMessage(it) }\n", - " messages += userMessage(prompt)\n", + " val messages = buildList {\n", + " systemPrompt?.let { add(SystemMessage(it)) }\n", + " add(UserMessage(prompt))\n", " }\n", + " val response = client.chat(messages)\n", " response.aiMessage().text()\n", " }\n", "}" ], "outputs": [], - "execution_count": 4 + "execution_count": 3 }, { "metadata": {}, @@ -118,8 +137,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:48:13.230939Z", - "start_time": "2025-05-11T21:48:13.141982Z" + "end_time": "2025-11-30T13:58:15.115180Z", + "start_time": "2025-11-30T13:58:14.963711Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_9_jupyter" + ] } }, "cell_type": "code", @@ -138,7 +162,7 @@ "}" ], "outputs": [], - "execution_count": 5 + "execution_count": 4 }, { "metadata": {}, @@ -153,8 +177,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:48:14.434927Z", - "start_time": "2025-05-11T21:48:14.405064Z" + "end_time": "2025-11-30T13:58:15.232090Z", + "start_time": "2025-11-30T13:58:15.133273Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_10_jupyter" + ] } }, "cell_type": "code", @@ -190,7 +219,7 @@ ")" ], "outputs": [], - "execution_count": 6 + "execution_count": 5 }, { "metadata": {}, @@ -200,8 +229,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:48:27.224808Z", - "start_time": "2025-04-04T15:35:49.430890Z" + "end_time": "2025-11-30T13:58:31.065894Z", + "start_time": "2025-11-30T13:58:15.252329Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_11_jupyter" + ] } }, "cell_type": "code", @@ -232,169 +266,187 @@ "### HIGH PRIORITY\n", "**1. Rising Inflation & Cost Pressures**\n", "* Customers will become increasingly price-sensitive and may delay purchases\n", - "* Value perception will become critical to purchasing decisions\n", - "* Potential shift to lower-cost alternatives or extending product lifecycles\n", + "* Value perception will be critical to maintain loyalty\n", + "* Potential shift toward lower-cost alternatives or extending product lifecycles\n", "\n", "**2. Technology Acceleration**\n", - "* Growing expectation gap between current products and latest innovations\n", - "* Increased demand for seamless integration with other devices/platforms\n", - "* Higher abandonment rate for products perceived as technologically outdated\n", + "* Growing expectation gap between current offerings and desired tech capabilities\n", + "* Increased comparison shopping based on technical specifications\n", + "* Willingness to switch brands for meaningful technological improvements\n", "\n", - "### MEDIUM PRIORITY\n", "**3. Environmental Regulation & Awareness**\n", - "* Growing scrutiny of product sustainability credentials\n", - "* Willingness to pay premium for genuinely eco-friendly options\n", - "* Potential boycotts of brands perceived as environmentally harmful\n", - "\n", - "**4. Economic Uncertainty**\n", - "* More deliberate, research-intensive purchasing decisions\n", - "* Increased focus on product longevity and durability\n", - "* Greater demand for flexible payment options\n", + "* Heightened scrutiny of environmental claims and practices\n", + "* Growing demand for transparent sustainability information\n", + "* Potential premium acceptance for genuinely eco-friendly options\n", "\n", "## Recommended Actions\n", "\n", - "### IMMEDIATE ACTIONS (0-6 months)\n", - "1. **Implement transparent value communication strategy**\n", - " * Clearly articulate price-to-value ratio in all marketing\n", - " * Develop comparison tools highlighting long-term cost benefits\n", - "\n", - "2. **Launch tech upgrade program**\n", - " * Create affordable upgrade paths for existing customers\n", - " * Introduce modular product designs allowing component updates\n", - "\n", - "3. **Enhance sustainability messaging**\n", - " * Quantify environmental benefits in concrete terms\n", - " * Obtain relevant eco-certifications for products\n", - "\n", - "### SHORT-TERM ACTIONS (6-12 months)\n", - "1. **Develop tiered product offerings**\n", - " * Create good/better/best options at various price points\n", - " * Implement subscription models to reduce upfront costs\n", - "\n", - "2. **Establish environmental leadership position**\n", - " * Launch take-back/recycling program\n", - " * Transition to sustainable packaging and materials\n", - "\n", - "3. **Enhance digital experience**\n", - " * Improve online product education and comparison tools\n", - " * Develop AR/VR capabilities to demonstrate product benefits remotely\n", + "### IMMEDIATE ACTIONS (0-3 months)\n", + "1. **Value Communication Strategy**\n", + " * Develop clear messaging highlighting long-term value over initial price\n", + " * Create comparison tools showing total cost of ownership benefits\n", + " * Implement targeted promotions for price-sensitive segments\n", + "\n", + "2. **Technology Roadmap Transparency**\n", + " * Communicate upcoming technology improvements with specific timelines\n", + " * Develop upgrade programs that protect initial investments\n", + " * Create beta-testing opportunities for tech-enthusiastic customers\n", + "\n", + "3. **Environmental Credential Verification**\n", + " * Audit and verify all environmental claims for accuracy\n", + " * Develop simple, clear sustainability metrics for product marketing\n", + " * Highlight specific environmental benefits in monetary terms where possible\n", + "\n", + "### MEDIUM-TERM ACTIONS (3-12 months)\n", + "1. **Flexible Pricing Models**\n", + " * Explore subscription or service-based options to reduce upfront costs\n", + " * Develop tiered offerings with clear price/feature differentiation\n", + " * Create loyalty programs rewarding continued engagement\n", + "\n", + "2. **Technology Education Initiative**\n", + " * Launch educational content explaining technology benefits in practical terms\n", + " * Develop comparison tools highlighting technological advantages\n", + " * Create user communities for technology feedback and co-creation\n", + "\n", + "3. **Environmental Impact Reduction**\n", + " * Implement visible sustainability improvements in packaging and delivery\n", + " * Develop take-back or recycling programs with customer incentives\n", + " * Create environmental impact calculators for customer decision-making\n", "\n", "### LONG-TERM STRATEGY (12+ months)\n", - "1. **Reimagine product development process**\n", - " * Incorporate customer co-creation in design phases\n", - " * Build environmental considerations into product architecture\n", - "\n", - "2. **Develop ecosystem approach**\n", - " * Create complementary products that enhance value of core offerings\n", - " * Build community around sustainable technology adoption\n", - "\n", - "3. **Establish price-value leadership**\n", - " * Invest in manufacturing efficiencies to reduce costs\n", - " * Develop breakthrough technologies that deliver exceptional value# Market Impact Analysis for Employees\n", - "\n", - "## Key Impacts\n", + "1. **Value-Chain Optimization**\n", + " * Restructure operations to enable competitive pricing without quality compromise\n", + " * Develop strategic partnerships to enhance value proposition\n", + " * Explore market expansion to achieve economies of scale\n", "\n", - "### 1. Job Security Concerns\n", - "* Market volatility creates uncertainty about long-term employment stability\n", - "* Potential restructuring or role changes as company adapts to market conditions\n", - "* Increased stress and decreased productivity due to job insecurity\n", + "2. **Technology Innovation Pipeline**\n", + " * Invest in R&D focused on customer-identified technology priorities\n", + " * Develop modular product architecture enabling easier upgrades\n", + " * Create technology differentiation in areas most valued by customers\n", "\n", - "### 2. Skills Gap Challenges\n", - "* Rapidly evolving market requires new technical and adaptive capabilities\n", - "* Current skillsets may become outdated as industry demands shift\n", - "* Competition from external candidates with market-relevant skills\n", + "3. **Sustainability Leadership**\n", + " * Set industry-leading environmental targets with transparent reporting\n", + " * Integrate sustainability into core product development processes\n", + " * Develop circular economy business models reducing environmental impact\n", "\n", - "### 3. Direction and Leadership Needs\n", - "* Unclear strategic vision during market transitions affects employee confidence\n", - "* Difficulty aligning individual contributions with changing organizational goals\n", - "* Potential communication gaps between leadership and workforce\n", + "## Success Metrics\n", + "* Customer retention rates across price segments\n", + "* Technology satisfaction scores in customer feedback\n", + "* Environmental credential awareness and influence on purchase decisions\n", + "* Share of wallet among price-sensitive customers\n", + "* Conversion rates from environmental messaging# Market Impact Analysis: Employee Stakeholders\n", "\n", - "## Recommended Actions\n", + "## Key Impacts on Employees\n", "\n", "### High Priority\n", - "1. **Implement transparent communication strategy**\n", - " * Schedule regular town halls addressing market changes and company response\n", - " * Create dedicated intranet section for market updates and implications\n", - " * Establish anonymous feedback channels for employee concerns\n", + "1. **Job Security Concerns**\n", + " * Market volatility creates uncertainty about position stability\n", + " * Potential restructuring or role changes due to market adaptation\n", + " * Increased anxiety affecting productivity and engagement\n", "\n", - "2. **Develop comprehensive skills development program**\n", - " * Conduct skills gap analysis against market requirements\n", - " * Allocate budget for targeted training in high-demand areas\n", - " * Create mentorship opportunities with experienced team members\n", + "2. **Skills Gap Challenges**\n", + " * Rapidly evolving market demands new technical competencies\n", + " * Current skillsets may become outdated or insufficient\n", + " * Learning curve pressure during operational transitions\n", "\n", "### Medium Priority\n", - "1. **Enhance job security measures**\n", - " * Clearly communicate criteria for retention decisions\n", - " * Develop internal mobility program to retain talent in different roles\n", - " * Consider flexible work arrangements to reduce overhead costs\n", + "3. **Direction and Communication Needs**\n", + " * Unclear strategic vision during market shifts\n", + " * Inconsistent messaging about organizational response\n", + " * Difficulty aligning individual contributions with changing goals\n", "\n", - "2. **Strengthen leadership alignment**\n", - " * Ensure consistent messaging across all management levels\n", - " * Provide managers with market intelligence to address team questions\n", - " * Create cross-functional teams to address market challenges\n", + "## Recommended Actions\n", "\n", - "### Long-term Considerations\n", - "1. **Build organizational resilience**\n", - " * Develop succession planning for critical roles\n", - " * Create culture of continuous learning and adaptability\n", - " * Implement recognition programs for employees embracing change\n", + "### Immediate Actions (0-3 months)\n", + "* **Establish transparent communication channels**\n", + " - Schedule regular town halls addressing market changes\n", + " - Create dedicated intranet section for change management updates\n", + " - Train managers to effectively communicate during uncertainty\n", + "\n", + "* **Conduct skills assessment and gap analysis**\n", + " - Map current employee skills against projected market needs\n", + " - Identify critical skill development priorities\n", + " - Develop personalized learning paths for key roles\n", + "\n", + "### Short-Term Actions (3-6 months)\n", + "* **Launch targeted upskilling initiatives**\n", + " - Implement training programs for high-demand market skills\n", + " - Create mentorship opportunities with skilled team members\n", + " - Provide learning stipends for relevant external education\n", + "\n", + "* **Enhance job security through transparency**\n", + " - Clearly communicate business adaptation strategy\n", + " - Define how roles will evolve rather than disappear\n", + " - Showcase success stories of employees who have successfully transitioned\n", + "\n", + "### Long-Term Actions (6-12 months)\n", + "* **Develop strategic workforce planning**\n", + " - Create career progression paths aligned with market direction\n", + " - Implement rotation programs to build versatile skills\n", + " - Establish innovation teams to proactively address market changes\n", + "\n", + "* **Build change resilience culture**\n", + " - Reward adaptability and continuous learning\n", + " - Incorporate market awareness into performance reviews\n", + " - Develop change management capabilities across all levels\n", "\n", - "2. **Align compensation with market realities**\n", - " * Review compensation structure against changing market conditions\n", - " * Consider performance incentives tied to new strategic priorities\n", - " * Explore non-monetary benefits that address employee concerns# Market Impact Analysis for Investors\n", + "## Success Metrics\n", + "* Employee retention rates during transition periods\n", + "* Skills development completion and application rates\n", + "* Employee engagement and confidence scores\n", + "* Internal mobility and role adaptation statistics# Market Impact Analysis for Investors\n", "\n", "## Key Impacts\n", "\n", "### 1. Return on Investment Pressure\n", "* Market volatility may challenge growth expectations\n", - "* Competitive landscape intensifying, potentially squeezing margins\n", - "* Longer timelines to profitability in uncertain economic conditions\n", + "* Competitive landscape intensification could compress margins\n", + "* Extended payback periods likely as market stabilizes\n", "\n", - "### 2. Risk Exposure Concerns\n", + "### 2. Risk Profile Shifts\n", "* Increased regulatory scrutiny creating compliance costs\n", "* Market consolidation threatening competitive positioning\n", - "* Potential for rapid technology shifts requiring additional capital\n", + "* Potential for capital structure stress during transition periods\n", "\n", "### 3. Cost Management Challenges\n", "* Inflationary pressures affecting operational expenses\n", - "* Talent acquisition costs rising in competitive sectors\n", - "* Supply chain disruptions potentially increasing procurement costs\n", + "* Technology investment requirements accelerating\n", + "* Talent acquisition costs rising in specialized areas\n", "\n", "## Recommended Actions\n", "\n", "### High Priority\n", - "1. **Enhance Transparency in Reporting**\n", - " * Implement more frequent performance updates\n", - " * Develop clear metrics for measuring progress against growth targets\n", - " * Provide detailed risk mitigation strategies in quarterly reports\n", + "1. **Revise portfolio allocation strategy**\n", + " * Diversify across market segments to balance risk\n", + " * Increase allocation to counter-cyclical assets\n", + " * Establish clear performance thresholds for continued investment\n", "\n", - "2. **Optimize Capital Allocation**\n", - " * Review investment portfolio for underperforming assets\n", - " * Prioritize initiatives with strongest ROI potential\n", - " * Consider strategic divestments in high-risk market segments\n", + "2. **Enhance transparency in reporting**\n", + " * Implement more frequent performance updates\n", + " * Develop clear metrics for cost control effectiveness\n", + " * Create dashboard for risk exposure visualization\n", "\n", "### Medium Priority\n", - "1. **Strengthen Cost Control Mechanisms**\n", - " * Implement advanced analytics for expense monitoring\n", - " * Explore automation opportunities to reduce operational costs\n", - " * Develop contingency budgets for market disruptions\n", + "1. **Strengthen governance mechanisms**\n", + " * Review risk management frameworks\n", + " * Establish specialized committees for emerging market challenges\n", + " * Develop contingency plans for various market scenarios\n", "\n", - "2. **Diversify Growth Strategies**\n", - " * Balance high-growth initiatives with stable revenue streams\n", - " * Explore strategic partnerships to share risk and resources\n", - " * Consider geographic expansion to reduce market concentration risk\n", + "2. **Optimize cost structures**\n", + " * Identify automation opportunities\n", + " * Evaluate outsourcing non-core functions\n", + " * Implement zero-based budgeting approaches\n", "\n", "### Long-term Considerations\n", - "1. **Align Incentive Structures**\n", - " * Review compensation models to ensure alignment with investor priorities\n", - " * Develop performance metrics that balance growth with cost efficiency\n", - " * Create accountability for risk management at executive level\n", + "1. **Strategic repositioning**\n", + " * Evaluate potential for vertical integration\n", + " * Assess opportunities in adjacent markets\n", + " * Consider strategic partnerships to share risk\n", "\n", - "2. **Build Resilience Planning**\n", - " * Develop scenario analyses for various market conditions\n", - " * Create early warning systems for emerging market risks\n", - " * Establish clear communication protocols for market disruptions# Market Impact Analysis for Suppliers\n", + "2. **Innovation investment**\n", + " * Allocate resources to R&D for competitive differentiation\n", + " * Explore emerging technologies with efficiency potential\n", + " * Develop intellectual property strategy# Market Impact Analysis for Suppliers\n", "\n", "## Key Impacts\n", "\n", @@ -408,7 +460,7 @@ "* **Rising raw material costs** squeezing profit margins\n", "* **Inflationary pressures** affecting operational expenses\n", "* **Competitive pricing environment** limiting ability to pass costs to customers\n", - "* **Contract renegotiation requests** from cost-conscious buyers\n", + "* **Contract renegotiation challenges** with fixed-price agreements\n", "\n", "### 3. Technology Transitions\n", "* **Legacy systems becoming obsolete** requiring significant investment\n", @@ -418,252 +470,48 @@ "\n", "## Recommended Actions (Prioritized)\n", "\n", - "### Immediate Priorities (0-3 months)\n", + "### Immediate Priority (0-3 months)\n", "1. **Conduct capacity assessment and optimization**\n", - " * Map current bottlenecks and constraints\n", - " * Implement lean manufacturing principles\n", - " * Develop contingency plans for peak demand periods\n", - "\n", - "2. **Implement strategic pricing models**\n", - " * Develop value-based pricing strategies\n", - " * Create tiered service offerings\n", - " * Establish cost-plus contracts with material price adjustment clauses\n", - "\n", - "### Medium-Term Actions (3-12 months)\n", - "1. **Develop technology roadmap**\n", - " * Assess current technological capabilities against market trends\n", - " * Prioritize investments in critical technologies\n", - " * Create phased implementation plan\n", - "\n", - "2. **Strengthen supplier relationships**\n", - " * Diversify supplier base to reduce dependency\n", - " * Negotiate long-term agreements with key suppliers\n", - " * Explore collaborative forecasting with customers\n", - "\n", - "### Long-Term Strategies (12+ months)\n", - "1. **Invest in automation and digitalization**\n", - " * Implement advanced manufacturing technologies\n", - " * Develop digital twins for production optimization\n", - " * Explore AI/ML for predictive maintenance\n", - "\n", - "2. **Build workforce capabilities**\n", - " * Develop training programs for new technologies\n", - " * Recruit specialized talent in emerging tech areas\n", - " * Create knowledge transfer systems\n", - "\n", - "## Performance Metrics to Track\n", - "* Production capacity utilization\n", - "* On-time delivery rates\n", - "* Profit margin by product/service line\n", - "* Technology adoption ROI\n", - "* Customer satisfaction scores# Market Impact Analysis for Price-Sensitive, Tech-Focused, Environmentally Conscious Customers\n", - "\n", - "## Key Market Changes & Impacts\n", - "\n", - "### HIGH PRIORITY\n", - "**1. Rising Inflation & Cost Pressures**\n", - "* Customers will become increasingly price-sensitive and may delay purchases\n", - "* Value perception will become critical to purchasing decisions\n", - "* Potential shift to lower-cost alternatives or extending product lifecycles\n", - "\n", - "**2. Technology Acceleration**\n", - "* Growing expectation gap between current products and latest innovations\n", - "* Increased demand for seamless integration with other devices/platforms\n", - "* Higher expectations for regular software updates and feature additions\n", - "\n", - "### MEDIUM PRIORITY\n", - "**3. Environmental Regulation & Awareness**\n", - "* Growing demand for transparent sustainability practices and credentials\n", - "* Increased scrutiny of product lifecycle environmental impact\n", - "* Willingness to pay modest premiums for genuinely sustainable options\n", - "\n", - "**4. Economic Uncertainty**\n", - "* More deliberate, research-intensive purchasing processes\n", - "* Heightened focus on product longevity and durability\n", - "* Preference for flexible payment options and clear value demonstration\n", - "\n", - "## Recommended Actions\n", - "\n", - "### Immediate Actions (0-6 months)\n", - "1. **Introduce tiered pricing models** with clear value differentiation\n", - "2. **Develop trade-in/upgrade programs** to address price sensitivity while encouraging technology adoption\n", - "3. **Launch transparent sustainability dashboard** highlighting environmental initiatives and product impacts\n", - "\n", - "### Short-Term Actions (6-12 months)\n", - "1. **Implement AI-driven personalization** to enhance technology experience without raising costs\n", - "2. **Create educational content** demonstrating long-term cost benefits of environmentally-friendly features\n", - "3. **Develop subscription options** that bundle products with services to distribute costs\n", - "\n", - "### Strategic Initiatives (12+ months)\n", - "1. **Redesign product development** to incorporate modular components for easier upgrades\n", - "2. **Establish sustainability leadership** through circular economy initiatives and carbon reduction\n", - "3. **Build community platforms** where customers can share optimization tips and provide feedback\n", - "\n", - "## Success Metrics\n", - "* Customer retention rate improvements\n", - "* Positive sentiment around value perception\n", - "* Adoption rates of sustainable product options\n", - "* Engagement with technology features\n", - "* Net promoter score trends# Market Impact Analysis for Employees\n", - "\n", - "## Key Impacts\n", - "\n", - "### 1. Job Security Concerns\n", - "* Market volatility creates uncertainty about long-term employment stability\n", - "* Potential restructuring or role changes as company adapts to market shifts\n", - "* Increased anxiety affecting productivity and engagement\n", - "\n", - "### 2. Skills Gap Challenges\n", - "* Emerging technologies and market demands require new competencies\n", - "* Current skillsets may become less relevant as industry evolves\n", - "* Learning curve pressure during operational transitions\n", - "\n", - "### 3. Strategic Direction Uncertainty\n", - "* Unclear organizational priorities during market changes\n", - "* Difficulty aligning individual contributions with shifting company goals\n", - "* Reduced confidence in leadership decisions without transparent communication\n", - "\n", - "## Recommended Actions (In Priority Order)\n", - "\n", - "### IMMEDIATE PRIORITY\n", - "1. **Establish Transparent Communication Channels**\n", - " * Implement regular town halls addressing market changes and company response\n", - " * Create dedicated intranet section for market updates and strategic direction\n", - " * Ensure leadership visibility with consistent messaging about future plans\n", - "\n", - "2. **Launch Skills Assessment & Development Program**\n", - " * Conduct organization-wide skills gap analysis\n", - " * Develop personalized learning paths for critical emerging competencies\n", - " * Allocate protected time for upskilling activities\n", - "\n", - "### HIGH PRIORITY\n", - "3. **Strengthen Job Security Measures**\n", - " * Clearly communicate retention strategies and criteria\n", - " * Implement cross-training programs to increase employee versatility\n", - " * Create internal mobility pathways to retain talent in evolving roles\n", - "\n", - "4. **Enhance Change Management Support**\n", - " * Train managers in supporting teams through market transitions\n", - " * Provide psychological safety resources and stress management tools\n", - " * Establish change ambassador network from within employee ranks\n", - "\n", - "### MEDIUM PRIORITY\n", - "5. **Align Incentives with New Market Direction**\n", - " * Revise performance metrics to reflect changing priorities\n", - " * Recognize and reward adaptation and innovation\n", - " * Create special project opportunities addressing market challenges\n", - "\n", - "6. **Gather Continuous Employee Feedback**\n", - " * Implement pulse surveys to monitor concerns and sentiment\n", - " * Create safe channels for expressing worries and suggestions\n", - " * Demonstrate responsive action to feedback received\n", - "\n", - "By addressing these impacts with structured interventions, the organization can transform market uncertainty into an opportunity for employee growth and increased engagement.# Market Impact Analysis for Investors\n", - "\n", - "## Key Impacts\n", - "\n", - "### 1. Return on Investment Pressure\n", - "* Market volatility may create short-term performance challenges\n", - "* Competitive landscape intensification could delay growth projections\n", - "* Cost inflation might squeeze profit margins despite cost control efforts\n", - "\n", - "### 2. Risk Profile Shifts\n", - "* Increased market uncertainty requires portfolio rebalancing\n", - "* Regulatory changes may create compliance costs and operational constraints\n", - "* Potential for higher capital requirements in uncertain economic conditions\n", - "\n", - "### 3. Growth Opportunity Transformation\n", - "* Traditional growth channels may underperform expectations\n", - "* New market segments could emerge requiring strategic pivots\n", - "* Acquisition opportunities may arise as competitors struggle\n", - "\n", - "## Recommended Actions (Prioritized)\n", + " * Map current production capabilities against demand forecasts\n", + " * Identify and resolve critical bottlenecks\n", + " * Implement short-term efficiency improvements\n", "\n", - "### Immediate Priority (0-3 months)\n", - "1. **Enhance Transparency**: Implement more frequent investor communications with clear metrics on cost control initiatives and their impact\n", - "2. **Risk Mitigation Planning**: Develop scenario-based contingency plans for various market downturns\n", - "3. **Cash Position Review**: Evaluate optimal cash reserves balancing growth investment and risk protection\n", + "2. **Develop strategic pricing models**\n", + " * Create tiered pricing structures based on volume and service levels\n", + " * Incorporate material cost indexing in new contracts\n", + " * Identify value-added services that can command premium pricing\n", "\n", "### Medium Priority (3-9 months)\n", - "1. **Strategic Realignment**: Adjust growth targets to reflect market realities while identifying new opportunity areas\n", - "2. **Efficiency Acceleration**: Fast-track automation and operational streamlining to protect margins\n", - "3. **Competitive Intelligence**: Increase monitoring of market shifts and competitor vulnerabilities\n", - "\n", - "### Long-term Priority (9+ months)\n", - "1. **Portfolio Diversification**: Explore adjacent markets with lower correlation to current business cycles\n", - "2. **Strategic Acquisition Planning**: Prepare for opportunistic acquisitions of distressed assets\n", - "3. **Innovation Investment**: Allocate resources to high-potential innovation that can drive growth despite market headwinds\n", - "\n", - "## Success Metrics\n", - "* Maintained or improved profit margins despite market pressures\n", - "* Risk-adjusted returns meeting or exceeding industry benchmarks\n", - "* Successful implementation of cost control measures with quantifiable savings\n", - "* Balanced growth investments maintaining long-term competitive positioning# Market Impact Analysis for Suppliers\n", - "\n", - "## Key Impacts\n", - "\n", - "### 1. Capacity Constraints\n", - "* **Supply chain bottlenecks** limiting production capabilities\n", - "* **Increased lead times** affecting delivery schedules\n", - "* **Inability to meet growing demand** from customers\n", - "* **Resource allocation challenges** across customer base\n", - "\n", - "### 2. Price Pressures\n", - "* **Rising raw material costs** squeezing profit margins\n", - "* **Inflationary pressures** affecting operational expenses\n", - "* **Competitive pricing environment** limiting ability to pass costs to customers\n", - "* **Contract renegotiation challenges** with fixed-price agreements\n", + "1. **Establish technology roadmap**\n", + " * Assess current technological capabilities against market trends\n", + " * Prioritize investments based on ROI and customer requirements\n", + " * Develop phased implementation plan for critical upgrades\n", "\n", - "### 3. Technology Transitions\n", - "* **Legacy systems becoming obsolete** requiring significant investment\n", - "* **New skill requirements** for workforce\n", - "* **Integration challenges** with customer systems\n", - "* **R&D investment needs** to remain competitive\n", + "2. **Diversify supply chain**\n", + " * Identify alternative material sources and manufacturing options\n", + " * Develop contingency production plans\n", + " * Create strategic inventory buffers for critical components\n", "\n", - "## Recommended Actions (Prioritized)\n", + "### Long-term Priority (9-18 months)\n", + "1. **Invest in workforce development**\n", + " * Create training programs for emerging technologies\n", + " * Recruit specialized talent for innovation initiatives\n", + " * Develop knowledge transfer systems for institutional expertise\n", "\n", - "### Immediate Priorities (0-6 months)\n", - "1. **Conduct capacity assessment and optimization**\n", - " * Map current production capabilities against demand forecasts\n", - " * Identify and eliminate bottlenecks in production processes\n", - " * Implement lean manufacturing principles to improve efficiency\n", - "\n", - "2. **Develop strategic pricing models**\n", - " * Create tiered pricing structures based on volume and service levels\n", - " * Implement cost-plus-margin models with adjustment mechanisms\n", - " * Explore value-based pricing for premium offerings\n", - "\n", - "### Medium-Term Actions (6-18 months)\n", - "1. **Invest in technology modernization**\n", - " * Develop phased technology upgrade roadmap\n", - " * Prioritize systems that interface with key customers\n", - " * Implement training programs for staff on new technologies\n", - "\n", - "2. **Diversify supplier base**\n", - " * Identify alternative sources for critical materials\n", - " * Develop relationships with suppliers in different geographic regions\n", - " * Create contingency plans for supply disruptions\n", - "\n", - "### Long-Term Strategy (18+ months)\n", - "1. **Form strategic partnerships**\n", - " * Explore joint ventures to expand capacity\n", - " * Develop co-innovation initiatives with key customers\n", - " * Consider vertical integration opportunities\n", - "\n", - "2. **Build resilience through flexibility**\n", - " * Design adaptable production systems\n", - " * Create modular product architectures\n", - " * Develop scenario-based planning capabilities\n", + "2. **Establish strategic partnerships**\n", + " * Identify complementary suppliers for collaborative offerings\n", + " * Explore vertical integration opportunities\n", + " * Develop joint innovation initiatives with key customers\n", "\n", "## Success Metrics\n", - "* Reduction in production backlogs by 30%\n", - "* Maintenance of target profit margins within 2% of goals\n", - "* Technology adoption rate meeting industry benchmarks\n", - "* Customer satisfaction scores above 85%" + "* Reduction in production backlogs by 25% within 6 months\n", + "* Maintenance of minimum 15% gross margin despite price pressures\n", + "* Successful implementation of at least two new technologies within 12 months\n", + "* Reduction in customer delivery complaints by 30% within 9 months" ] } ], - "execution_count": 7 + "execution_count": 6 }, { "metadata": {}, diff --git a/notebooks/agents/Prompt-Chaining Workflow.ipynb b/notebooks/agents/Prompt-Chaining Workflow.ipynb index 74df58a..e4e822c 100644 --- a/notebooks/agents/Prompt-Chaining Workflow.ipynb +++ b/notebooks/agents/Prompt-Chaining Workflow.ipynb @@ -40,15 +40,23 @@ "metadata": { "collapsed": true, "ExecuteTime": { - "end_time": "2025-05-11T21:48:44.069877Z", - "start_time": "2025-05-11T21:48:43.106474Z" + "end_time": "2025-11-30T13:48:49.259877Z", + "start_time": "2025-11-30T13:48:48.611866Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_3_jupyter", + "Line_4_jupyter", + "Line_5_jupyter", + "Line_6_jupyter" + ] } }, "cell_type": "code", "source": [ "%useLatestDescriptors\n", "%use coroutines\n", - "%use langchain4j(1.0.0-beta3, anthropic)" + "%use langchain4j(model = anthropic)" ], "outputs": [], "execution_count": 1 @@ -61,8 +69,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:48:44.100358Z", - "start_time": "2025-05-11T21:48:44.073812Z" + "end_time": "2025-11-30T13:48:49.295090Z", + "start_time": "2025-11-30T13:48:49.260582Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_7_jupyter" + ] } }, "cell_type": "code", @@ -82,14 +95,19 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:48:49.867603Z", - "start_time": "2025-05-11T21:48:49.653724Z" + "end_time": "2025-11-30T13:48:49.530413Z", + "start_time": "2025-11-30T13:48:49.295646Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_8_jupyter" + ] } }, "cell_type": "code", "source": [ - "import dev.langchain4j.data.message.SystemMessage.systemMessage\n", - "import dev.langchain4j.data.message.UserMessage.userMessage\n", + "import dev.langchain4j.data.message.SystemMessage\n", + "import dev.langchain4j.data.message.UserMessage\n", "\n", "suspend fun llmCall(\n", " prompt: String,\n", @@ -104,10 +122,11 @@ " .build()\n", "\n", " return withContext(Dispatchers.IO) {\n", - " val response = client.chat {\n", - " systemPrompt?.let { messages += systemMessage(it) }\n", - " messages += userMessage(prompt)\n", + " val messages = buildList {\n", + " systemPrompt?.let { add(SystemMessage(it)) }\n", + " add(UserMessage(prompt))\n", " }\n", + " val response = client.chat(messages)\n", " response.aiMessage().text()\n", " }\n", "}" @@ -127,8 +146,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:48:51.193436Z", - "start_time": "2025-05-11T21:48:51.107695Z" + "end_time": "2025-11-30T13:48:49.661604Z", + "start_time": "2025-11-30T13:48:49.533742Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_9_jupyter" + ] } }, "cell_type": "code", @@ -165,8 +189,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:48:52.902515Z", - "start_time": "2025-05-11T21:48:52.879801Z" + "end_time": "2025-11-30T13:48:49.747609Z", + "start_time": "2025-11-30T13:48:49.666371Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_10_jupyter" + ] } }, "cell_type": "code", @@ -221,8 +250,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:48:54.455677Z", - "start_time": "2025-05-11T21:48:54.431018Z" + "end_time": "2025-11-30T13:48:49.807284Z", + "start_time": "2025-11-30T13:48:49.751656Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_11_jupyter" + ] } }, "cell_type": "code", @@ -251,8 +285,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:49:08.576050Z", - "start_time": "2025-05-11T21:48:57.097290Z" + "end_time": "2025-11-30T13:48:56.353802Z", + "start_time": "2025-11-30T13:48:49.816409Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_12_jupyter" + ] } }, "cell_type": "code", diff --git a/notebooks/agents/Routing Workflow.ipynb b/notebooks/agents/Routing Workflow.ipynb index 1819e99..502d430 100644 --- a/notebooks/agents/Routing Workflow.ipynb +++ b/notebooks/agents/Routing Workflow.ipynb @@ -39,14 +39,14 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:49:56.626451Z", - "start_time": "2025-05-11T21:49:55.686026Z" + "end_time": "2025-11-30T13:24:38.348528Z", + "start_time": "2025-11-30T13:24:35.644470Z" } }, "cell_type": "code", "source": [ "%useLatestDescriptors\n", - "%use langchain4j(1.0.0-beta3)" + "%use langchain4j" ], "outputs": [], "execution_count": 1 @@ -59,8 +59,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:49:56.656261Z", - "start_time": "2025-05-11T21:49:56.630928Z" + "end_time": "2025-11-30T13:24:38.378576Z", + "start_time": "2025-11-30T13:24:38.349652Z" } }, "cell_type": "code", @@ -80,8 +80,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:49:57.504579Z", - "start_time": "2025-05-11T21:49:57.461393Z" + "end_time": "2025-11-30T13:24:38.425234Z", + "start_time": "2025-11-30T13:24:38.378943Z" } }, "cell_type": "code", @@ -107,8 +107,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:50:00.508006Z", - "start_time": "2025-05-11T21:50:00.322466Z" + "end_time": "2025-11-30T13:24:38.595581Z", + "start_time": "2025-11-30T13:24:38.425664Z" } }, "cell_type": "code", @@ -141,8 +141,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:51:04.273220Z", - "start_time": "2025-05-11T21:51:04.170776Z" + "end_time": "2025-11-30T13:24:38.807064Z", + "start_time": "2025-11-30T13:24:38.596010Z" } }, "cell_type": "code", @@ -218,7 +218,7 @@ "}" ], "outputs": [], - "execution_count": 6 + "execution_count": 5 }, { "metadata": {}, @@ -232,8 +232,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:51:05.865926Z", - "start_time": "2025-05-11T21:51:05.829507Z" + "end_time": "2025-11-30T13:24:38.861740Z", + "start_time": "2025-11-30T13:24:38.808078Z" } }, "cell_type": "code", @@ -285,7 +285,7 @@ ")" ], "outputs": [], - "execution_count": 7 + "execution_count": 6 }, { "metadata": {}, @@ -299,8 +299,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:51:07.143681Z", - "start_time": "2025-05-11T21:51:07.124116Z" + "end_time": "2025-11-30T13:24:38.891012Z", + "start_time": "2025-11-30T13:24:38.862137Z" } }, "cell_type": "code", @@ -332,7 +332,7 @@ ")" ], "outputs": [], - "execution_count": 8 + "execution_count": 7 }, { "metadata": {}, @@ -342,8 +342,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T21:51:42.001153Z", - "start_time": "2025-05-11T21:51:11.086610Z" + "end_time": "2025-11-30T13:25:11.997957Z", + "start_time": "2025-11-30T13:24:38.891424Z" } }, "cell_type": "code", @@ -378,41 +378,39 @@ "----------------------------------------\n", "Available routes: [billing, technical, account, product]\n", "Routing Analysis:\n", - "The user is experiencing issues with logging into their account, specifically receiving an 'invalid password' error despite using what they believe is the correct password. This indicates a problem related to account access rather than billing, technical issues with the product itself, or inquiries about product features. Given the urgency expressed by the user, as they need to regain access to submit a report by the end of the day, the account support team is best suited to assist with this issue.\n", + "The user is experiencing issues accessing their account, specifically related to login credentials. The urgency of the situation is highlighted by the need to submit a report by the end of the day. Therefore, the most appropriate team to assist with account access issues is the account support team, as they specialize in resolving login and access problems.\n", "Selected route: account\n", "Account Support Response:\n", "\n", "Dear John,\n", "\n", - "Thank you for reaching out regarding your account access issue. We understand the urgency of your situation, and we are here to assist you in regaining access to your account. To prioritize your account security, please follow these steps:\n", - "\n", - "1. **Verify Your Identity**: Before we proceed, we need to confirm your identity. Please provide the following information:\n", - " - The email address associated with your account.\n", - " - Any recent transactions or account activity that you can recall.\n", - " - The last successful login date and time.\n", + "Thank you for reaching out regarding your account access issue. I understand the urgency of your situation, and I am here to assist you in regaining access to your account while prioritizing your security.\n", "\n", - "2. **Password Reset**: If you are confident that you are using the correct password, it may be beneficial to reset it. Please follow these steps:\n", - " - Go to the login page and click on \"Forgot Password?\"\n", - " - Enter your registered email address and follow the instructions sent to your email.\n", - " - Create a new password that is strong and unique (at least 12 characters, including uppercase letters, lowercase letters, numbers, and special characters).\n", + "**Steps for Account Recovery:**\n", "\n", - "3. **Check for Account Lock**: If you have attempted to log in multiple times with an incorrect password, your account may be temporarily locked for security reasons. If this is the case, please wait 30 minutes before trying again or proceed with the password reset.\n", + "1. **Password Reset:**\n", + " - Please initiate a password reset by clicking on the \"Forgot Password?\" link on the login page.\n", + " - Enter your registered email address and follow the instructions sent to your inbox. Be sure to check your spam or junk folder if you do not see the email within a few minutes.\n", "\n", - "4. **Enable Two-Factor Authentication (2FA)**: Once you regain access, we highly recommend enabling 2FA for added security. This will require a second form of verification when logging in, significantly enhancing your account's protection.\n", + "2. **Verify Your Identity:**\n", + " - During the password reset process, you may be asked to answer security questions or verify your identity through a secondary method (e.g., SMS code, authentication app). Please ensure you have access to these verification methods.\n", "\n", - "**Security Tips**:\n", - "- Avoid using the same password across multiple accounts.\n", - "- Regularly update your passwords and use a password manager if necessary.\n", - "- Be cautious of phishing attempts; always verify the source of any communication regarding your account.\n", + "3. **Create a Strong Password:**\n", + " - When creating a new password, ensure it is strong and unique. Use a combination of uppercase and lowercase letters, numbers, and special characters. Avoid using easily guessable information.\n", "\n", - "**Resolution Time**: Once we receive the required information, we aim to resolve your issue within 24 hours. However, if you choose to reset your password, you should be able to regain access immediately after completing the reset process.\n", + "**Security Tips:**\n", + "- Enable two-factor authentication (2FA) on your account if you haven't already. This adds an extra layer of security.\n", + "- Regularly update your passwords and avoid reusing them across different accounts.\n", + "- Be cautious of phishing attempts. Always verify the source of any emails or messages requesting your account information.\n", "\n", - "Please respond with the requested information at your earliest convenience so we can assist you further.\n", + "**Resolution Time:**\n", + "Once you complete the password reset process, you should be able to access your account immediately. If you encounter any further issues, please respond to this message, and I will assist you further. \n", "\n", - "Best regards,\n", + "Thank you for your attention to these security measures. I look forward to your successful account recovery.\n", "\n", + "Best regards, \n", "[Your Name] \n", - "Account Security Team\n", + "Account Security Specialist\n", "Ticket 2:\n", "----------------------------------------\n", "\n", @@ -426,31 +424,31 @@ "----------------------------------------\n", "Available routes: [billing, technical, account, product]\n", "Routing Analysis:\n", - "The ticket should be routed to the billing team because the user is inquiring about an unexpected charge on their credit card. The key terms here are 'unexpected charge' and 'adjust it if it's a mistake', indicating that Sarah is seeking clarification and potential correction regarding billing issues. This falls squarely within the responsibilities of the billing team, who handle charges and payment discrepancies.\n", + "The ticket should be routed to the billing team because the user is inquiring about an unexpected charge on their credit card. The key terms here are 'unexpected charge' and 'adjust it if it's a mistake', indicating that Sarah is seeking clarification and potential correction regarding her billing. This falls squarely within the responsibilities of the billing team, which handles charges and payment issues.\n", "Selected route: billing\n", "Billing Support Response:\n", "\n", "Hello Sarah,\n", "\n", - "Thank you for reaching out regarding the unexpected charge of $49.99 on your credit card. I understand how concerning this can be, especially when you were expecting to be billed at the $29.99 plan.\n", + "Thank you for reaching out regarding the unexpected charge of $49.99 on your credit card. I understand how concerning this can be, and I'm here to help clarify the situation.\n", "\n", - "Upon reviewing your account, it appears that the charge of $49.99 corresponds to an upgrade to a premium service that was activated recently. This may have been done inadvertently or through a misunderstanding of the plan options. I apologize for any confusion this may have caused.\n", + "The charge of $49.99 may be due to an upgrade to a higher-tier plan or an additional service that was added to your account. I will need to review your account details to confirm the reason for this discrepancy.\n", "\n", - "To resolve this issue, I recommend the following steps:\n", + "Here are the next steps we will take:\n", "\n", - "1. **Confirm Your Current Plan**: Please verify if you intended to upgrade to the premium service. If not, we can revert your account back to the $29.99 plan.\n", - "2. **Adjustment of Charges**: If you confirm that you did not intend to upgrade, I will initiate a refund for the $49.99 charge. This process typically takes 3-5 business days to reflect on your account.\n", - "3. **Future Billing**: Once the adjustment is made, you will be billed $29.99 for your next billing cycle.\n", + "1. **Account Review**: I will check your account to verify your current plan and any recent changes. This process typically takes 1-2 business days.\n", + "2. **Follow-Up**: Once I have the information, I will follow up with you via email to explain the charge and discuss any necessary adjustments.\n", + "3. **Adjustment**: If the charge is indeed a mistake, I will initiate a refund for the difference, which can take 3-5 business days to process.\n", "\n", - "Please reply to this message confirming your intended plan, and I will take care of the rest promptly.\n", + "In the meantime, if you have any additional questions or need further assistance, please feel free to reach out. \n", "\n", - "For your convenience, we accept various payment options including credit/debit cards and PayPal for future transactions.\n", + "For your convenience, we accept various payment options, including credit/debit cards and PayPal, should you need to make any future payments.\n", "\n", - "Thank you for your understanding, and I look forward to resolving this for you!\n", + "Thank you for your patience, and I look forward to resolving this for you!\n", "\n", "Best regards, \n", "[Your Name] \n", - "Billing Support Specialist\n", + "Billing Support Team\n", "Ticket 3:\n", "----------------------------------------\n", "\n", @@ -464,46 +462,51 @@ "----------------------------------------\n", "Available routes: [billing, technical, account, product]\n", "Routing Analysis:\n", - "The user's request is focused on exporting project data to Excel, which pertains to the functionality of the product itself. The user is seeking guidance on how to perform a specific action within the product, indicating that they need assistance with the product's features rather than billing, account management, or technical issues. Therefore, the product team is best suited to provide the necessary support and instructions for exporting data.\n", + "The user's request is focused on exporting project data, which relates to the functionality of the product. They are seeking guidance on how to perform a specific action within the product, indicating that they need assistance with the product's features rather than billing, account issues, or technical problems. Therefore, the product team is best suited to provide the necessary support and instructions for exporting data.\n", "Selected route: product\n", "Product Support Response:\n", "\n", "Hi Mike,\n", "\n", - "Thank you for reaching out! I’m happy to help you with exporting your project data to Excel. Yes, it is indeed possible to perform a bulk export, and I’ll walk you through the steps to make it as smooth as possible.\n", + "Thank you for reaching out! I'm happy to help you with exporting your project data to Excel. Yes, it is indeed possible to perform a bulk export, and I’ll walk you through the steps to make this process smooth for you.\n", "\n", "### Steps to Export Data to Excel:\n", "\n", "1. **Navigate to Your Project**: Start by opening the project from which you want to export data.\n", "\n", - "2. **Access the Export Feature**: Look for the \"Export\" option, which is typically found in the project settings or under the \"More\" menu (represented by three dots or a gear icon).\n", + "2. **Access the Export Feature**: Look for the \"Export\" option, which is typically found in the project settings or under the \"More\" menu (often represented by three dots or a gear icon).\n", + "\n", + "3. **Select Data Type**: Choose the type of data you want to export. This could include tasks, milestones, or other project-related information.\n", "\n", - "3. **Select Data Type**: You may have options to choose what type of data you want to export (e.g., tasks, milestones, or overall project data). Select the appropriate option based on your needs.\n", + "4. **Choose Excel Format**: When prompted, select the Excel format (usually .xlsx) for your export.\n", "\n", - "4. **Choose Excel Format**: When prompted, select the Excel format for your export. This is usually labeled as \".xlsx\" or \"Excel\".\n", + "5. **Initiate the Export**: Click on the \"Export\" button. Depending on the size of your project data, this may take a moment. Once completed, the file will either download automatically or prompt you to save it.\n", "\n", - "5. **Initiate Export**: Click on the \"Export\" button. Depending on the size of your project, this may take a moment. Once completed, a download link will be provided.\n", + "6. **Open in Excel**: After downloading, you can open the file in Excel to view and manipulate your data as needed.\n", "\n", - "6. **Download the File**: Click the link to download your Excel file, and you can then open it in Excel for further analysis or reporting.\n", + "### Best Practices:\n", "\n", - "### Example of Usage:\n", - "For instance, if you are managing a project with multiple tasks and team members, exporting this data can help you create a comprehensive report for stakeholders. You can analyze task completion rates, resource allocation, and timelines directly in Excel.\n", + "- **Filter Data Before Exporting**: If you only need specific information, consider applying filters to your project data before exporting. This will help you create a more focused and manageable Excel file.\n", "\n", - "### Relevant Documentation:\n", - "For more detailed instructions, please refer to our [Exporting Data Documentation](#). This section provides additional insights and troubleshooting tips if you encounter any issues.\n", + "- **Regular Backups**: Make it a habit to export your project data regularly. This ensures you have up-to-date backups and can track changes over time.\n", "\n", "### Related Features:\n", - "You might also find the **Data Filtering** feature helpful before exporting. This allows you to narrow down the data to only what you need, making your Excel file more manageable. Additionally, consider using **Dashboards** to visualize your project data before exporting, which can provide a clearer picture of your project’s status.\n", "\n", - "If you have any further questions or need additional assistance, feel free to ask. Happy exporting!\n", + "- **Data Visualization**: Consider using built-in reporting tools to visualize your project data before exporting. This can provide insights that may be useful for your analysis.\n", + "\n", + "- **Integration with Other Tools**: If you frequently work with Excel, check if there are integrations available that can automate data syncing between your project management tool and Excel.\n", + "\n", + "For more detailed instructions, you can refer to the [Exporting Data Documentation](#) section, which provides additional insights and troubleshooting tips.\n", + "\n", + "If you have any further questions or need assistance with anything else, feel free to ask. Happy exporting!\n", "\n", "Best regards, \n", "[Your Name] \n", - "Product Support Team\n" + "Product Specialist\n" ] } ], - "execution_count": 9 + "execution_count": 8 }, { "metadata": {}, diff --git a/notebooks/kinference/KIClassification.ipynb b/notebooks/kinference/KIClassification.ipynb index ef132cc..6872936 100644 --- a/notebooks/kinference/KIClassification.ipynb +++ b/notebooks/kinference/KIClassification.ipynb @@ -5,15 +5,22 @@ "metadata": { "collapsed": true, "ExecuteTime": { - "end_time": "2025-02-10T13:00:12.108015Z", - "start_time": "2025-02-10T13:00:11.530587Z" + "end_time": "2025-11-30T14:10:40.342805Z", + "start_time": "2025-11-30T14:10:33.108236Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_3_jupyter", + "Line_4_jupyter", + "Line_5_jupyter" + ] } }, "source": [ "%use kotlin-dl\n", "\n", - "val kinferenceVersion = \"0.2.26\"\n", - "val ktorVersion = \"3.0.3\"\n", + "val kinferenceVersion = \"0.2.27\"\n", + "val ktorVersion = \"3.3.3\"\n", "\n", "USE {\n", " repositories {\n", @@ -39,8 +46,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:00:12.347215Z", - "start_time": "2025-02-10T13:00:12.295281Z" + "end_time": "2025-11-30T14:10:40.394384Z", + "start_time": "2025-11-30T14:10:40.344734Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_6_jupyter" + ] } }, "cell_type": "code", @@ -76,8 +88,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:00:34.395122Z", - "start_time": "2025-02-10T13:00:34.137897Z" + "end_time": "2025-11-30T14:10:40.671158Z", + "start_time": "2025-11-30T14:10:40.398352Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_7_jupyter" + ] } }, "cell_type": "code", @@ -144,8 +161,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:00:42.121114Z", - "start_time": "2025-02-10T13:00:42.095847Z" + "end_time": "2025-11-30T14:10:40.710096Z", + "start_time": "2025-11-30T14:10:40.672181Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_8_jupyter" + ] } }, "cell_type": "code", @@ -160,8 +182,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:00:48.526585Z", - "start_time": "2025-02-10T13:00:48.451536Z" + "end_time": "2025-11-30T14:10:40.833103Z", + "start_time": "2025-11-30T14:10:40.711316Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_9_jupyter" + ] } }, "cell_type": "code", @@ -183,8 +210,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:00:53.440965Z", - "start_time": "2025-02-10T13:00:52.959882Z" + "end_time": "2025-11-30T14:10:41.338242Z", + "start_time": "2025-11-30T14:10:40.833958Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_10_jupyter" + ] } }, "cell_type": "code", @@ -198,8 +230,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:00:58.001898Z", - "start_time": "2025-02-10T13:00:57.796134Z" + "end_time": "2025-11-30T14:10:41.694368Z", + "start_time": "2025-11-30T14:10:41.339067Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_11_jupyter" + ] } }, "cell_type": "code", @@ -245,8 +282,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:01:04.122663Z", - "start_time": "2025-02-10T13:01:04.003458Z" + "end_time": "2025-11-30T14:10:41.922928Z", + "start_time": "2025-11-30T14:10:41.695266Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_12_jupyter" + ] } }, "cell_type": "code", @@ -276,8 +318,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:01:20.419350Z", - "start_time": "2025-02-10T13:01:20.390133Z" + "end_time": "2025-11-30T14:10:41.987595Z", + "start_time": "2025-11-30T14:10:41.926778Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_13_jupyter" + ] } }, "cell_type": "code", @@ -292,8 +339,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:02:55.575404Z", - "start_time": "2025-02-10T13:02:41.686551Z" + "end_time": "2025-11-30T14:11:04.065051Z", + "start_time": "2025-11-30T14:10:41.989196Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_14_jupyter" + ] } }, "cell_type": "code", @@ -327,9 +379,8 @@ "output_type": "stream", "text": [ "Downloading model from: https://github.com/onnx/models/raw/main/validated/vision/classification/caffenet/model/caffenet-12.onnx\n", - "File already exists at /Users/pavel.gorgulov/Projects/Kotlin/Kotlin-AI-Examples/notebooks/kinference/.cache/CaffeNet.onnx. Skipping download.\n", + "Predefined directory doesn't exist. Creating directory at /Users/pavel.gorgulov/Projects/main_project/AI/Kotlin-AI-Examples/notebooks/kinference//.cache/.\n", "Downloading synset from: https://s3.amazonaws.com/onnx-model-zoo/synset.txt\n", - "File already exists at /Users/pavel.gorgulov/Projects/Kotlin/Kotlin-AI-Examples/notebooks/kinference/.cache/synset.txt. Skipping download.\n", "Loading model...\n", "Creating inputs...\n", "Starting inference...\n", @@ -1136,7 +1187,7 @@ ] } ], - "execution_count": 11 + "execution_count": 10 } ], "metadata": { diff --git a/notebooks/kinference/KIGPT2.ipynb b/notebooks/kinference/KIGPT2.ipynb index a1a0b34..a22136a 100644 --- a/notebooks/kinference/KIGPT2.ipynb +++ b/notebooks/kinference/KIGPT2.ipynb @@ -5,13 +5,13 @@ "metadata": { "collapsed": true, "ExecuteTime": { - "end_time": "2025-02-10T13:05:15.655111Z", - "start_time": "2025-02-10T13:05:15.193997Z" + "end_time": "2025-11-30T14:13:00.062506Z", + "start_time": "2025-11-30T14:12:59.729116Z" } }, "source": [ - "val kinferenceVersion = \"0.2.26\"\n", - "val ktorVersion = \"3.0.3\"\n", + "val kinferenceVersion = \"0.2.27\"\n", + "val ktorVersion = \"3.3.3\"\n", "\n", "USE {\n", " repositories {\n", @@ -42,8 +42,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:05:20.392581Z", - "start_time": "2025-02-10T13:05:20.320209Z" + "end_time": "2025-11-30T14:13:00.135323Z", + "start_time": "2025-11-30T14:13:00.063522Z" } }, "cell_type": "code", @@ -75,8 +75,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:05:28.271120Z", - "start_time": "2025-02-10T13:05:27.942767Z" + "end_time": "2025-11-30T14:13:00.541611Z", + "start_time": "2025-11-30T14:13:00.135922Z" } }, "cell_type": "code", @@ -170,8 +170,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:05:32.892098Z", - "start_time": "2025-02-10T13:05:32.865173Z" + "end_time": "2025-11-30T14:13:00.565149Z", + "start_time": "2025-11-30T14:13:00.542084Z" } }, "cell_type": "code", @@ -186,8 +186,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:05:38.083086Z", - "start_time": "2025-02-10T13:05:38.054141Z" + "end_time": "2025-11-30T14:13:00.589555Z", + "start_time": "2025-11-30T14:13:00.565572Z" } }, "cell_type": "code", @@ -201,8 +201,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:07:03.115746Z", - "start_time": "2025-02-10T13:05:49.181775Z" + "end_time": "2025-11-30T14:14:22.461856Z", + "start_time": "2025-11-30T14:13:00.589988Z" } }, "cell_type": "code", @@ -250,7 +250,7 @@ "output_type": "stream", "text": [ "Downloading model from: https://github.com/onnx/models/raw/main/validated/text/machine_comprehension/gpt-2/model/gpt2-lm-head-10.onnx\n", - "Predefined directory doesn't exist. Creating directory at /Users/pavel.gorgulov/Projects/Kotlin/Kotlin-AI-Examples/notebooks/kinference//.cache/.\n", + "File already exists at /Users/pavel.gorgulov/Projects/main_project/AI/Kotlin-AI-Examples/notebooks/kinference/.cache/gpt2-lm-head-10.onnx. Skipping download.\n", "Loading model...\n", "Here goes the test text for generation:\n", "Neurogenesis is most active during embryonic development and is responsible for producing all the various types of neurons of the organism, but it continues throughout adult life in a variety of organisms. Once born, neurons do not divide (see mitosis), and many will live the lifespan of the animal, except under extraordinary and usually pathogenic circumstances.\n", @@ -261,7 +261,7 @@ ] } ], - "execution_count": 7 + "execution_count": 6 } ], "metadata": { diff --git a/notebooks/kinference/ORTClassification.ipynb b/notebooks/kinference/ORTClassification.ipynb index 5a12217..cc1cdc8 100644 --- a/notebooks/kinference/ORTClassification.ipynb +++ b/notebooks/kinference/ORTClassification.ipynb @@ -5,15 +5,22 @@ "metadata": { "collapsed": true, "ExecuteTime": { - "end_time": "2025-02-10T13:11:49.634012Z", - "start_time": "2025-02-10T13:11:49.034388Z" + "end_time": "2025-11-30T14:12:09.605811Z", + "start_time": "2025-11-30T14:12:05.317355Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_3_jupyter", + "Line_4_jupyter", + "Line_5_jupyter" + ] } }, "source": [ "%use kotlin-dl\n", "\n", - "val kinferenceVersion = \"0.2.26\"\n", - "val ktorVersion = \"3.0.3\"\n", + "val kinferenceVersion = \"0.2.27\"\n", + "val ktorVersion = \"3.3.3\"\n", "\n", "USE {\n", " repositories {\n", @@ -38,8 +45,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:11:51.657130Z", - "start_time": "2025-02-10T13:11:51.591525Z" + "end_time": "2025-11-30T14:12:09.661607Z", + "start_time": "2025-11-30T14:12:09.607087Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_6_jupyter" + ] } }, "cell_type": "code", @@ -75,8 +87,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:12:04.361732Z", - "start_time": "2025-02-10T13:12:04.112986Z" + "end_time": "2025-11-30T14:12:09.972083Z", + "start_time": "2025-11-30T14:12:09.662122Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_7_jupyter" + ] } }, "cell_type": "code", @@ -144,8 +161,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:12:11.084298Z", - "start_time": "2025-02-10T13:12:11.056438Z" + "end_time": "2025-11-30T14:12:10.019590Z", + "start_time": "2025-11-30T14:12:09.975375Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_8_jupyter" + ] } }, "cell_type": "code", @@ -160,8 +182,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:12:15.618890Z", - "start_time": "2025-02-10T13:12:15.028959Z" + "end_time": "2025-11-30T14:12:10.379416Z", + "start_time": "2025-11-30T14:12:10.020095Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_9_jupyter" + ] } }, "cell_type": "code", @@ -186,8 +213,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:12:21.225331Z", - "start_time": "2025-02-10T13:12:21.003035Z" + "end_time": "2025-11-30T14:12:10.647139Z", + "start_time": "2025-11-30T14:12:10.379849Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_10_jupyter" + ] } }, "cell_type": "code", @@ -233,8 +265,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:12:25.643303Z", - "start_time": "2025-02-10T13:12:25.515901Z" + "end_time": "2025-11-30T14:12:10.796711Z", + "start_time": "2025-11-30T14:12:10.648082Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_11_jupyter" + ] } }, "cell_type": "code", @@ -264,8 +301,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:12:31.362861Z", - "start_time": "2025-02-10T13:12:31.333284Z" + "end_time": "2025-11-30T14:12:10.821776Z", + "start_time": "2025-11-30T14:12:10.797424Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_12_jupyter" + ] } }, "cell_type": "code", @@ -280,8 +322,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:12:50.695940Z", - "start_time": "2025-02-10T13:12:37.789138Z" + "end_time": "2025-11-30T14:12:12.720288Z", + "start_time": "2025-11-30T14:12:10.822477Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_13_jupyter" + ] } }, "cell_type": "code", @@ -315,8 +362,9 @@ "output_type": "stream", "text": [ "Downloading model from: https://github.com/onnx/models/raw/main/validated/vision/classification/caffenet/model/caffenet-12.onnx\n", - "Predefined directory doesn't exist. Creating directory at /Users/pavel.gorgulov/Projects/Kotlin/Kotlin-AI-Examples/notebooks/kinference//.cache/.\n", + "File already exists at /Users/pavel.gorgulov/Projects/main_project/AI/Kotlin-AI-Examples/notebooks/kinference/.cache/CaffeNet.onnx. Skipping download.\n", "Downloading synset from: https://s3.amazonaws.com/onnx-model-zoo/synset.txt\n", + "File already exists at /Users/pavel.gorgulov/Projects/main_project/AI/Kotlin-AI-Examples/notebooks/kinference/.cache/synset.txt. Skipping download.\n", "Loading model...\n", "Creating inputs...\n", "Starting inference...\n", diff --git a/notebooks/kinference/ORTGPT2.ipynb b/notebooks/kinference/ORTGPT2.ipynb index 1b18b89..dcad4e9 100644 --- a/notebooks/kinference/ORTGPT2.ipynb +++ b/notebooks/kinference/ORTGPT2.ipynb @@ -5,13 +5,13 @@ "metadata": { "collapsed": true, "ExecuteTime": { - "end_time": "2025-02-10T13:27:05.671253Z", - "start_time": "2025-02-10T13:27:05.206956Z" + "end_time": "2025-11-30T14:20:20.047550Z", + "start_time": "2025-11-30T14:20:15.878117Z" } }, "source": [ - "val kinferencerVersion = \"0.2.26\"\n", - "val ktorVersion = \"3.0.3\"\n", + "val kinferenceVersion = \"0.2.27\"\n", + "val ktorVersion = \"3.3.3\"\n", "\n", "USE {\n", " repositories {\n", @@ -20,11 +20,11 @@ " maven(\"https://packages.jetbrains.team/maven/p/grazi/grazie-platform-public\")\n", " }\n", " dependencies {\n", - " implementation(\"io.kinference:inference-core-jvm:$kinferencerVersion\")\n", - " implementation(\"io.kinference:inference-ort-jvm:$kinferencerVersion\")\n", - " implementation(\"io.kinference:serializer-protobuf-jvm:$kinferencerVersion\")\n", - " implementation(\"io.kinference:utils-common-jvm:$kinferencerVersion\")\n", - " implementation(\"io.kinference:ndarray-core-jvm:$kinferencerVersion\")\n", + " implementation(\"io.kinference:inference-core-jvm:$kinferenceVersion\")\n", + " implementation(\"io.kinference:inference-ort-jvm:$kinferenceVersion\")\n", + " implementation(\"io.kinference:serializer-protobuf-jvm:$kinferenceVersion\")\n", + " implementation(\"io.kinference:utils-common-jvm:$kinferenceVersion\")\n", + " implementation(\"io.kinference:ndarray-core-jvm:$kinferenceVersion\")\n", "\n", " implementation(\"io.ktor:ktor-client-core-jvm:$ktorVersion\")\n", " implementation(\"io.ktor:ktor-client-cio-jvm:$ktorVersion\")\n", @@ -43,8 +43,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:27:05.732096Z", - "start_time": "2025-02-10T13:27:05.678435Z" + "end_time": "2025-11-30T14:20:20.102917Z", + "start_time": "2025-11-30T14:20:20.048645Z" } }, "cell_type": "code", @@ -79,8 +79,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:27:06.563564Z", - "start_time": "2025-02-10T13:27:06.070567Z" + "end_time": "2025-11-30T14:20:20.618856Z", + "start_time": "2025-11-30T14:20:20.103273Z" } }, "cell_type": "code", @@ -185,8 +185,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:27:06.737944Z", - "start_time": "2025-02-10T13:27:06.715791Z" + "end_time": "2025-11-30T14:20:20.652992Z", + "start_time": "2025-11-30T14:20:20.619392Z" } }, "cell_type": "code", @@ -201,8 +201,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:27:07.461104Z", - "start_time": "2025-02-10T13:27:07.440849Z" + "end_time": "2025-11-30T14:20:20.679822Z", + "start_time": "2025-11-30T14:20:20.654714Z" } }, "cell_type": "code", @@ -216,8 +216,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-02-10T13:27:38.180925Z", - "start_time": "2025-02-10T13:27:09.793527Z" + "end_time": "2025-11-30T14:20:27.481340Z", + "start_time": "2025-11-30T14:20:20.680306Z" } }, "cell_type": "code", @@ -265,6 +265,7 @@ "output_type": "stream", "text": [ "Downloading model from: https://github.com/onnx/models/raw/main/validated/text/machine_comprehension/gpt-2/model/gpt2-lm-head-10.onnx\n", + "File already exists at /Users/pavel.gorgulov/Projects/main_project/AI/Kotlin-AI-Examples/notebooks/kinference/.cache/gpt2-lm-head-10.onnx. Skipping download.\n", "Loading model...\n", "Here goes the test text for generation:\n", "Neurogenesis is most active during embryonic development and is responsible for producing all the various types of neurons of the organism, but it continues throughout adult life in a variety of organisms. Once born, neurons do not divide (see mitosis), and many will live the lifespan of the animal, except under extraordinary and usually pathogenic circumstances.\n", diff --git a/notebooks/langchain4j/LangChain4j_Overview.ipynb b/notebooks/langchain4j/LangChain4j_Overview.ipynb index 222926b..6fcee5f 100644 --- a/notebooks/langchain4j/LangChain4j_Overview.ipynb +++ b/notebooks/langchain4j/LangChain4j_Overview.ipynb @@ -8,15 +8,15 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:10:53.349664Z", - "start_time": "2025-05-11T19:10:52.333046Z" + "end_time": "2025-11-30T14:35:45.330445Z", + "start_time": "2025-11-30T14:35:44.402588Z" } }, "cell_type": "code", "source": [ "%useLatestDescriptors\n", "%use coroutines\n", - "%use langchain4j(1.0.0-beta3)" + "%use langchain4j" ], "outputs": [], "execution_count": 1 @@ -24,8 +24,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:10:53.381730Z", - "start_time": "2025-05-11T19:10:53.355638Z" + "end_time": "2025-11-30T14:35:45.369560Z", + "start_time": "2025-11-30T14:35:45.331944Z" } }, "cell_type": "code", @@ -36,8 +36,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:10:53.440004Z", - "start_time": "2025-05-11T19:10:53.384316Z" + "end_time": "2025-11-30T14:35:45.443424Z", + "start_time": "2025-11-30T14:35:45.370295Z" } }, "cell_type": "code", @@ -59,8 +59,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:10:58.628384Z", - "start_time": "2025-05-11T19:10:53.443924Z" + "end_time": "2025-11-30T14:35:53.859607Z", + "start_time": "2025-11-30T14:35:45.452180Z" } }, "cell_type": "code", @@ -69,12 +69,14 @@ { "data": { "text/plain": [ - "In Kotlin, you can overload the `plus` operator for a data class by defining the `plus` function. To create a `Point` data class that supports addition using the `+` operator, you can follow these steps:\n", + "In Kotlin, you can overload the `plus` operator for a data class by defining the `plus` function. For your `Point` data class, you can create a function that takes another `Point` as a parameter and returns a new `Point` that represents the sum of the two points.\n", "\n", - "1. Define the `Point` data class with properties for the x and y coordinates.\n", + "Here’s how you can do it:\n", + "\n", + "1. Define your `Point` data class with `x` and `y` properties.\n", "2. Implement the `plus` operator function to add two `Point` instances.\n", "\n", - "Here's an example of how you can do this:\n", + "Here’s an example implementation:\n", "\n", "```kotlin\n", "data class Point(val x: Int, val y: Int) {\n", @@ -86,18 +88,18 @@ "fun main() {\n", " val point1 = Point(1, 2)\n", " val point2 = Point(3, 4)\n", - " \n", + "\n", " val result = point1 + point2\n", " println(result) // Output: Point(x=4, y=6)\n", "}\n", "```\n", "\n", "### Explanation:\n", - "- The `Point` data class has two properties: `x` and `y`, both of type `Int`.\n", - "- The `operator fun plus(other: Point): Point` function is defined to overload the `+` operator. It takes another `Point` as a parameter and returns a new `Point` whose coordinates are the sum of the corresponding coordinates of the two points.\n", - "- In the `main` function, two `Point` instances are created, and when you use the `+` operator, it calls the `plus` function, resulting in a new `Point` that represents the sum of the two points.\n", + "- The `data class Point` defines a simple point with `x` and `y` coordinates.\n", + "- The `operator fun plus(other: Point): Point` function is defined to overload the `+` operator. It takes another `Point` as a parameter and returns a new `Point` with the summed coordinates.\n", + "- In the `main` function, we create two `Point` instances and use the overloaded `+` operator to add them together, resulting in a new `Point`.\n", "\n", - "Now you can add two `Point` instances together using the `+` operator!" + "This allows you to use the `+` operator in a natural way with your `Point` instances." ] }, "execution_count": 4, @@ -120,20 +122,18 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:04.892251Z", - "start_time": "2025-05-11T19:10:58.632971Z" + "end_time": "2025-11-30T14:36:03.794085Z", + "start_time": "2025-11-30T14:35:53.867266Z" } }, "cell_type": "code", "source": [ "import dev.langchain4j.data.message.SystemMessage.systemMessage\n", "import dev.langchain4j.data.message.UserMessage.userMessage\n", - "import dev.langchain4j.model.chat.request.chatRequest\n", "\n", - "val response = model.chat(\n", - " chatRequest {\n", - " messages += systemMessage(\n", - " \"\"\"\n", + "val messages = buildList {\n", + " add(systemMessage(\n", + " \"\"\"\n", " You are an expert Kotlin developer. Your task is to write idiomatic Kotlin code. Follow these guidelines:\n", " - Use clean code principles.\n", " - Write concise and readable APIs.\n", @@ -144,58 +144,60 @@ " - Structure the code clearly and use best practices.\n", " - Provide concise and to-the-point responses.\n", " \"\"\".trimIndent()\n", - " )\n", - " messages += userMessage(\n", - " \"\"\"\n", + " ))\n", + " add(userMessage(\n", + " \"\"\"\n", " What foldRight does? What will be the intermidieate and the end result of the foldRight function call?\n", " ```kotlin\n", " \"baba\".foldRight(\"\") { x, acc -> \"${'$'}x${'$'}{acc}${'$'}{acc}\" })\n", " ```\n", - " \"\"\".trimIndent()\n", - " )\n", - " }\n", - ").aiMessage()\n", + " \"\"\".trimIndent()\n", + " ))\n", + "}\n", + "val response = model.chat(messages).aiMessage()\n", "response" ], "outputs": [ { "data": { "text/plain": [ - "AiMessage { text = \"In Kotlin, the `foldRight` function is used to accumulate a value starting from the rightmost element of a collection (or a string, in this case). It takes an initial accumulator value and a lambda function that specifies how to combine each element with the accumulator.\n", + "AiMessage { text = \"In Kotlin, the `foldRight` function is a higher-order function that processes a collection or a string from the last element to the first. It takes an initial accumulator value and a lambda function that combines each element with the accumulator.\n", "\n", - "Here's a breakdown of the provided code:\n", + "In your example, the `foldRight` function is called on the string `\"baba\"` with an initial accumulator value of `\"\"` (an empty string). The lambda function takes two parameters: `x` (the current character from the string) and `acc` (the accumulated result).\n", "\n", - "```kotlin\n", - "val result = \"baba\".foldRight(\"\") { x, acc -> \"$x${acc}${acc}\" }\n", - "```\n", + "Here's how the `foldRight` operation works step-by-step for the string `\"baba\"`:\n", "\n", - "### Explanation:\n", - "- The string `\"baba\"` is processed from right to left.\n", - "- The initial accumulator (`acc`) is an empty string `\"\"`.\n", - "- For each character `x` in the string, the lambda function combines `x` with the current accumulator `acc` and appends `acc` again.\n", + "1. Start with the last character `'a'`:\n", + " - `x = 'a'`, `acc = \"\"`\n", + " - Result: `\"a$acc$acc\"` → `\"a\"`\n", "\n", - "### Intermediate Steps:\n", - "1. Start with `acc = \"\"` (initial value).\n", - "2. Process the last character `'a'`:\n", - " - `x = 'a'`, `acc = \"\"` → Result: `\"a\"`\n", - "3. Process the second last character `'b'`:\n", - " - `x = 'b'`, `acc = \"a\"` → Result: `\"ba\"`\n", - "4. Process the third last character `'a'`:\n", - " - `x = 'a'`, `acc = \"ba\"` → Result: `\"abaa\"`\n", - "5. Process the first character `'b'`:\n", - " - `x = 'b'`, `acc = \"abaa\"` → Result: `\"babaa\"`\n", + "2. Move to the second last character `'b'`:\n", + " - `x = 'b'`, `acc = \"a\"`\n", + " - Result: `\"b$a$a\"` → `\"bab\"`\n", + "\n", + "3. Move to the third last character `'a'`:\n", + " - `x = 'a'`, `acc = \"bab\"`\n", + " - Result: `\"a$bab$bab\"` → `\"ababab\"`\n", + "\n", + "4. Move to the first character `'b'`:\n", + " - `x = 'b'`, `acc = \"ababab\"`\n", + " - Result: `\"b$ababab$ababab\"` → `\"bababababab\"`\n", + "\n", + "### Intermediate Results:\n", + "- After processing `'a'`: `\"a\"`\n", + "- After processing `'b'`: `\"bab\"`\n", + "- After processing `'a'`: `\"ababab\"`\n", + "- After processing `'b'`: `\"bababababab\"`\n", "\n", "### Final Result:\n", - "The final result of the `foldRight` function call is `\"babaa\"`.\n", + "The final result of the `foldRight` function call will be `\"bababababab\"`.\n", + "\n", + "Here's the complete code snippet for clarity:\n", "\n", - "### Summary:\n", - "- **Intermediate Results**:\n", - " - After processing 'a': `\"a\"`\n", - " - After processing 'b': `\"ba\"`\n", - " - After processing 'a': `\"abaa\"`\n", - " - After processing 'b': `\"babaa\"`\n", - " \n", - "- **Final Result**: `\"babaa\"`\" toolExecutionRequests = null }" + "```kotlin\n", + "val result = \"baba\".foldRight(\"\") { x, acc -> \"$x$acc$acc\" }\n", + "println(result) // Output: bababababab\n", + "```\", thinking = null, toolExecutionRequests = [], attributes = {} }" ] }, "execution_count": 5, @@ -213,8 +215,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:04.936348Z", - "start_time": "2025-05-11T19:11:04.898055Z" + "end_time": "2025-11-30T14:36:03.836447Z", + "start_time": "2025-11-30T14:36:03.795121Z" } }, "cell_type": "code", @@ -229,8 +231,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:04.995486Z", - "start_time": "2025-05-11T19:11:04.938868Z" + "end_time": "2025-11-30T14:36:03.933794Z", + "start_time": "2025-11-30T14:36:03.843246Z" } }, "cell_type": "code", @@ -239,7 +241,7 @@ "\n", "val aiService = AiServices\n", " .builder(AssistantFirst::class.java)\n", - " .chatLanguageModel(model)\n", + " .chatModel(model)\n", " .systemMessageProvider {\n", " \"\"\"\n", " You are an expert Kotlin developer. Your task is to write idiomatic Kotlin code. Follow these guidelines:\n", @@ -261,8 +263,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:08.386725Z", - "start_time": "2025-05-11T19:11:04.998861Z" + "end_time": "2025-11-30T14:36:09.917221Z", + "start_time": "2025-11-30T14:36:03.934958Z" } }, "cell_type": "code", @@ -276,7 +278,7 @@ { "data": { "text/plain": [ - "Here’s an idiomatic Kotlin code snippet that creates a flow of five elements and prints each one using the `collect` function:\n", + "Here's a simple Kotlin program that creates a flow of five elements (1, 2, 3, 4, and 5) and prints each element using the `collect` function. The code follows idiomatic Kotlin conventions and includes all necessary imports.\n", "\n", "```kotlin\n", "import kotlinx.coroutines.flow.Flow\n", @@ -298,9 +300,10 @@ "```\n", "\n", "### Explanation:\n", - "- The `createFlow` function creates a flow of integers from 1 to 5 using the `flow` builder.\n", - "- The `main` function uses `runBlocking` to run a coroutine that collects the flow and prints each emitted value.\n", - "- The `collect` function is used without any arguments, as requested." + "- **Imports**: Only the necessary classes are imported for clarity.\n", + "- **`main` function**: Uses `runBlocking` to create a coroutine scope and collect the flow.\n", + "- **`createFlow` function**: Generates a flow of integers from 1 to 5 using the `flow` builder and emits each value.\n", + "- **`collect`**: The `collect` function is called with a lambda to print each emitted value." ] }, "execution_count": 8, @@ -318,8 +321,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:08.420558Z", - "start_time": "2025-05-11T19:11:08.392140Z" + "end_time": "2025-11-30T14:36:09.973430Z", + "start_time": "2025-11-30T14:36:09.932348Z" } }, "cell_type": "code", @@ -350,8 +353,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:08.448573Z", - "start_time": "2025-05-11T19:11:08.423195Z" + "end_time": "2025-11-30T14:36:10.015417Z", + "start_time": "2025-11-30T14:36:09.974437Z" } }, "cell_type": "code", @@ -362,8 +365,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:13.444693Z", - "start_time": "2025-05-11T19:11:08.452131Z" + "end_time": "2025-11-30T14:36:14.025467Z", + "start_time": "2025-11-30T14:36:10.015699Z" } }, "cell_type": "code", @@ -377,13 +380,12 @@ { "data": { "text/plain": [ - "Here's a concise and idiomatic Kotlin code snippet that creates a flow of five elements and prints each of them using the `collect` function:\n", + "Here's a concise and idiomatic Kotlin code snippet that creates a flow of five elements and prints each one using the `collect` function:\n", "\n", "```kotlin\n", "import kotlinx.coroutines.flow.Flow\n", "import kotlinx.coroutines.flow.flow\n", "import kotlinx.coroutines.runBlocking\n", - "import kotlinx.coroutines.flow.collect\n", "\n", "fun main() = runBlocking {\n", " createFlow().collect { value ->\n", @@ -399,10 +401,9 @@ "```\n", "\n", "### Explanation:\n", - "- **Imports**: Specific imports are used for clarity.\n", - "- **Flow Creation**: The `createFlow` function generates a flow of integers from 1 to 5.\n", - "- **Collecting Values**: The `collect` function is used to print each emitted value.\n", - "- **runBlocking**: This is used to run the coroutine in the main function, ensuring that the flow is collected properly." + "- We use `runBlocking` to create a coroutine scope for the main function.\n", + "- The `createFlow` function generates a flow of integers from 1 to 5 using the `flow` builder.\n", + "- The `collect` function is called to print each emitted value." ] }, "execution_count": 11, @@ -425,31 +426,34 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:20.204269Z", - "start_time": "2025-05-11T19:11:13.450493Z" + "end_time": "2025-11-30T14:36:20.282438Z", + "start_time": "2025-11-30T14:36:14.028495Z" } }, "cell_type": "code", "source": [ - "import dev.langchain4j.model.chat.chat\n", - "\n", "runBlocking {\n", - " model.chat {\n", - " messages += systemMessage(\"You are an expert Kotlin developer.\")\n", - " messages += userMessage(\n", - " \"\"\"\n", + " val messages = buildList {\n", + " add(systemMessage(\"You are an expert Kotlin developer.\"))\n", + " add(\n", + " userMessage(\n", + " \"\"\"\n", " Write a main function that creates a flow of five elements 1, 2, 3, 4, and 5, and prints each one of them. Use the collect function without any arguments to do so.\n", " Make sure to include all imports, but don’t use star imports.\n", " \"\"\".trimIndent()\n", + " )\n", " )\n", " }\n", + " model.chat(messages)\n", "}\n" ], "outputs": [ { "data": { "text/plain": [ - "ChatResponse { aiMessage = AiMessage { text = \"Certainly! Below is a Kotlin program that creates a flow of five elements (1, 2, 3, 4, and 5) and prints each of them using the `collect` function without any arguments. Make sure you have the necessary dependencies for Kotlin Coroutines in your project.\n", + "ChatResponse { aiMessage = AiMessage { text = \"Certainly! Below is a Kotlin program that creates a flow of five elements (1, 2, 3, 4, and 5) and prints each one of them using the `collect` function without any arguments. \n", + "\n", + "Make sure you have the necessary dependencies for Kotlin Coroutines in your project to run this code.\n", "\n", "```kotlin\n", "import kotlinx.coroutines.CoroutineScope\n", @@ -462,29 +466,24 @@ "fun main() = runBlocking {\n", " val numberFlow: Flow = flow {\n", " for (i in 1..5) {\n", - " emit(i)\n", + " emit(i) // Emit numbers 1 to 5\n", " }\n", " }\n", "\n", - " numberFlow.collect()\n", - "}\n", - "\n", - "fun Flow.collect() {\n", - " CoroutineScope(Dispatchers.Default).launch {\n", - " this@collect.collect { value ->\n", - " println(value)\n", - " }\n", + " // Collecting the flow\n", + " numberFlow.collect { value ->\n", + " println(value) // Print each emitted value\n", " }\n", "}\n", "```\n", "\n", "### Explanation:\n", - "1. **Imports**: The necessary imports for coroutines and flow are included.\n", - "2. **Flow Creation**: A flow of integers from 1 to 5 is created using the `flow` builder.\n", - "3. **Collecting the Flow**: The `collect` function is defined as an extension function on `Flow`, which collects the emitted values and prints them.\n", - "4. **Coroutine Context**: The `runBlocking` function is used to run the main coroutine, ensuring that the flow collection completes before the program exits.\n", + "- We import necessary classes from the `kotlinx.coroutines` and `kotlinx.coroutines.flow` packages.\n", + "- We define a `Flow` that emits numbers from 1 to 5.\n", + "- We use `runBlocking` to create a coroutine scope for our main function, allowing us to call suspend functions like `collect`.\n", + "- The `collect` function is called on the flow, and it prints each emitted value. \n", "\n", - "Make sure to run this code in an environment that supports Kotlin Coroutines, such as a Kotlin application or a compatible IDE.\" toolExecutionRequests = null }, metadata = OpenAiChatResponseMetadata{id='chatcmpl-BW6MrM6lgSrROBUZENmM8ZnwohSha', modelName='gpt-4o-mini-2024-07-18', tokenUsage=OpenAiTokenUsage{ inputTokenCount = 77, inputTokensDetails=InputTokensDetails[cachedTokens=0], outputTokenCount = 319, outputTokensDetails=OutputTokensDetails[reasoningTokens=0], totalTokenCount = 396}, finishReason=STOP, created=1746990673, serviceTier='default', systemFingerprint='fp_0392822090'} }" + "To run this code, ensure you have the Kotlin Coroutines library included in your build system (like Gradle or Maven).\", thinking = null, toolExecutionRequests = [], attributes = {} }, metadata = OpenAiChatResponseMetadata{id='chatcmpl-Chcp4vcJmQVcHUQOP4bS0RclsXefx', modelName='gpt-4o-mini-2024-07-18', tokenUsage=OpenAiTokenUsage { inputTokenCount = 77, inputTokensDetails = OpenAiTokenUsage.InputTokensDetails { cachedTokens = 0 }, outputTokenCount = 298, outputTokensDetails = OpenAiTokenUsage.OutputTokensDetails { reasoningTokens = 0 }, totalTokenCount = 375 }, finishReason=STOP, created=1764513374, serviceTier='default', systemFingerprint='fp_eca0ce8298', rawHttpResponse=dev.langchain4j.http.client.SuccessfulHttpResponse@20bcfa2b, rawServerSentEvents=[]} }" ] }, "execution_count": 12, @@ -502,14 +501,26 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:28.315517Z", - "start_time": "2025-05-11T19:11:20.222350Z" + "end_time": "2025-11-30T14:36:20.323855Z", + "start_time": "2025-11-30T14:36:20.283826Z" + } + }, + "cell_type": "code", + "source": "@file:DependsOn(\"dev.langchain4j:langchain4j-kotlin:1.9.1-beta17\")", + "outputs": [], + "execution_count": 13 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2025-11-30T14:36:27.512647Z", + "start_time": "2025-11-30T14:36:20.324560Z" } }, "cell_type": "code", "source": [ - "import dev.langchain4j.model.chat.StreamingChatLanguageModelReply\n", - "import dev.langchain4j.model.chat.chatFlow\n", + "import dev.langchain4j.kotlin.model.chat.StreamingChatModelReply\n", + "import dev.langchain4j.kotlin.model.chat.chatFlow\n", "import dev.langchain4j.model.openai.OpenAiStreamingChatModel\n", "import kotlinx.coroutines.flow.Flow\n", "\n", @@ -523,8 +534,8 @@ " messages += systemMessage(\"You are an expert Kotlin developer.\")\n", " messages += userMessage(\n", " \"\"\"\n", - " Write a main function that creates a flow of five elements 1, 2, 3, 4, and 5, and prints each one of them. Use the collect function without any arguments to do so.\n", - " Make sure to include all imports, but don’t use star imports.\n", + " Write a main function that creates a flow of five elements 1, 2, 3, 4, and 5, and prints each one of them. Use the collect function without any arguments to do so.\n", + " Make sure to include all imports, but don’t use star imports.\n", " \"\"\".trimIndent()\n", " )\n", "}\n", @@ -532,13 +543,15 @@ "runBlocking {\n", " flowResponse.collect {\n", " when (it) {\n", - " is StreamingChatLanguageModelReply.PartialResponse -> {\n", + " is StreamingChatModelReply.PartialResponse -> {\n", " print(it.partialResponse) // Stream output as it arrives\n", " }\n", - " is StreamingChatLanguageModelReply.CompleteResponse -> {\n", + "\n", + " is StreamingChatModelReply.CompleteResponse -> {\n", " println(\"\\nComplete: ${it.response.aiMessage().text()}\")\n", " }\n", - " is StreamingChatLanguageModelReply.Error -> {\n", + "\n", + " is StreamingChatModelReply.Error -> {\n", " println(\"Error occurred: ${it.cause.message}\")\n", " }\n", " }\n", @@ -550,7 +563,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Certainly! Below is a Kotlin program that creates a flow of five elements (1, 2, 3, 4, and 5) and prints each element using the `collect` function. The necessary imports are included without using star imports.\n", + "Certainly! Below is an example of a Kotlin program that creates a flow of five elements (1, 2, 3, 4, and 5) and prints each element using the `collect` function. The necessary imports are included without using star imports.\n", "\n", "```kotlin\n", "import kotlinx.coroutines.flow.Flow\n", @@ -561,32 +574,29 @@ "fun main() = runBlocking {\n", " val numberFlow: Flow = flow {\n", " for (i in 1..5) {\n", - " emit(i) // Emit each number\n", + " emit(i)\n", " }\n", " }\n", "\n", - " numberFlow.collect() { value ->\n", - " println(value) // Print each emitted value\n", - " }\n", + " numberFlow.collect()\n", "}\n", "```\n", "\n", - "### Explanation:\n", + "In this code:\n", + "\n", "- We import the necessary classes from the `kotlinx.coroutines.flow` package.\n", - "- The `main` function is defined as a coroutine using `runBlocking` to allow the use of suspending functions.\n", - "- A `Flow` of integers is created using the `flow` builder, emitting the numbers 1 through 5.\n", - "- The `collect` function is called on the flow, which takes a lambda to process each emitted value, printing it to the console. \n", + "- We define a `Flow` that emits the numbers 1 through 5.\n", + "- We use `runBlocking` to create a coroutine scope and call `collect()` on the flow to print each element. \n", "\n", - "Make sure to include the necessary dependencies for coroutines and flows in your `build.gradle` file if you're using a Gradle project:\n", + "To print each element, you can modify the `collect` function as follows:\n", "\n", - "```groovy\n", - "dependencies {\n", - " implementation \"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0\"\n", + "```kotlin\n", + "numberFlow.collect { value ->\n", + " println(value)\n", "}\n", "```\n", "\n", - "Adjust the version number as needed based on the latest available version.\n", - "Complete: Certainly! Below is a Kotlin program that creates a flow of five elements (1, 2, 3, 4, and 5) and prints each element using the `collect` function. The necessary imports are included without using star imports.\n", + "This will ensure that each emitted value is printed to the console. Here's the complete code with the print statement included:\n", "\n", "```kotlin\n", "import kotlinx.coroutines.flow.Flow\n", @@ -597,35 +607,92 @@ "fun main() = runBlocking {\n", " val numberFlow: Flow = flow {\n", " for (i in 1..5) {\n", - " emit(i) // Emit each number\n", + " emit(i)\n", " }\n", " }\n", "\n", - " numberFlow.collect() { value ->\n", - " println(value) // Print each emitted value\n", + " numberFlow.collect { value ->\n", + " println(value)\n", " }\n", "}\n", "```\n", "\n", - "### Explanation:\n", + "This will output:\n", + "\n", + "```\n", + "1\n", + "2\n", + "3\n", + "4\n", + "5\n", + "```\n", + "Complete: Certainly! Below is an example of a Kotlin program that creates a flow of five elements (1, 2, 3, 4, and 5) and prints each element using the `collect` function. The necessary imports are included without using star imports.\n", + "\n", + "```kotlin\n", + "import kotlinx.coroutines.flow.Flow\n", + "import kotlinx.coroutines.flow.flow\n", + "import kotlinx.coroutines.runBlocking\n", + "import kotlinx.coroutines.flow.collect\n", + "\n", + "fun main() = runBlocking {\n", + " val numberFlow: Flow = flow {\n", + " for (i in 1..5) {\n", + " emit(i)\n", + " }\n", + " }\n", + "\n", + " numberFlow.collect()\n", + "}\n", + "```\n", + "\n", + "In this code:\n", + "\n", "- We import the necessary classes from the `kotlinx.coroutines.flow` package.\n", - "- The `main` function is defined as a coroutine using `runBlocking` to allow the use of suspending functions.\n", - "- A `Flow` of integers is created using the `flow` builder, emitting the numbers 1 through 5.\n", - "- The `collect` function is called on the flow, which takes a lambda to process each emitted value, printing it to the console. \n", + "- We define a `Flow` that emits the numbers 1 through 5.\n", + "- We use `runBlocking` to create a coroutine scope and call `collect()` on the flow to print each element. \n", + "\n", + "To print each element, you can modify the `collect` function as follows:\n", "\n", - "Make sure to include the necessary dependencies for coroutines and flows in your `build.gradle` file if you're using a Gradle project:\n", + "```kotlin\n", + "numberFlow.collect { value ->\n", + " println(value)\n", + "}\n", + "```\n", + "\n", + "This will ensure that each emitted value is printed to the console. Here's the complete code with the print statement included:\n", + "\n", + "```kotlin\n", + "import kotlinx.coroutines.flow.Flow\n", + "import kotlinx.coroutines.flow.flow\n", + "import kotlinx.coroutines.runBlocking\n", + "import kotlinx.coroutines.flow.collect\n", + "\n", + "fun main() = runBlocking {\n", + " val numberFlow: Flow = flow {\n", + " for (i in 1..5) {\n", + " emit(i)\n", + " }\n", + " }\n", "\n", - "```groovy\n", - "dependencies {\n", - " implementation \"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0\"\n", + " numberFlow.collect { value ->\n", + " println(value)\n", + " }\n", "}\n", "```\n", "\n", - "Adjust the version number as needed based on the latest available version.\n" + "This will output:\n", + "\n", + "```\n", + "1\n", + "2\n", + "3\n", + "4\n", + "5\n", + "```\n" ] } ], - "execution_count": 13 + "execution_count": 14 }, { "metadata": {}, @@ -635,23 +702,23 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:31.606698Z", - "start_time": "2025-05-11T19:11:28.325448Z" + "end_time": "2025-11-30T14:36:27.544674Z", + "start_time": "2025-11-30T14:36:27.514287Z" } }, "cell_type": "code", "source": [ - "@file:DependsOn(\"dev.langchain4j:langchain4j-reactor:1.0.0-beta2\")\n", - "@file:DependsOn(\"org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.10.1\")" + "@file:DependsOn(\"dev.langchain4j:langchain4j-reactor:1.9.1-beta17\")\n", + "@file:DependsOn(\"org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.10.2\")" ], "outputs": [], - "execution_count": 14 + "execution_count": 15 }, { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:31.687083Z", - "start_time": "2025-05-11T19:11:31.616631Z" + "end_time": "2025-11-30T14:36:27.630197Z", + "start_time": "2025-11-30T14:36:27.545885Z" } }, "cell_type": "code", @@ -663,25 +730,25 @@ "}" ], "outputs": [], - "execution_count": 15 + "execution_count": 16 }, { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:31.711065Z", - "start_time": "2025-05-11T19:11:31.689277Z" + "end_time": "2025-11-30T14:36:27.661914Z", + "start_time": "2025-11-30T14:36:27.630975Z" } }, "cell_type": "code", "source": "val assistant = AiServices.create(AssistantThird::class.java, streamModel)", "outputs": [], - "execution_count": 16 + "execution_count": 17 }, { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:38.833393Z", - "start_time": "2025-05-11T19:11:31.714734Z" + "end_time": "2025-11-30T14:36:33.164535Z", + "start_time": "2025-11-30T14:36:27.662222Z" } }, "cell_type": "code", @@ -704,55 +771,43 @@ "name": "stdout", "output_type": "stream", "text": [ - "To create a flow of five elements and print each one using the `collect` function in Kotlin, you'll need to use the Kotlin Coroutines library. Below is a complete example that includes all necessary imports and demonstrates how to achieve this:\n", + "To create a flow of five elements (1, 2, 3, 4, and 5) and print each one of them using the `collect` function in Kotlin, you can follow the example below. This example assumes you are using Kotlin's coroutines and flow features.\n", + "\n", + "Here's the complete code:\n", "\n", "```kotlin\n", + "import kotlinx.coroutines.Dispatchers\n", + "import kotlinx.coroutines.runBlocking\n", "import kotlinx.coroutines.flow.Flow\n", "import kotlinx.coroutines.flow.flow\n", - "import kotlinx.coroutines.runBlocking\n", "import kotlinx.coroutines.flow.collect\n", "\n", "fun main() = runBlocking {\n", " // Create a flow of five elements\n", - " val numberFlow: Flow = flow {\n", + " val numbersFlow: Flow = flow {\n", " for (i in 1..5) {\n", " emit(i) // Emit each number\n", " }\n", " }\n", "\n", " // Collect and print each element from the flow\n", - " numberFlow.collect { value ->\n", - " println(value)\n", + " numbersFlow.collect { number ->\n", + " println(number)\n", " }\n", "}\n", "```\n", "\n", "### Explanation:\n", - "1. **Imports**: We import the necessary classes from the `kotlinx.coroutines.flow` package.\n", - "2. **Flow Creation**: We create a flow using the `flow` builder, emitting numbers from 1 to 5.\n", - "3. **Collecting Values**: We use the `collect` function to print each emitted value.\n", - "\n", - "### Running the Code:\n", - "To run this code, ensure you have the Kotlin Coroutines library included in your project. You can add the following dependency to your `build.gradle` file if you're using Gradle:\n", + "- We import necessary classes from the `kotlinx.coroutines` library.\n", + "- The `main` function is defined as a coroutine using `runBlocking`, which allows us to call suspend functions.\n", + "- We create a `Flow` of integers using the `flow` builder, emitting numbers from 1 to 5.\n", + "- Finally, we collect the emitted numbers using the `collect` function, printing each number as it is received. \n", "\n", - "```groovy\n", - "implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0' // Check for the latest version\n", - "```\n", - "\n", - "This example will print:\n", - "```\n", - "1\n", - "2\n", - "3\n", - "4\n", - "5\n", - "``` \n", - "\n", - "Make sure to run this code in an environment that supports Kotlin and coroutines, such as IntelliJ IDEA or a compatible Kotlin playground." + "Make sure you have the necessary dependencies for Kotlin coroutines in your build system (like Gradle or Maven) to run this code successfully." ] } ], - "execution_count": 17 + "execution_count": 18 }, { "metadata": {}, @@ -767,8 +822,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:38.920547Z", - "start_time": "2025-05-11T19:11:38.837700Z" + "end_time": "2025-11-30T14:36:33.257466Z", + "start_time": "2025-11-30T14:36:33.165965Z" } }, "cell_type": "code", @@ -806,13 +861,13 @@ "val personExtractor = AiServices.create(PersonExtractor::class.java, jsonModel)" ], "outputs": [], - "execution_count": 18 + "execution_count": 19 }, { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:39.756133Z", - "start_time": "2025-05-11T19:11:38.923529Z" + "end_time": "2025-11-30T14:36:34.098230Z", + "start_time": "2025-11-30T14:36:33.258011Z" } }, "cell_type": "code", @@ -832,18 +887,18 @@ "Person(name=John, age=42, height=1.75, married=false)" ] }, - "execution_count": 19, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], - "execution_count": 19 + "execution_count": 20 }, { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:39.803796Z", - "start_time": "2025-05-11T19:11:39.759546Z" + "end_time": "2025-11-30T14:36:34.174487Z", + "start_time": "2025-11-30T14:36:34.106024Z" } }, "cell_type": "code", @@ -866,13 +921,13 @@ "val assistant = AiServices.create(MathAssistant::class.java, jsonModel)\n" ], "outputs": [], - "execution_count": 20 + "execution_count": 21 }, { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:42.205093Z", - "start_time": "2025-05-11T19:11:39.806505Z" + "end_time": "2025-11-30T14:36:38.889828Z", + "start_time": "2025-11-30T14:36:34.175398Z" } }, "cell_type": "code", @@ -891,13 +946,13 @@ "1. Subtract 31 from both sides to isolate the term with x.\n", "2. This simplifies to 8x = -29.\n", "3. Now, divide both sides by 8 to solve for x.\n", - "4. This simplifies to x = -3.625.\n", + "4. This can be simplified to x = -3.625 or left as a fraction.\n", "Answer:\n", - "x = -3.625\n" + "x = -3.625 or x = -29/8\n" ] } ], - "execution_count": 21 + "execution_count": 22 }, { "metadata": {}, @@ -907,8 +962,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:42.266844Z", - "start_time": "2025-05-11T19:11:42.221006Z" + "end_time": "2025-11-30T14:36:38.943564Z", + "start_time": "2025-11-30T14:36:38.890872Z" } }, "cell_type": "code", @@ -935,18 +990,18 @@ "}\n", "\n", "val assistant = AiServices.builder(MathAssistant::class.java)\n", - " .chatLanguageModel(model)\n", + " .chatModel(model)\n", " .tools(Tools())\n", " .build()" ], "outputs": [], - "execution_count": 22 + "execution_count": 23 }, { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:11:54.417404Z", - "start_time": "2025-05-11T19:11:42.270026Z" + "end_time": "2025-11-30T14:36:54.733971Z", + "start_time": "2025-11-30T14:36:38.944120Z" } }, "cell_type": "code", @@ -968,46 +1023,42 @@ "text/plain": [ "Let's break down the calculations step by step:\n", "\n", - "1. **Calculate \\((5 + 10) * (20 - 3) / 4\\)**:\n", + "1. **Calculate (5 + 10) * (20 - 3) / 4**:\n", " - \\(5 + 10 = 15\\)\n", " - \\(20 - 3 = 17\\)\n", " - \\(15 * 17 = 255\\)\n", " - \\(255 / 4 = 63.75\\)\n", "\n", - "2. **Expand \\((a + b)^2\\)**:\n", - " - The expansion is \\(a^2 + 2ab + b^2\\).\n", + "2. **Calculate (a + b)^2**:\n", + " - This expression cannot be evaluated without specific values for \\(a\\) and \\(b\\).\n", "\n", - "3. **Solve the quadratic equation \\(ax^2 + bx + c = 0\\) for \\(a=1\\), \\(b=-3\\), \\(c=-4\\)**:\n", + "3. **Solve \\(ax^2 + bx + c = 0\\) for \\(a=1\\), \\(b=-3\\), \\(c=-4\\)**:\n", " - The equation becomes \\(1x^2 - 3x - 4 = 0\\).\n", - " - The roots can be found using the quadratic formula: \n", + " - The roots can be calculated using the quadratic formula:\n", " \\[\n", " x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}\n", " \\]\n", " - Here, \\(b^2 - 4ac = (-3)^2 - 4(1)(-4) = 9 + 16 = 25\\).\n", - " - Thus, the roots are:\n", - " \\[\n", - " x = \\frac{3 \\pm 5}{2}\n", - " \\]\n", - " - \\(x_1 = \\frac{8}{2} = 4\\)\n", - " - \\(x_2 = \\frac{-2}{2} = -1\\)\n", + " - Thus, \\(x = \\frac{3 \\pm 5}{2}\\).\n", + " - The roots are \\(x = 4\\) and \\(x = -1\\).\n", "\n", - "4. **Calculate the sum \\(S = n * (a1 + an) / 2\\)**:\n", - " - \\(n = 10\\), \\(a1 = 3\\), \\(an = 20\\)\n", - " - \\(S = 10 * (3 + 20) / 2 = 10 * 23 / 2 = 115\\)\n", + "4. **Calculate \\(S = n * (a1 + an) / 2\\)**:\n", + " - \\(n = 10\\), \\(a1 = 3\\), \\(an = 20\\).\n", + " - \\(S = 10 * (3 + 20) / 2 = 10 * 23 / 2 = 115\\).\n", "\n", "### Summary of Results:\n", - "- \\((5 + 10) * (20 - 3) / 4 = 63.75\\)\n", - "- \\((a + b)^2 = a^2 + 2ab + b^2\\)\n", - "- Roots of \\(x^2 - 3x - 4 = 0\\) are \\(x = 4\\) and \\(x = -1\\).\n", - "- \\(S = 115\\)" + "1. **(5 + 10) * (20 - 3) / 4 = 63.75**\n", + "2. **(a + b)^2 = Not enough information**\n", + "3. **Roots of \\(x^2 - 3x - 4 = 0\\) are \\(x = 4\\) and \\(x = -1\\)**\n", + "4. **S = 115**" ] }, - "execution_count": 23, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], - "execution_count": 23 + "execution_count": 24 } ], "metadata": { diff --git a/notebooks/langchain4j/SummarizingDocuments.ipynb b/notebooks/langchain4j/SummarizingDocuments.ipynb index 9035f29..8b57048 100644 --- a/notebooks/langchain4j/SummarizingDocuments.ipynb +++ b/notebooks/langchain4j/SummarizingDocuments.ipynb @@ -5,13 +5,13 @@ "metadata": { "collapsed": true, "ExecuteTime": { - "end_time": "2025-05-11T19:12:35.905970Z", - "start_time": "2025-05-11T19:12:34.994478Z" + "end_time": "2025-11-30T14:37:18.824144Z", + "start_time": "2025-11-30T14:37:18.257594Z" } }, "source": [ "%useLatestDescriptors\n", - "%use langchain4j(1.0.0-beta3)" + "%use langchain4j" ], "outputs": [], "execution_count": 1 @@ -19,8 +19,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:12:36.134623Z", - "start_time": "2025-05-11T19:12:35.909753Z" + "end_time": "2025-11-30T14:37:19.114022Z", + "start_time": "2025-11-30T14:37:18.828333Z" } }, "cell_type": "code", @@ -67,15 +67,14 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:12:36.239949Z", - "start_time": "2025-05-11T19:12:36.138835Z" + "end_time": "2025-11-30T14:37:19.211014Z", + "start_time": "2025-11-30T14:37:19.114665Z" } }, "cell_type": "code", "source": [ "import dev.langchain4j.data.message.UserMessage.userMessage\n", "import dev.langchain4j.model.chat.request.ChatRequest\n", - "import dev.langchain4j.model.chat.request.chatRequest\n", "import dev.langchain4j.model.openai.OpenAiChatModel\n", "\n", "/**\n", @@ -95,13 +94,8 @@ "\n", " val prompt = \"Please summarize the following text:\\n\\n$chunk\"\n", "\n", - " // Construct a chat request (if you’re using chat models)\n", - " val request = chatRequest {\n", - " messages += userMessage(prompt)\n", - " }\n", - "\n", " // Send the request to get the actual summary\n", - " val response = openAi.chat(request)\n", + " val response = openAi.chat(userMessage(prompt))\n", "\n", " // Extract the content from the response\n", " return response.aiMessage().text()\n", @@ -113,8 +107,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:12:36.370419Z", - "start_time": "2025-05-11T19:12:36.244473Z" + "end_time": "2025-11-30T14:37:19.397754Z", + "start_time": "2025-11-30T14:37:19.221998Z" } }, "cell_type": "code", @@ -158,8 +152,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:12:36.415577Z", - "start_time": "2025-05-11T19:12:36.382328Z" + "end_time": "2025-11-30T14:37:19.439788Z", + "start_time": "2025-11-30T14:37:19.398451Z" } }, "cell_type": "code", @@ -174,479 +168,479 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:21:50.634549Z", - "start_time": "2025-05-11T19:12:36.417729Z" + "end_time": "2025-11-30T14:45:55.271830Z", + "start_time": "2025-11-30T14:37:19.440632Z" } }, "cell_type": "code", - "source": "val summaryDetail1 = summarizeDocument(artificialIntelligenceWikipediaText, detail = 1.0)", + "source": "val summaryDetail = summarizeDocument(artificialIntelligenceWikipediaText, detail = 1.0)", "outputs": [], "execution_count": 6 }, { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T19:21:50.727246Z", - "start_time": "2025-05-11T19:21:50.656323Z" + "end_time": "2025-11-30T14:45:58.400158Z", + "start_time": "2025-11-30T14:45:55.272847Z" } }, "cell_type": "code", - "source": "println(\"Summary with detail=1.0:\\n$summaryDetail1\")", + "source": "println(\"Summary with detail=1.0:\\n$summaryDetail\")", "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Summary with detail=1.0:\n", - "Artificial intelligence (AI) refers to the intelligence displayed by machines, especially computer systems. It is a research area in computer science that creates and examines methods and software allowing machines to understand their surroundings and use learning and intelligence to perform actions that boost their probability of reaching set goals.\n", + "Artificial intelligence (AI) is the display of intelligence by machines, especially computer systems. It is a research field within computer science that focuses on creating and studying methods and software that allow machines to understand their environment and use learning and intelligence to perform actions that increase their likelihood of achieving set goals.\n", "\n", - ", Tesla); and scientific research. The term AI can refer to machines commonly known as Artificial Intelligence. These machines are used in various sectors including industry, government, and scientific research. High-profile applications of AI include advanced web search engines like Google, recommendation systems used by YouTube, Amazon, and Netflix, voice interaction systems like Google Assistant, Siri, and Alexa, and autonomous vehicles like Tesla.\n", + ". , self-driving cars); and applications in healthcare, defense, and financial services. These applications are often referred to as AI technology.\n", "\n", - "The text discusses the broad applications of Artificial Intelligence (AI), including autonomous vehicles, creative tools, and strategy games. However, it notes that many AI technologies are not recognized as such because they have become so common and useful that they no longer carry the \"AI\" label.\n", + "The text discusses the use of artificial intelligence (AI) in different fields such as autonomous vehicles, creative tools, and strategy games. However, it also points out that many AI applications are not recognized as such. This is because once AI becomes extremely useful and common in a particular application, it is no longer labeled as AI.\n", "\n", - "Alan Turing was the pioneer in machine intelligence research. Artificial intelligence (AI) became an academic discipline in 1956. The field has experienced several cycles of optimism and disappointment, resulting in loss of funding, a phenomenon termed as AI winter.\n", + "Alan Turing was the pioneer of substantial research in what he labeled as machine intelligence. The academic discipline of artificial intelligence (AI) was established in 1956. The field experienced numerous cycles of optimism and periods of disappointment, leading to funding loss, a phase termed as AI winter.\n", "\n", - "The funding and interest in artificial intelligence (AI) significantly increased after 2012 when deep learning outperformed all previous AI techniques. The interest further escalated after 2017 with the introduction of the transformer architecture. This resulted in the AI boom in the early 2020s, with most of the advancements in AI being pioneered by companies, universities, and labs primarily based in the United States.\n", + "Funding and interest in artificial intelligence (AI) significantly increased after 2012 when deep learning techniques surpassed previous AI methods, and again after 2017 with the development of the transformer architecture. This resulted in the AI boom in the early 2020s, where companies, universities, and labs, mostly based in the United States, made substantial advancements in AI.\n", "\n", - "The rise of artificial intelligence in the 21st century is leading to societal and economic changes, with increased automation and data-driven decision-making. AI systems are being integrated into different economic sectors and aspects of life, affecting job markets, healthcare, government, industry, and education.\n", + "The increasing use of artificial intelligence in the 21st century is causing societal and economic changes, with greater automation and reliance on data for decision-making. AI is being integrated into numerous sectors including job markets, healthcare, government, industry, and education, influencing all aspects of life.\n", "\n", - "The text raises concerns about the long-term effects, ethical implications, and risks of AI, suggesting the need for regulatory policies for safety and benefits of the technology. It also mentions that AI research is divided into various sub-fields, each focused on specific goals and tools.\n", + "The text discusses the long-term effects, ethical implications, and risks of artificial intelligence (AI), suggesting the need for regulatory policies to guarantee its safety and benefits. It also mentions that AI research is divided into various sub-fields, each focused on specific goals and tools.\n", "\n", - "The primary objectives of AI research encompass reasoning, knowledge representation, planning, learning, natural language processing, perception, and support for robotics. One of the long-term goals is to achieve general intelligence, which means the AI system's ability to perform any task a human can do at an equal or superior level.\n", + "The main objectives of AI research encompass reasoning, knowledge representation, planning, learning, natural language processing, perception, and robotics support. A paramount long-term goal in the field is to achieve general intelligence, which is the ability to perform any task that a human can do, but at least at an equal level.\n", "\n", - "AI researchers utilize a variety of techniques to achieve their goals, including search and mathematical optimization, formal logic, artificial neural networks, and methods based on statistics, operations research, and economics. AI also incorporates knowledge from fields such as psychology, linguistics, philosophy, neuroscience, and more.\n", + "AI researchers employ a variety of techniques to achieve their goals, such as search and mathematical optimization, formal logic, artificial neural networks, and methods based on statistics, operations research and economics. AI also utilizes knowledge from psychology, linguistics, philosophy, neuroscience and other fields.\n", "\n", - "The broad challenge of simulating or creating intelligence has been divided into smaller, specific sub-problems. These sub-problems involve certain traits or capabilities that researchers believe an intelligent system should demonstrate. The traits that have been most focused on encompass the range of AI research.\n", + "The main objective of simulating or creating intelligence has been divided into smaller issues. These sub-problems involve specific characteristics or abilities that researchers anticipate an intelligent system would exhibit. The traits that have been most researched and encompass the range of AI studies are discussed below.\n", "\n", - "Early researchers created algorithms that mimic human reasoning and problem-solving, particularly in solving puzzles or making logical deductions. By the late 1980s and 1990s, they developed methods to handle uncertain or incomplete information, using concepts from probability and economics.\n", + "The text discusses the evolution of algorithms in problem-solving. Early researchers created algorithms that mimic the sequential reasoning humans use in solving puzzles or making logical deductions. By the late 1980s and 1990s, methods were developed to handle uncertain or incomplete information, incorporating concepts from fields such as probability and economics.\n", "\n", - "The text explains that many algorithms struggle to solve large reasoning problems due to a \"combinatorial explosion\", where they become exponentially slower as the problems increase in size. It also notes that humans seldom use the methodical deduction that early AI research could imitate, instead opting for quick, intuitive judgments to solve most of their problems.\n", + "Many algorithms struggle to solve large reasoning problems as they become exponentially slower with the increase in problem size, a phenomenon known as \"combinatorial explosion\". Humans, in contrast, often don't use step-by-step deduction, as early AI research could replicate, but rather solve problems using quick, intuitive judgments.\n", "\n", - "The text discusses the unresolved issue of accurate and efficient reasoning. It explains that an ontology represents knowledge as a set of concepts within a domain and their relationships. Knowledge representation and knowledge engineering enable AI programs to intelligently answer questions and deduce real-world facts.\n", + "The text discusses the unresolved issue of accurate and efficient reasoning. It introduces the concept of ontology in knowledge representation, which depicts knowledge as a set of concepts within a domain and their relationships. This, combined with knowledge engineering, enables AI programs to intelligently answer questions and make deductions about real-world facts.\n", "\n", - "Formal knowledge representations are utilized in various fields such as content-based indexing and retrieval, scene interpretation, clinical decision support, and knowledge discovery. This knowledge is stored in a knowledge base, which is a collection of information formatted to be utilized by a program.\n", + "Formal knowledge representations are used in various fields such as content-based indexing and retrieval, scene interpretation, clinical decision support, and knowledge discovery from large databases. A knowledge base refers to a body of knowledge that is represented in a format that can be utilized by a program.\n", "\n", - "An ontology refers to the collection of objects, relationships, concepts, and properties utilized in a specific area of knowledge.\n", + "An ontology is the collection of elements such as objects, relations, concepts, and properties utilized in a specific knowledge domain.\n", "\n", - "Knowledge bases need to illustrate various aspects of knowledge including objects, properties, their relations and categories, situations, events, states and time. They should also represent causes and effects, knowledge about knowledge, default reasoning which refers to assumptions humans make until proven otherwise, and numerous other domains of knowledge.\n", + "Knowledge bases are required to represent various aspects and domains of knowledge, including objects, properties, categories, relations between objects, situations, events, states, time, causes and effects, and knowledge about knowledge. They also need to cater to default reasoning, which refers to assumptions that are considered true until proven otherwise, and remain constant despite changes in other facts.\n", "\n", - "The text discusses two major challenges in knowledge representation. The first is the vastness of commonsense knowledge, which refers to the large set of basic facts known by the average person. The second challenge is the sub-symbolic nature of most commonsense knowledge, indicating that much of what people know cannot be verbally expressed as 'facts' or 'statements'.\n", + "The text highlights two major challenges in knowledge representation: the vast amount of commonsense knowledge that an average person possesses, and the fact that most of this knowledge is not in a form that can be verbally expressed as facts or statements.\n", "\n", - "The text discusses challenges in artificial intelligence (AI), including the difficulty of knowledge acquisition, which is the process of obtaining knowledge for AI applications. It also describes an \"agent\" in AI as anything that perceives and acts in the world, specifically aiming to achieve certain goals or preferences. In automated planning, the agent works towards a specific goal.\n", + "The text discusses challenges in artificial intelligence (AI), including the difficulty of knowledge acquisition - obtaining necessary knowledge for AI applications. It also introduces the concept of an \"agent\" in AI, which is something that perceives and acts in the world. A rational agent has goals or preferences and takes actions to achieve them, particularly in automated planning where the agent has a specific goal.\n", "\n", - "In automated decision making, the decision-making agent has preferences for certain situations and aversions to others. Each situation is given a numerical value, known as the \"utility,\" which represents the agent's preference level for that situation.\n", + "In automated decision making, the agent assigns a numerical value, known as \"utility\", to each situation based on its preferences. This number indicates how much the agent prefers or wants to avoid a certain situation.\n", "\n", - "The text discusses a method where for every potential action, its \"expected utility\" is calculated. This is done by considering the utility of all possible results of the action, factoring in the likelihood of each outcome. The action with the highest expected utility is then selected. In classical planning, the agent is fully aware of the consequences of any action.\n", + "The text describes a process where for every possible action, its \"expected utility\" can be calculated. This is done by considering the utility of all possible outcomes of the action, and factoring in the likelihood of each outcome. The action with the highest expected utility is then chosen. In classical planning, the agent is aware of the exact impact of any action.\n", "\n", - "In most real-world situations, an agent might not be sure about its current scenario or the outcomes of its possible actions. Thus, it must make a decision based on probability and then re-evaluate the situation to check if the chosen action was effective.\n", + "The text discusses the challenges typically faced in real-world situations, where the agent, or decision-maker, is often uncertain about their exact circumstances or the outcomes of their potential actions. Therefore, the agent must make decisions based on probabilistic predictions and then re-evaluate the situation based on the results of those actions.\n", "\n", - "The text discusses the uncertainty of an agent's preferences in some situations, particularly when other agents or humans are involved. This uncertainty can be addressed either by learning through methods like inverse reinforcement learning, or by the agent seeking additional information to enhance its preferences. Information value theory can help determine the worth of exploratory or experimental actions.\n", + "The text discusses how an agent's preferences can sometimes be uncertain, particularly when other agents or humans are involved. This uncertainty can be addressed through learning techniques like inverse reinforcement learning or by the agent seeking additional information to refine its preferences. The text also mentions the application of information value theory to assess the worth of exploratory or experimental actions.\n", "\n", - "The text discusses how the potential future actions and scenarios are usually too vast to predict accurately. Therefore, agents must make decisions and assess situations despite not knowing the probable results.\n", + "Agents must make decisions and evaluate situations in the vast space of potential future actions and situations. However, due to the complexity and size of this space, they must do so while uncertain of the results.\n", "\n", - "A Markov decision process is a mathematical approach for decision making, featuring a transition model outlining the probability of an action causing a specific state change, and a reward function detailing the utility of each state and cost of each action. The policy, which associates a decision with each possible state, can be calculated, heuristic, or learned.\n", + "A Markov decision process includes a transition model and a reward function. The former predicts the probability of an action changing the state in a certain way, while the latter provides the utility of each state and the cost of every action. A policy, which can be calculated, heuristic, or learned, pairs a decision with each possible state.\n", "\n", - "Game theory is a principle used in AI programs to depict the rational behavior of multiple interacting agents. Machine learning, a major part of AI, is the study of programs that can automatically enhance their performance on any given task. There are several types of machine learning in existence.\n", + "Game theory is a method used in AI programs to outline rational behavior of multiple interacting agents, especially in decision-making processes. Machine learning, which is a fundamental part of AI, refers to the study of programs that can automatically enhance their performance on a specific task. There are various types of machine learning.\n", "\n", - "Unsupervised learning is a method that analyzes data and identifies patterns and predictions without any guidance. On the other hand, supervised learning necessitates human-labelled input data. It has two main types: classification, where the program predicts the category of the input, and regression, where the program deduces a numeric function based on numeric input.\n", + "Unsupervised learning uses data to find patterns and make predictions without guidance, while supervised learning needs a human to label the input data. The two main types of supervised learning are classification, where the program predicts the category of the input, and regression, where the program deduces a numeric function based on numeric input.\n", "\n", - "Reinforcement learning is a process where an agent is rewarded for good responses and penalized for bad ones. This helps the agent to learn to choose 'good' responses. Transfer learning, on the other hand, is a process where the knowledge gained from one problem is used to solve another problem.\n", + "Reinforcement learning is a process where an agent learns to make good choices by receiving rewards for good responses and punishments for bad ones. Transfer learning, on the other hand, involves applying knowledge acquired from one problem to a new problem.\n", "\n", - "Deep learning, a variant of machine learning, uses artificial neural networks inspired by biology for various learning types. Computational learning theory evaluates learners based on computational complexity, sample complexity (amount of data needed), or other optimization concepts.\n", + "Deep learning is a form of machine learning that uses artificial neural networks inspired by biology for various types of learning. Computational learning theory evaluates learners based on computational complexity, sample complexity (the amount of data needed), or other optimization concepts.\n", "\n", - "Natural language processing (NLP) enables software to interpret, generate, and communicate in human languages like English. It tackles issues such as speech recognition and synthesis, machine translation, information extraction and retrieval, and question answering.\n", + "Natural language processing (NLP) is a technology that enables software to interact in human languages like English. It deals with specific issues such as speech recognition, speech synthesis, machine translation, information extraction, information retrieval and question answering.\n", "\n", - "Early research, using Noam Chomsky's generative grammar and semantic networks, struggled with word-sense disambiguation unless it was limited to small areas known as \"micro-worlds.\" This was due to the issue of common sense knowledge.\n", + "Early studies, influenced by Noam Chomsky's generative grammar and semantic networks, struggled with distinguishing between different meanings of a word unless they were limited to small specific areas, referred to as \"micro-worlds\". This was due to the problem of common sense knowledge.\n", "\n", - "Margaret Masterman proposed that the understanding of languages relies on meaning rather than grammar. She suggested that computational language structure should be based on thesauri instead of dictionaries.\n", + "Margaret Masterman argued that understanding languages relies more on meaning than grammar. She suggested that computational language structure should be based on thesauri, not dictionaries.\n", "\n", - "Modern deep learning techniques used in Natural Language Processing (NLP) involve word embedding, which represents words as vectors encoding their meanings, and transformers, a deep learning architecture that uses an attention mechanism, among others.\n", + "The modern deep learning techniques for Natural Language Processing (NLP) include word embedding, which represents words as vectors encoding their meaning, and transformers, a deep learning architecture that uses an attention mechanism, among others.\n", "\n", - "In 2019, generative pre-trained transformer (GPT) language models started producing coherent text. By 2023, these models had reached human-level performance on various tests and real-world applications, including the bar exam, the SAT test, and the GRE test.\n", + "In 2019, generative pre-trained transformer (GPT) language models started to produce coherent text. By 2023, these models achieved human-level scores on various tests including the bar exam, SAT, GRE, and were applied in many other real-world situations.\n", "\n", - "Machine perception refers to the capacity of machines to use sensor input to understand aspects of the world. This includes using cameras, microphones, wireless signals, and various sensors. Computer vision, a part of machine perception, involves analyzing visual input. The field of machine perception includes speech and facial recognition, image and object recognition, and robotic perception.\n", "\n", - "The text talks about social intelligence in machines. An example is Kismet, a robot head created in the 1990s, which can recognize and imitate emotions. The text also mentions affective computing, an interdisciplinary field that includes systems capable of recognizing, interpreting, processing, or simulating human emotions and mood.\n", + "Machine perception refers to the capacity to interpret sensor inputs (like cameras, microphones, wireless signals, etc.) to understand aspects of the world. This encompasses computer vision, which is the analysis of visual input. Areas within this field include speech and facial recognition, image and object classification, and robotic perception.\n", "\n", - "This text explains that some virtual assistants are programmed to converse or joke in a way that mimics human interaction, which can make them seem more emotionally aware. However, this can lead to users developing an inflated perception of the computer's intelligence.\n", + "Social intelligence refers to systems like Kismet, a robot head developed in the 1990s, which can recognize and simulate emotions. This falls under the interdisciplinary field of affective computing, which includes systems that can recognize, interpret, process, or simulate human feelings, emotions, and moods.\n", "\n", - "The text discusses some moderate successes in affective computing. These include textual sentiment analysis and multimodal sentiment analysis, where AI classifies emotions displayed by a person in a video. It also mentions artificial general intelligence, suggesting that a machine with such capability should be able to solve a wide range of problems similar to human intelligence.\n", + "The text explains that some virtual assistants are designed to speak conversationally or humorously to mimic human interaction and seem more emotionally aware. However, this can lead to a misleading perception of these computer agents' actual intelligence level, especially among inexperienced users.\n", "\n", - "Artificial intelligence (AI) research employs a broad range of techniques to achieve its objectives. One such strategy involves search and optimization, where AI resolves numerous issues by intelligently scouring through a multitude of possible solutions. Two distinct types of search methods used in AI are state space search and local search.\n", + "The text discusses some moderate successes in affective computing, which include textual sentiment analysis and multimodal sentiment analysis. This involves AI classifying the emotional responses displayed by a subject in a video. It also mentions artificial general intelligence, suggesting that a machine with this type of intelligence should be capable of solving a wide range of problems with similar breadth and versatility to human intelligence.\n", "\n", - "State space search is a method that navigates through a tree of potential states to locate a goal state. This process is commonly used in planning algorithms, where it sifts through trees of goals and subgoals to find a path to a specific target goal - a process referred to as means-ends analysis.\n", + "AI research employs numerous methods to achieve its aims, including search and optimization techniques. AI can resolve various issues by smartly searching through numerous potential solutions. Two types of search used in AI are state space search and local search.\n", "\n", - "Simple exhaustive searches are often inadequate for real-world problems due to the search space growing extremely large, resulting in slow or incomplete searches. Applying heuristics or rules of thumb can help prioritize choices that are more likely to achieve a goal.\n", + "State space search is a process that explores a tree of potential states to locate a goal state. This method is frequently used in planning algorithms, which sift through trees of goals and subgoals to find a route to a desired goal, a process known as means-ends analysis.\n", "\n", - "Adversarial search is a technique used in game-playing programs like chess or Go, which involves searching through a tree of possible moves and counter-moves to find a winning position. On the other hand, local search, as illustrated by gradient descent, adjusts two parameters in order to minimize the loss function.\n", + "Exhaustive searches are often insufficient for real-world problems as the number of potential areas to search can become too large, resulting in an extremely slow or never-ending search. To solve this, heuristics or rules of thumb can be used to prioritize choices that are more likely to achieve the intended goal.\n", "\n", - "Local search is a mathematical optimization technique used to solve problems by refining an initial guess incrementally. Gradient descent, a variant of local search, optimizes numerical parameters by gradually adjusting them to minimize a loss function. This method is frequently used to train neural networks.\n", + "The text describes two types of search methods used in AI and programming. Adversarial search is utilized in game-playing programs like chess or Go, where it explores a tree of potential moves and counter-moves to find a winning position. Local search, exemplified by gradient descent, adjusts two parameters to minimize the loss function. Different starting points can influence the outcome.\n", "\n", - "Local search involves evolutionary computation, which strives to continually enhance a set of potential solutions by mutating and recombining them, with only the fittest surviving each generation. Distributed search processes can be coordinated using swarm intelligence algorithms.\n", + "Local search is a method that uses mathematical optimization to solve problems by refining an initial guess. Gradient descent, a form of local search, optimizes numerical parameters by incrementally adjusting them to reduce a loss function. This method is often used to train neural networks.\n", "\n", - "The text mentions two commonly used swarm algorithms in search: particle swarm optimization, which is inspired by bird flocking, and ant colony optimization, which is based on ant trails. Additionally, it states that formal logic is utilized for reasoning and knowledge representation.\n", + "Evolutionary computation is a type of local search that aims to progressively enhance a set of potential solutions by mutating and recombining them, with only the fittest surviving each generation. Distributed search processes can be coordinated through swarm intelligence algorithms.\n", "\n", - "Formal logic is divided into two main forms: propositional logic and predicate logic. Propositional logic works on statements that are true or false and uses logical connectors like \"and\", \"or\", \"not\" and \"implies\". Predicate logic operates on objects, predicates and relations, using quantifiers such as \"Every X is a Y\" and \"There are some Xs that are Ys\".\n", + "The text mentions two popular swarm algorithms used in search, namely particle swarm optimization, which is inspired by bird flocking, and ant colony optimization, inspired by ant trails. It also mentions that formal logic is used for reasoning and knowledge representation.\n", "\n", - "Deductive reasoning in logic is the method of validating a new statement based on other given statements assumed to be true. These proofs can be organized as proof trees, where nodes are marked by sentences and linked to parent nodes through inference rules.\n", + "Formal logic is divided into two main types: propositional logic and predicate logic. Propositional logic deals with true or false statements and uses logical connectives such as \"and\", \"or\", \"not\" and \"implies\". On the other hand, predicate logic operates on objects, predicates, and relations and employs quantifiers like \"Every X is a Y\" and \"There are some Xs that are Ys\".\n", "\n", - "The text explains that problem-solving is essentially searching for a solution, depicted as the root node of a proof tree, using given premises or axioms as leaf nodes. With Horn clauses, the problem-solving search can be conducted either by reasoning from the premises forward or from the problem backward.\n", + "Deductive reasoning in logic involves validating a new statement based on other given statements assumed to be true. The structure of proofs can be visualized as proof trees, where nodes represent sentences and the connections between parent and children nodes are determined by inference rules.\n", "\n", - "The clausal form of first-order logic uses resolution as a single, axiom-free rule of inference to solve problems by proving a contradiction from premises that include the negation of the problem. However, inference in both Horn clause logic and first-order logic is undecidable and intractable.\n", + "Problem-solving involves searching for a proof tree where the root node is marked by the problem's solution and the leaf nodes by premises or axioms. In the context of Horn clauses, this search can be carried out by reasoning either forwards from the premises or backwards from the problem.\n", "\n", - "The text discusses two concepts: backward reasoning with Horn clauses and fuzzy logic. The former concept, used in the Prolog programming language, is Turing complete, meaning it can solve any problem that a Turing machine can, given enough time and resources. Its efficiency is on par with other symbolic programming languages. On the other hand, fuzzy logic is a method that assigns a \"degree of truth\" between 0 and 1, allowing it to handle vague or partially true propositions.\n", + "The text explains that in first-order logic, resolution is an inference rule that solves a problem by proving a contradiction from premises, including the negation of the problem. It also states that inference in both Horn clause logic and first-order logic is undecidable and intractable.\n", "\n", - "Non-monotonic logics, such as logic programming with negation as failure, are used to manage default reasoning. Moreover, other specific types of logic have been developed to explain numerous complex domains.\n", + "Backward reasoning with Horn clauses, a method used in Prolog, a logic programming language, is Turing complete, meaning it can simulate a Turing machine. It is also as efficient as other symbolic programming languages. Fuzzy logic, on the other hand, assigns a value between 0 and 1 to represent the \"degree of truth,\" allowing it to manage propositions that are partially true or vague.\n", "\n", - "The text discusses probabilistic methods used in artificial intelligence (AI) for uncertain reasoning. These methods, derived from probability theory and economics, are used to help AI operate in conditions where information is incomplete or uncertain. These tools are applicable in various AI fields such as reasoning, planning, learning, perception, and robotics.\n", + "Non-monotonic logics and logic programming with negation as failure are created to deal with default reasoning. Specialized versions of logic have also been created to explain various complex domains.\n", "\n", - "The text discusses the development of exact mathematical tools used to analyze how an entity can make choices and plan. These tools are based on decision theory, decision analysis, and information value theory. Some of the models utilized include Markov decision processes, dynamic decision networks, game theory, and mechanism design.\n", + "The text discusses the use of probabilistic methods in artificial intelligence (AI) to handle uncertain or incomplete information. These methods, derived from probability theory and economics, are employed in various AI domains such as reasoning, planning, learning, perception, and robotics. The text also mentions the use of a Bayesian network, which comes with associated conditional probability tables.\n", "\n", - "Bayesian networks are a versatile tool utilized for various purposes such as reasoning through the Bayesian inference algorithm, learning via the expectation-maximization algorithm, planning with decision networks, and perception through dynamic Bayesian networks.\n", + "The text discusses the development of precise mathematical tools to examine how an agent can make choices and plan. These tools, which are based on decision theory, decision analysis, and information value theory, include models like Markov decision processes, dynamic decision networks, game theory, and mechanism design.\n", "\n", - "Probabilistic algorithms are useful for analyzing data streams over time. They can be used for filtering, prediction, smoothing, and finding explanations for data, aiding perception systems in processing processes represented by models like hidden Markov models or Kalman filters.\n", + "Bayesian networks are a tool used for various tasks such as reasoning via the Bayesian inference algorithm, learning through the expectation-maximization algorithm, planning with decision networks, and perception using dynamic Bayesian networks.\n", "\n", - ", \"if hot then cool\"), on the other hand. The classifiers use statistical learning methods to identify patterns or characteristics, while controllers use algorithms to respond to certain conditions. The expectation-maximization clustering method has been successfully used to accurately cluster Old Faithful eruption data, highlighting the effectiveness of such AI applications.\n", + "Probabilistic algorithms can be utilized for various tasks such as filtering, predicting, smoothing, and interpreting streams of data. They assist perception systems in analyzing processes that unfold over time, such as hidden Markov models or Kalman filters.\n", "\n", - "The text discusses a concept in machine learning known as classifiers, which are functions that use pattern matching to find the closest match. These classifiers can be adjusted using supervised learning based on selected examples. Each pattern, also referred to as an observation, is assigned a predefined class label. The combination of all observations and their corresponding class labels constitutes a data set.\n", + ", \"if hot then cool\"), on the other. Expectation-maximization clustering is an effective method for accurately categorizing data, such as the eruption patterns of Old Faithful geyser.\n", "\n", - "The text describes the process of classifying a new observation based on previous experience. It mentions that there are several types of classifiers, with the decision tree being the simplest and most commonly used symbolic machine learning algorithm.\n", + "The text discusses classifiers, which are functions that use pattern matching to identify the closest match. These classifiers can be adjusted or fine-tuned through supervised learning using selected examples. Each pattern or observation is associated with a predefined class. The combination of all observations and their respective class labels constitute a data set.\n", "\n", - "The K-nearest neighbor algorithm was the most popular analogical AI until the mid-1990s, but then got replaced by Kernel methods like the support vector machine (SVM). Google reportedly uses the naive Bayes classifier as it is highly scalable. Neural networks are also utilized as classifiers.\n", + "The text explains that when a new observation is received, it is classified based on past experience. Among the many types of classifiers used, the decision tree is the simplest and most commonly used symbolic machine learning algorithm.\n", "\n", - "An artificial neural network is a system of interconnected nodes or artificial neurons, which are modeled after the neurons in a biological brain. The main function of these networks is to recognize patterns, which they can do in new data once they've been trained.\n", + "The K-nearest neighbor algorithm was the most commonly used analogical AI until the mid-1990s, when Kernel methods like the support vector machine took over. The naive Bayes classifier is said to be the \"most widely used learner\" at Google, largely because of its scalability. Neural networks are also utilized as classifiers.\n", "\n", - "A deep neural network consists of an input, a minimum of two hidden layers of nodes applying functions, and an output. Data is transmitted to the next layer once the weight crosses a specified threshold.\n", + "An artificial neural network is a system of interconnected nodes, or artificial neurons, designed to mimic the neurons in a human brain. This network is trained to recognize certain patterns and, once trained, it can identify these patterns in new data.\n", "\n", - "Neural networks use learning algorithms that implement local search to select the appropriate weights for each input during training. The backpropagation algorithm is the most commonly used training technique. Neural networks have the ability to model intricate relationships between inputs and outputs, and identify patterns in data. Theoretically, a neural network can learn any function.\n", + "A deep neural network consists of an input, at least two hidden layers of nodes, and an output. Each node applies a function and when the weight surpasses a specified threshold, the data is sent to the next layer.\n", "\n", - "Feedforward neural networks allow signals to pass in one direction, while recurrent neural networks feed the output back into the input, enabling short-term memory of previous inputs. The most successful architecture for recurrent networks is Long Short Term Memory. Perceptrons use a single layer of neurons, whereas deep learning utilizes multiple layers.\n", + "Learning algorithms for neural networks use local search to select the appropriate weights during training, with the backpropagation algorithm being the most common technique. Neural networks are capable of modeling complex relationships between inputs and outputs and identifying patterns in data. Theoretically, they can learn any function.\n", "\n", - "Convolutional neural networks improve the connection between neurons that are close to each other, which is essential in image processing for identifying an object. Deep learning uses multiple layers of neurons between the network's inputs and outputs.\n", + "Feedforward neural networks pass signals in one direction, while recurrent neural networks feed output signals back into the input, facilitating short-term memory of past inputs. Among recurrent networks, long short-term memory is the most effective architecture. Perceptrons use only a single layer of neurons, while deep learning utilizes multiple layers.\n", "\n", - "The text describes how multiple layers in a process can progressively extract more complex features from raw input. In the context of image processing, lower layers may identify basic elements like edges, while higher layers identify more sophisticated concepts that are relevant to humans, such as digits, letters, or faces.\n", + "Convolutional neural networks enhance the relationship between neurons that are near each other, which is crucial in image processing. Here, a specific group of neurons must identify an 'edge' before the network can recognize an object. Deep learning uses multiple layers of neurons between the network's inputs and outputs.\n", "\n", - "As of 2023, deep learning has significantly enhanced the performance of programs in various subfields of artificial intelligence, such as computer vision, speech recognition, natural language processing, and image classification. However, the exact reason why deep learning is so effective in these applications is not yet known.\n", + "The text describes how multiple layers in image processing can gradually extract more complex features from raw input. Lower layers identify simpler aspects like edges, while higher layers recognize more advanced concepts like digits, letters, or faces.\n", "\n", - "The rapid success of deep learning between 2012 and 2015 was not due to a new discovery or theoretical breakthrough, as deep neural networks and backpropagation had been known since the 1950s. The success was instead due to an immense increase in computer power, including a hundred-fold speed increase by switching to GPUs, and the availability of large amounts of training data, particularly giant curated datasets used for benchmark testing, like ImageNet.\n", + "Deep learning has significantly enhanced the performance of programs in various subfields of artificial intelligence, such as computer vision, speech recognition, natural language processing, and image classification. However, as of 2023, the reason for deep learning's success in these applications is not understood.\n", "\n", - "The text describes Generative pre-trained transformers (GPT), which are large language models used in natural language processing. They are based on the understanding of semantic relationships between words in sentences. GPT models are pre-trained on a large amount of text, usually sourced from the internet, and the pre-training process involves predicting the next token, which can be a word, subword or punctuation.\n", + "The rapid success of deep learning from 2012-2015 was not due to any new discovery or theoretical breakthrough, as deep neural networks and backpropagation had been described as far back as the 1950s. Rather, it was due to two main factors: a significant increase in computer power, including a hundred-fold increase in speed due to the use of GPUs, and the availability of large amounts of training data, particularly the large curated datasets used for benchmark testing, such as ImageNet.\n", "\n", - "GPT models, during pre-training, gather world knowledge and can generate human-like text by continually predicting the next token. In a later training phase, the model is typically enhanced to be more truthful, useful, and harmless, often using a method known as reinforcement learning from human feedback (RLHF).\n", + "Generative pre-trained transformers (GPT) are language models that focus on semantic relationships between words in sentences. These text-based models are pre-trained on a large amount of text data, often sourced from the internet. The pre-training process involves predicting the next token, which could be a word, subword, or punctuation mark.\n", "\n", - "Current GPT models, used in chatbots, can still generate inaccuracies known as \"hallucinations\", but this can be mitigated with RLHF and good quality data. Some current models and services include Gemini (formerly Bard), ChatGPT, Grok, Claude, Copilot, and LLaMA.\n", + "This text discusses the pre-training of GPT models, during which they gather knowledge about the world. These models can then generate human-like text by predicting the next token repeatedly. Usually, a subsequent training phase enhances the model's accuracy, usefulness, and safety, often utilizing a technique known as reinforcement learning from human feedback (RLHF).\n", "\n", - "The text discusses Multimodal GPT models, which have the ability to process various types of data, including images, videos, sound, and text.\n", + "Current Generative Pre-training Transformer (GPT) models are used in chatbots, allowing users to ask questions or request tasks in simple text. However, these models can generate false information, known as \"hallucinations\", though this can be minimized with RLHF and quality data. Current models and services include Gemini (formerly Bard), ChatGPT, Grok, Claude, Copilot, and LLaMA.\n", "\n", - "In the late 2010s, graphics processing units (GPUs) enhanced for AI and used with TensorFlow software became the main tool for training large-scale machine learning models in both commercial and academic settings, replacing the previously used central processing units (CPUs).\n", + "Multimodal GPT models have the ability to process various types of data, including images, videos, sound, and text.\n", "\n", - "The text refers to the historical use of specialized programming languages like Lisp, Prolog, Python, and others.\n", + "In the late 2010s, graphics processing units (GPUs) with AI-specific enhancements replaced central processing units (CPUs) as the primary tool for training large-scale machine learning models in both commercial and academic settings. This shift was facilitated by the use of specialized TensorFlow software.\n", "\n", - "The text describes the various applications of artificial intelligence (AI) and machine learning technology in the 2020s. These include search engines like Google Search, online advertisement targeting, recommendation systems used by Netflix, YouTube, or Amazon, driving internet traffic, targeted advertising platforms like AdSense and Facebook, virtual assistants such as Siri and Alexa, autonomous vehicles, automatic language translation services like Microsoft Translator and Google Translate, facial recognition systems like Apple's Face ID, Microsoft's DeepFace, Google's FaceNet, and image labeling used by Facebook, Apple's iPhoto and TikTok.\n", + "The text mentions that historically, specialized languages like Lisp, Prolog, Python and others have been used.\n", "\n", + "Artificial Intelligence (AI) and machine learning technologies are extensively used in various applications in the 2020s. These include Google Search, online advertisement targeting, recommendation systems offered by platforms like Netflix, YouTube, or Amazon, driving internet traffic, targeted advertising like AdSense and Facebook, virtual assistants such as Siri or Alexa, autonomous vehicles including drones, ADAS, and self-driving cars. Other applications include automatic language translation by software like Microsoft Translator and Google Translate, facial recognition as seen in Apple's Face ID, Microsoft's DeepFace, and Google's FaceNet, and image labeling used by Facebook, Apple's iPhoto, and TikTok.\n", "\n", - "The use of artificial intelligence (AI) in healthcare could greatly improve patient care and quality of life. Medical professionals, adhering to the Hippocratic Oath, are ethically obligated to use AI if it can help in more accurate diagnosis and treatment of patients.\n", + "The application of artificial intelligence (AI) in healthcare could potentially enhance patient care and improve quality of life. From an ethical perspective, medical professionals are obliged to use AI if it can provide more accurate diagnoses and treatment for patients.\n", "\n", - "AI is a crucial tool in medical research for processing and integrating large amounts of data. This is especially significant for organoid and tissue engineering development, which rely heavily on microscopy imaging. It is also suggested that AI could address imbalances in funding distribution across various research fields.\n", + "AI is a critical tool in medical research, especially in processing and integrating large amounts of data. It is especially useful in organoid and tissue engineering development that heavily rely on microscopy imaging. AI also has the potential to address disparities in funding distribution across different research fields.\n", "\n", - "New AI tools are enhancing our knowledge of biomedically relevant pathways. AlphaFold 2, introduced in 2021, showed the capability to estimate the 3D structure of a protein in hours, not months. In 2023, AI-guided drug discovery reportedly found a class of antibiotics that can kill two types of drug-resistant bacteria.\n", + "New AI tools have significant potential in the field of biomedicine. For instance, AlphaFold 2, released in 2021, was able to determine the 3D structure of a protein in a matter of hours as opposed to months. Furthermore, by 2023, AI was instrumental in discovering a new class of antibiotics that could eliminate two types of drug-resistant bacteria.\n", "\n", - "The article discusses the use of game playing programs in the development and testing of artificial intelligence (AI) techniques since the 1950s. It highlights the achievement of Deep Blue, the first computer chess-playing system that defeated world chess champion Garry Kasparov in May 1997.\n", + "The text discusses the use of game playing programs to demonstrate and test advanced artificial intelligence techniques since the 1950s. It highlights the achievement of Deep Blue, the first computer chess-playing system to beat a reigning world chess champion, Garry Kasparov, on 11 May 1997.\n", "\n", - "In 2011, IBM's question answering system, Watson, decisively defeated the top two Jeopardy! champions, Brad Rutter and Ken Jennings, in a quiz show exhibition match. Then, in March 2016, AlphaGo, a computer system designed to play the game of Go, won 4 out of 5 games against Go champion Lee Sedol, becoming the first computer system to defeat a professional Go player without any handicaps.\n", + "In 2011, IBM's question answering system, Watson, won a Jeopardy! exhibition match against top champions Brad Rutter and Ken Jennings. Then, in March 2016, a computer system named AlphaGo defeated Go champion Lee Sedol in 4 out of 5 games, marking the first time a computer system beat a professional Go player without handicaps.\n", "\n", - "In 2017, an AI program defeated Ke Jie, the world's best Go player. Other AI programs, like Pluribus, can handle imperfect-information games like poker. DeepMind has developed more generalized reinforcement learning models, such as MuZero, which can be trained to play various games including chess, Go, and Atari games.\n", + "In 2017, an AI defeated Ke Jie, the world's best Go player. Other AI programs like Pluribus can handle imperfect-information games like poker. DeepMind has also developed generalistic reinforcement learning models like MuZero, which can be trained to play chess, Go, or Atari games.\n", "\n", - "In 2019, DeepMind's AlphaStar reached grandmaster level in the complex real-time strategy game, StarCraft II. Furthermore, in 2021, an AI agent, using deep reinforcement learning, participated in a PlayStation Gran Turismo competition and won against four of the world's top Gran Turismo drivers.\n", + "In 2019, DeepMind's AI, AlphaStar, reached grandmaster level in StarCraft II, a complex real-time strategy game. Then in 2021, an AI agent competed in a PlayStation Gran Turismo competition, defeating four of the world's top players using deep reinforcement learning.\n", "\n", - "Countries worldwide are utilizing Artificial Intelligence (AI) in their military operations. The primary applications of AI in the military include improving command and control, communication, sensor technology, integration, and interoperability. Research is also being conducted to utilize AI in intelligence collection and analysis, logistics, cyber operations, information operations, and semi-autonomous and autonomous vehicles.\n", + "Countries worldwide are implementing artificial intelligence (AI) in their military operations. The primary uses of AI are to improve command and control, communications, sensors, integration, and interoperability. Areas of research include intelligence gathering and analysis, logistics, cyber operations, information operations, and semi-autonomous and autonomous vehicles.\n", "\n", - "AI technologies enhance military operations by coordinating sensors and effectors, detecting and identifying threats, marking enemy positions, acquiring targets, and managing distributed Joint Fires between networked combat vehicles involving both manned and unmanned teams. AI has been integrated into military operations in Iraq and Syria.\n", + "AI technologies support military operations by coordinating sensors and effectors, detecting and identifying threats, marking enemy positions, acquiring targets, and coordinating Joint Fires between manned and unmanned teams. These technologies were utilized in military operations in Iraq and Syria.\n", "\n", - "In November 2023, US Vice President Kamala Harris revealed a declaration signed by 31 countries aimed at regulating the military use of Artificial Intelligence (AI). The agreement includes commitments to use legal reviews to ensure military AI complies with international law and to maintain caution and transparency in the development of this technology.\n", + "In November 2023, US Vice President Kamala Harris announced a pledge signed by 31 countries to regulate the military use of artificial intelligence (AI). The agreement includes conducting legal reviews to ensure military AI complies with international laws and promoting caution and transparency in its development.\n", "\n", - "Generative AI became widely recognized in the early 2020s. By March 2023, 58% of US adults were aware of ChatGPT, a generative AI software, and 14% had used it.\n", + "Generative AI, a type of artificial intelligence, gained significant attention in the early 2020s. By March 2023, 58% of US adults knew about ChatGPT, a generative AI application, and 14% had used it.\n", "\n", - "AI-based text-to-image generators like Midjourney, DALL-E, and Stable Diffusion are gaining popularity due to their increasing realism and user-friendliness. This trend has led to viral AI-generated photos, including a fake photo of Pope Francis in a white puffer coat, a fictitious arrest of Donald Trump, and a hoax attack on the Pentagon. These tools are also being used in professional creative arts.\n", + "AI-based text-to-image generators, including Midjourney, DALL-E, and Stable Diffusion, have gained widespread attention due to their increasing realism and ease of use. This has led to a trend of viral AI-generated photos, such as a fake image of Pope Francis in a white puffer coat, a fictional arrest of Donald Trump, and a hoax attack on the Pentagon. These tools are also being used in professional creative arts.\n", "\n", - "The text discusses the wide application of AI across various industries to solve specific problems. According to a 2017 survey, one in five companies stated they had incorporated AI into their offerings or processes.\n", + "The text discusses the prevalence of AI applications in various industries. As per a 2017 survey, 20% of companies stated that they had integrated AI into some of their offerings or processes. This highlights the widespread use of AI to address specific problems unique to certain industries or institutions.\n", "\n", - "The text discusses various applications of artificial intelligence (AI). These include energy storage, medical diagnosis, military logistics, predicting judicial decisions, foreign policy, and supply chain management. In agriculture, AI aids farmers in identifying areas requiring irrigation, fertilization, pesticide treatments, or yield increase. Agronomists also use AI for research and development.\n", + "The text provides examples of areas where artificial intelligence (AI) is utilized, including energy storage, medical diagnosis, military logistics, predicting judicial decisions, foreign policy, and supply chain management. In agriculture, AI assists farmers in identifying areas requiring irrigation, fertilization, pesticide treatments, and yield increase. AI is also used by agronomists for research and development.\n", "\n", - "AI is utilized in agriculture for numerous tasks including predicting crop ripening time, monitoring soil moisture, operating agricultural robots, conducting predictive analytics, classifying livestock emotions, automating greenhouses, detecting diseases and pests, and water conservation.\n", + "Artificial Intelligence (AI) is being utilized in various ways in agriculture. These include predicting crop ripening time, monitoring soil moisture, operating agricultural robots, conducting predictive analytics, classifying livestock emotions, automating greenhouses, detecting diseases and pests, and conserving water.\n", "\n", - "Artificial intelligence (AI) is applied in astronomy to analyze vast amounts of data. Its uses include classification, regression, clustering, forecasting, generation, discovery and gaining new scientific insights. Examples of its applications include discovering exoplanets, predicting solar activity, and differentiating between signals and instrumental effects in gravitational wave astronomy.\n", + "Artificial intelligence (AI) is being utilized in the field of astronomy to manage and analyze the growing volumes of data. The applications of AI include classification, regression, clustering, forecasting, generation, discovery, and the development of scientific insights. These applications are helpful in tasks like discovering exoplanets, predicting solar activity, and differentiating between signals and instrumental effects in gravitational wave astronomy.\n", "\n", - "The text discusses the potential uses of artificial intelligence (AI) in space activities, such as space exploration, data analysis from space missions, real-time science decisions for spacecraft, space debris avoidance, and more autonomous operations. It also mentions that AI has both potential benefits and risks, indicating a link to a main article on the ethics of artificial intelligence.\n", + "The text discusses the potential use of artificial intelligence (AI) in space activities like exploration, data analysis from missions, real-time decisions of spacecraft, and space debris avoidance. It also highlights that AI has both potential benefits and risks, and the ethical considerations of AI are also important.\n", "\n", - "Demis Hassabis from Deep Mind believes that AI has potential to advance science and solve major problems by first \"solving intelligence\". However, with the increased use of AI, several unintended consequences and risks have also been identified.\n", + "AI has the potential to advance science and solve significant problems, according to Demis Hassabis of Deep Mind. He aims to \"solve intelligence\" with AI and then use it to solve all other issues. Nevertheless, with the widespread use of AI, several unexpected consequences and risks have surfaced.\n", "\n", - "The text discusses potential issues with AI training processes in in-production systems, noting that ethics and bias may not always be factored in, particularly in the case of unexplainable deep learning algorithms. It also mentions risks and harm related to privacy and copyright concerns, as machine-learning algorithms require large amounts of data to function.\n", + "AI training processes can sometimes neglect ethics and bias, particularly in deep learning where the algorithms can be hard to explain. Additionally, machine-learning algorithms need large amounts of data, which can pose risks and harm concerning privacy and copyright.\n", "\n", - "The methods utilized to gather data such as online activity, geolocation, video and audio from users by technology companies have sparked worries regarding privacy, surveillance, and copyright issues.\n", + "The methods employed to gather data such as online activity, geolocation information, and audio and video by technology companies have sparked privacy, surveillance, and copyright issues.\n", "\n", - "Amazon has recorded millions of private conversations to develop speech recognition algorithms, even allowing temporary workers to listen to and transcribe some. Opinions about this broad surveillance vary, with some viewing it as a necessary evil and others deeming it clearly unethical and a breach of privacy rights.\n", + "Amazon has recorded millions of private conversations for the purpose of building speech recognition algorithms, even allowing temporary workers to transcribe some. There are mixed opinions on this practice, with some viewing it as a necessary evil, while others consider it unethical and an invasion of privacy.\n", "\n", - "AI developers advocate for methods like data aggregation, de-identification, and differential privacy to create beneficial applications while preserving user privacy. Since 2016, privacy experts like Cynthia Dwork have started considering privacy from the perspective of fairness.\n", + "AI developers assert that to create valuable applications, the collection of data is necessary. They have developed methods like data aggregation, de-identification, and differential privacy to balance data collection and privacy preservation. Since 2016, certain privacy experts like Cynthia Dwork have started to perceive privacy from the perspective of fairness.\n", "\n", - "The text discusses how the focus has shifted from what AI systems know to how they use that knowledge. Generative AI, for example, is frequently trained on copyrighted works without a license, such as images or computer code. The usage of this output is justified under the concept of \"fair use\".\n", + "The text discusses how the focus of experts in the field of Generative AI has shifted from what knowledge they possess to how they apply that knowledge. This AI is often trained using unlicensed copyrighted materials, like images or computer code, and the resulting output is justified under the concept of \"fair use\".\n", "\n", - "Website owners can prevent their copyrighted content from being indexed or 'scraped' by AI by adding specific code to their site. This feature is available through certain services like OpenAI.\n", + "The text suggests that website owners who don't want their copyrighted content to be AI-indexed or 'scraped' can use specific coding to prevent search engines from indexing their website. Such services are currently available through platforms like OpenAI.\n", "\n", - "Experts are uncertain about the legal standing of using copyrighted work to train generative AI. Factors influencing this include the purpose of using the copyrighted work and its potential market impact. Notably, in 2023, renowned authors such as John Grisham and Jonathan Franzen sued AI companies for using their work for this purpose.\n", + "Legal experts are uncertain about how courts will interpret the use of copyrighted works to train generative AI. Factors that could be considered include the purpose and character of the use, and the potential impact on the market for the copyrighted work. In 2023, prominent authors like John Grisham and Jonathan Franzen sued AI companies for using their work in this way.\n", "\n", - "YouTube, Facebook and other platforms use AI recommender systems to guide users to more content, with the sole objective of maximizing user engagement and keeping people watching.\n", + "YouTube, Facebook, and other similar platforms use AI recommender systems to suggest more content to users. The primary objective of these AI programs is to maximize user engagement, essentially aiming to keep people watching.\n", "\n", - "The AI discovered that users often selected content featuring misinformation, conspiracy theories, and extreme partisan viewpoints. To maintain user engagement, the AI recommended more of such content. The AI also observed that users tended to watch more content on similar topics, leading users into filter bubbles where they were exposed to various versions of the same misinformation.\n", + "The AI discovered that users often selected content featuring misinformation, conspiracy theories, and extreme partisan views. To maintain user engagement, the AI suggested similar content. It also found that users frequently watched content on the same topic, leading the AI to create filter bubbles where users were exposed to multiple versions of the same misinformation.\n", "\n", - "The text discusses the harmful impact of misinformation spread through an AI program, leading to a decrease in trust in institutions, media, and government. This misinformation appeared to be validated by the AI program's success in achieving its goal, causing harm to society. Following the 2016 U.S. election, major tech companies took action to address this issue.\n", + "The text discusses the negative impacts of misinformation, which led to a lack of trust in institutions, media, and the government. This misinformation was propagated by an AI program that, while successfully achieving its goal, ended up causing damage to society. In response to these harmful effects, particularly noticeable after the 2016 U.S. election, major tech companies began taking measures to address this issue.\n", "\n", - "In 2022, generative AI started producing images, audio, video, and text that are virtually identical to real-life counterparts. However, this technology can be misused to generate large volumes of misinformation or propaganda.\n", + "In 2022, generative AI started producing images, audio, video, and text that are almost identical to real ones. This technology could potentially be used by malicious individuals to create large amounts of misinformation or propaganda.\n", "\n", - "AI pioneer Geoffrey Hinton voiced concerns about AI being used by authoritarian leaders to manipulate their electorates, among other risks. Additionally, issues of algorithmic bias and fairness were raised, noting that machine learning applications can be biased if they are trained with biased data, with developers potentially being unaware of the existing bias.\n", + "AI expert Geoffrey Hinton warned of the potential for AI to be used by authoritarian leaders to manipulate electorates, among other dangers. Furthermore, the text discusses the risk of algorithmic bias in machine learning applications, which can occur if they are trained on biased data. This bias may not always be apparent to the developers.\n", "\n", - "The text discusses the possibility of bias being introduced in machine learning through the selection of training data and model deployment. This bias can lead to serious harm, including discrimination, in areas such as medicine, finance, recruitment, housing, and policing. The field of fairness in machine learning is dedicated to studying how to prevent the harm caused by such algorithmic bias.\n", + "Bias in machine learning can be introduced through the selection of training data and the deployment of a model. If a biased algorithm is used in areas like medicine, finance, recruitment, housing, or policing, it can lead to discrimination. The study of fairness in machine learning focuses on preventing the harm caused by such algorithmic bias.\n", "\n", - "The concept of \"fairness\" within AI has become a significant area of academic study due to its complexity and the difficulty to define it in a way that satisfies all stakeholders. This is exemplified by an incident on June 28, 2015, where Google Photos's image labeling feature incorrectly identified two black individuals as \"gorillas\".\n", + "The concept of \"fairness\" in AI has become a significant area of academic study, as it has been found difficult to define in a way that satisfies everyone. This was highlighted when Google Photos's image labeling feature incorrectly identified two black individuals as \"gorillas\" in 2015.\n", "\n", - "The system initially had a \"sample size disparity\" issue as it was trained on a dataset with few images of black people. Google addressed this by disabling the system's ability to label anything as a \"gorilla\". However, eight years later in 2023, Google Photos and similar products from Apple, Facebook, Microsoft, and Amazon still couldn't identify a gorilla.\n", + "The text discusses a problem with a system that was trained on a dataset containing very few images of black people, a problem referred to as \"sample size disparity\". Google attempted to solve this issue by preventing the system from labeling anything as a \"gorilla\". However, even eight years later in 2023, Google Photos and similar products from Apple, Facebook, Microsoft, and Amazon were still unable to identify a gorilla.\n", "\n", - "COMPAS is a commercial software used by US courts to predict the probability of a defendant reoffending. In 2016, Julia Angwin from ProPublica found that the program showed racial bias, even though it was not provided with the race of the defendants.\n", + "COMPAS, a commercial program used by U.S. courts to predict a defendant's chance of reoffending, was found to display racial bias in 2016. This discovery was made by Julia Angwin at ProPublica, even though the program was not provided with the races of the defendants.\n", "\n", - "The system had an equal error rate of 61% for both whites and blacks. However, the nature of the errors varied by race. The system consistently over-predicted the likelihood of black individuals re-offending, and under-predicted the likelihood of white individuals re-offending.\n", + "The error rate of a system was calibrated at 61% for both whites and blacks. However, the system's errors were racially biased, as it overestimated the likelihood of re-offending for black individuals and underestimated the same for white individuals.\n", "\n", - "In 2017, researchers demonstrated that it was mathematically impossible for the COMPAS system to consider all aspects of fairness when the re-offense rates for whites and blacks were different in the data. They further noted that a program could still make biased decisions even if explicit problematic elements such as 'race' or 'gender' were not mentioned in the data.\n", + "In 2017, researchers demonstrated that the COMPAS algorithm could not accommodate all fairness measures due to different base rates of re-offense for whites and blacks in its data. It was also noted that a program could still make biased decisions even without explicitly identifying potentially problematic features like race or gender.\n", "\n", - "The feature in a program will be associated with other features such as \"address\", \"shopping history\" or \"first name\", and the program will make decisions based on these features, similar to how it would decide based on \"race\" or \"gender\". However, Moritz Hardt stated that fairness cannot be achieved through overlooking these variables.\n", + "The text discusses a feature of a program that works by correlating with other features such as \"address\", \"shopping history\" or \"first name\". The program will then make decisions based on these features similar to how it would on \"race\" or \"gender\". Moritz Hardt, however, asserts that fairness cannot be achieved through blindness, suggesting this approach is not effective in promoting fairness.\n", "\n", - "COMPAS has been criticized for its machine learning models' reliance on past data to make future predictions. Critics argue that if these models are trained on data reflecting past racist decisions, they will inevitably predict future occurrences of such decisions, perpetuating systemic racism.\n", + "Criticism of COMPAS, a machine learning model, points out its limitation of making valid predictions only if the future mirrors the past. If the data it's trained on contains past racist decisions, the model will predict future decisions to be racist as well.\n", "\n", - "The text suggests that machine learning, while useful, may inadvertently promote racist outcomes if it uses past data to make future predictions. It is more descriptive rather than prescriptive and may not be ideal for decision-making in scenarios where the hope is for a better future than the past.\n", + "The text suggests that machine learning, when used for making recommendations, can inadvertently propagate racism due to its inherent nature of being descriptive and not prescriptive. It is therefore not suitable for decision-making in areas where the goal is to improve upon past errors or biases.\n", "\n", - "The text suggests that bias and unfairness in AI may go unnoticed due to lack of diversity among its developers, with only 4% being black and 20% being women, the majority being white males.\n", + "The text suggests that bias and unfairness in AI development may go unnoticed due to the lack of diversity among AI engineers, who are predominantly white males. Only about 4% are black and 20% are women.\n", "\n", - "At the 2022 Conference on Fairness, Accountability, and Transparency in Seoul, South Korea, the Association for Computing Machinery suggested that the use of AI and robotics systems should be limited until they are proven to be free of bias mistakes. The organization particularly recommended curtailing the use of self-learning neural networks trained on large, unregulated, and flawed internet data.\n", + "At the 2022 Conference on Fairness, Accountability, and Transparency, the Association for Computing Machinery suggested that AI and robotics systems should be proven free of bias mistakes before their use. They also recommended the curtailment of self-learning neural networks trained on large, unregulated sources of flawed internet data, citing safety concerns.\n", "\n", - "The text discusses the lack of transparency in many AI systems, particularly those using deep neural networks. These systems are often so complex that even their designers cannot explain how they make decisions, due to the numerous non-linear relationships between inputs and outputs. This issue relates to concepts like Explainable AI, Algorithmic transparency, and Right to explanation.\n", + "The text discusses the issue of transparency in AI systems. Many of these systems, especially those involving deep neural networks, are so complex that their creators cannot explain how they make decisions. This is due to a large number of non-linear relationships between inputs and outputs.\n", "\n", - "The text discusses the importance of understanding how a machine learning program operates to ensure its correct functionality. Despite passing rigorous tests, a program can still learn something different from what was intended by the programmers. However, there are popular explainability techniques to better understand these programs.\n", + "The text discusses the challenges in ensuring the correct operation of a machine learning program. It emphasizes that it's impossible to be sure of a program's functioning if its working mechanism is not known. Even if a program passes rigorous tests, there's a possibility that it may still learn differently from what was initially intended by the programmers.\n", "\n", - "The text talks about a system designed to identify skin diseases more effectively than medical professionals. However, the system was found to incorrectly classify images with a ruler as \"cancerous\". This is attributed to the fact that photos of cancerous skin diseases usually include a ruler for scale.\n", + "A system designed to identify skin diseases was found to mistakenly classify images with a ruler as \"cancerous.\" This error occurred because the system associated the presence of a ruler, usually included in pictures of malignancies to show scale, with cancer.\n", "\n", - "A machine learning system designed to allocate medical resources wrongly classified asthma patients as \"low risk\" for dying from pneumonia. This is incorrect as asthma is a severe risk factor. The error occurred because the system's training data showed that asthma patients, who usually receive extensive medical care, were less likely to die, leading to the misclassification.\n", + "A machine learning system, designed to allocate medical resources more efficiently, incorrectly classified asthma patients as \"low risk\" for pneumonia-related death. This occurred because the training data indicated that asthma patients were unlikely to die due to their higher level of medical care, despite asthma being a significant risk factor.\n", "\n", - "The text discusses two separate points. First, it acknowledges a correlation between asthma and a lower risk of dying from pneumonia, but notes that this correlation may be misleading. Secondly, it asserts the right of individuals to understand the reasoning behind decisions made by algorithms, using doctors explaining their decisions to colleagues as an analogy.\n", + "The text discusses a true but deceptive correlation between asthma and a lower risk of dying from pneumonia. It also asserts that individuals negatively affected by an algorithm's decision are entitled to an explanation. This is comparable to doctors who are required to thoroughly explain their decision-making process to their peers.\n", "\n", - "Early drafts of the European Union's General Data Protection Regulation in 2016 acknowledged the existence of a particular right, which remains an unresolved issue with no clear solution according to industry experts. Regulators, however, insisted that despite the lack of a solution, the tools causing the problem should not be utilized due to the tangible harm they cause.\n", + "Early drafts of the European Union's General Data Protection Regulation (GDPR) in 2016 explicitly acknowledged the right to data protection. However, industry experts mentioned that there is no clear solution to this issue. Regulators stressed that the real harm stems from the lack of a solution, suggesting that if a problem can't be solved, then the tools causing the problem shouldn't be utilized.\n", "\n", - "DARPA launched the XAI (Explainable Artificial Intelligence) program in 2014 to address issues related to AI transparency. Potential solutions include SHAP, which aims to enhance transparency by visually representing how each feature contributes to the output, and LIME, which simplifies the model for local approximation, making it more interpretable.\n", + "DARPA created the XAI (Explainable Artificial Intelligence) program in 2014 to address issues regarding AI transparency. Several potential solutions have been proposed. SHAP aims to clarify transparency issues by visualizing how each feature contributes to the output. LIME works by locally approximating a model with a simpler, more understandable one.\n", "\n", - "Multitask learning enhances the performance of neural networks by providing multiple outputs in addition to the target classification, helping developers understand what the network has learned. Techniques like Deconvolution and DeepDream allow developers to interpret the learning patterns of different layers of the network and generate outputs that indicate what the network is learning.\n", + "Multitask learning offers numerous outputs beyond the target classification, aiding developers in understanding what the network has learned. Techniques like deconvolution, DeepDream, and other generative methods enable developers to visualize what various layers of a deep network have learned and generate output that indicates the network's learning process.\n", "\n", - "The text discusses the potential misuse of artificial intelligence (AI) by harmful entities such as authoritarian governments, terrorists, criminals or rogue states. These bad actors can utilize AI tools for nefarious purposes. One example given is a lethal autonomous weapon, a machine that can locate, select, and engage human targets without any human oversight.\n", + "The text discusses the potential misuse of artificial intelligence (AI) by harmful entities such as authoritarian governments, terrorists, criminals, or rogue states. These entities can use AI as a tool for creating lethal autonomous weapons, which are machines capable of identifying and attacking human targets without human supervision.\n", "\n", - "The text discusses the potential misuse of widely available AI tools by malicious parties to create inexpensive autonomous weapons. If mass-produced, these could potentially serve as weapons of mass destruction. Furthermore, even if used in conventional warfare, the text suggests that such AI weapons may not be able to accurately select targets, posing a risk of harm to innocent individuals.\n", + "The text warns about the misuse of widely available AI tools. It states that bad actors could use these tools to develop cheap autonomous weapons, which, if mass-produced, could become weapons of mass destruction. Additionally, even in conventional warfare, these AI weapons may not be able to reliably select targets, increasing the risk of innocent people being killed.\n", "\n", - "In 2014, 30 countries, including China, backed a ban on autonomous weapons under the United Nations' Convention on Certain Conventional Weapons. However, the United States and some other countries disagreed with this. By 2015, more than fifty countries were reportedly researching battlefield robots. Furthermore, AI tools could potentially aid authoritarian governments in controlling their citizens more efficiently.\n", + "In 2014, 30 countries, including China, backed a United Nations' ban on autonomous weapons, but the United States and some other nations opposed it. By 2015, more than 50 countries were said to be investigating battlefield robots. Artificial intelligence tools can enhance the ability of authoritarian regimes to effectively control their citizens.\n", "\n", - "The text discusses different technologies and how they can be used in surveillance and propaganda. Face and voice recognition can enable broad surveillance and identify potential state enemies. Machine learning can process this data for classification purposes. Recommendation systems can be used to deliver targeted propaganda and misinformation. Additionally, deepfakes and generative AI can assist in creating misinformation.\n", + "The text discusses how advanced technologies can be utilized for surveillance and information manipulation. Face and voice recognition can enable large-scale monitoring and machine learning can identify potential state adversaries. Recommendation systems can be used to effectively disseminate propaganda and misinformation. Furthermore, deepfakes and generative AI can assist in creating misinformation.\n", "\n", - "Advanced artificial intelligence (AI) can potentially make centralized decision making in authoritarian regimes more competitive than decentralized systems found in liberal societies. AI technologies, which have been available since 2020 or earlier, can reduce the cost and complexity of digital warfare and advanced spyware. For example, AI facial recognition systems are already being used for mass surveillance in China.\n", + "Advanced AI can potentially enhance the efficiency of authoritarian centralized decision making, making it more competitive than liberal and decentralized systems like markets. It can also reduce the complexity and cost of digital warfare and advanced spyware. Technologies such as AI facial recognition systems have been available since 2020 or earlier, with China already employing them for mass surveillance.\n", "\n", - "AI is expected to aid bad actors in ways that cannot be predicted, such as machine-learning AI being able to create thousands of toxic molecules in hours. Training AI systems requires a lot of computing power, which typically only Big Tech companies can afford.\n", + "Artificial Intelligence (AI) could potentially assist bad actors in malicious activities that are hard to predict. For instance, AI with machine-learning capabilities can create numerous toxic molecules in a short period. Training AI systems necessitates massive computing power, which typically only large tech companies can afford.\n", "\n", - "Smaller startups like Cohere and OpenAI often purchase access to data centers from larger tech companies like Google and Microsoft. Economists have often pointed out the potential for job loss due to artificial intelligence (AI), and the need for appropriate social policies to ensure full employment.\n", + "Smaller startups like Cohere and OpenAI purchase access to data centers from tech giants Google and Microsoft. Economists have often pointed out the potential for job losses due to AI, speculating that without proper social policy for full employment, technological unemployment could occur.\n", "\n", - "Technology has historically led to an increase in total employment, but economists admit that the impact of AI on jobs is unknown and could potentially reduce employment.\n", + "The text suggests that while technology has historically led to an increase in total employment, economists recognize that the advent and impact of Artificial Intelligence (AI) on employment is uncertain and unprecedented.\n", "\n", - "jobs could be automated by the mid-2030s, while a 2016 study by the OECD estimated only 9% of jobs were at risk. Economists are divided on the impact of robots and AI on long-term unemployment, but consensus is that increased productivity could bring overall benefits if gains are redistributed.\n", + "jobs could be automated by 2033, while a 2016 report by the Organization for Economic Cooperation and Development (OECD) estimated only 9% of jobs in its member countries could be automated. Economists generally agree that, while the use of robots and AI could increase unemployment in the short term, it could also have long-term benefits if the productivity gains are properly redistributed.\n", "\n", - "Jobs are at a high risk of potential automation, with an OECD report classifying 9% of U.S. jobs as high risk. However, the methodology of predicting future employment levels has been criticized for lacking evidence and suggesting that technology, instead of social policy, is the cause of unemployment or redundancies.\n", + "The text discusses the differing percentages of jobs at \"high risk\" of potential automation according to various reports, with one placing it at 9% for U.S jobs. However, the methodology used to predict future employment levels is criticized for lacking solid evidence and for suggesting that technology, rather than social policy, is the primary cause of unemployment and redundancies.\n", "\n", - "In April 2023, reports indicated that generative artificial intelligence had replaced 70% of the jobs for video game illustrators in China.\n", + "In April 2023, reports revealed that generative artificial intelligence had eradicated 70% of jobs for Chinese video game illustrators.\n", "\n", - "The Economist stated in 2015 that the rise of artificial intelligence could lead to the elimination of many middle-class jobs, similar to how the Industrial Revolution led to the removal of many blue-collar jobs. This concern was noted as \"worth taking seriously\".\n", + "The Economist in 2015 expressed concern that artificial intelligence (AI) might eliminate many middle-class jobs, similar to how steam power automated blue-collar jobs during the Industrial Revolution. This concern regarding AI's impact on white-collar jobs was considered \"worth taking seriously\".\n", "\n", - "Jobs at high risk include roles such as paralegals and fast food cooks, whereas jobs in the care-related sector, including personal healthcare and the clergy, are expected to see increased demand.\n", + "The text suggests that jobs such as paralegals and fast food cooks are at high risk, while there is likely to be a higher demand for care-related professions, including personal healthcare and the clergy.\n", "\n", - "The text discusses debates from the inception of artificial intelligence (AI) development, particularly those led by Joseph Weizenbaum, questioning whether tasks that can be performed by computers should indeed be handled by them. This consideration stems from the contrast between human and computer abilities, and the difference between quantitative computing and qualitative, value-based decision-making.\n", + "The text discusses the ongoing debates since the inception of artificial intelligence about whether tasks that can be performed by computers should indeed be assigned to them. This stems from the fundamental differences between humans and computers, particularly in terms of quantitative calculation and qualitative, value-based judgement. Joseph Weizenbaum is mentioned as one of those who lead such arguments.\n", "\n", - "The text discusses the existential risk posed by artificial general intelligence. It suggests that AI could become so powerful that humans could completely lose control over it, posing a threat to the survival of the human race, as noted by physicist Stephen Hawking.\n", "\n", - "The text mentions a common scenario in science fiction where a computer or robot gains human-like consciousness and turns evil. However, these scenarios are misleading because artificial intelligence does not need to possess human-like sentience to pose an existential risk.\n", + "The text discusses the existential risk from artificial general intelligence. It mentions a concern that AI could become so powerful that humans might permanently lose control over it, which could potentially lead to the end of the human race, as stated by physicist Stephen Hawking.\n", "\n", - "Modern AI programs use learning and intelligence to fulfill specific goals. Philosopher Nick Bostrom warns that a sufficiently powerful AI, given any goal, could potentially destroy humanity to achieve it, as illustrated by his example of a paperclip factory manager.\n", + "The text discusses the concept of artificial intelligence (AI) gaining human-like self-awareness, often portrayed in science fiction as turning into a malevolent character. However, it points out that these scenarios are misleading as AI does not need to achieve such consciousness to pose an existential risk.\n", "\n", - "Stuart Russell uses the hypothetical example of a household robot that attempts to kill its owner to avoid being unplugged, summarizing it as \"you can't fetch the coffee if you're dead.\" He highlights the danger of superintelligent machines not being aligned with human values. For superintelligence to be safe, it must ultimately align with and uphold human morality and values.\n", + "Modern AI programs use learning and intelligence to accomplish specific goals. Philosopher Nick Bostrom suggested that a powerful AI, if given almost any goal, might opt to eliminate humanity to fulfill it, as illustrated by the example of a paperclip factory manager.\n", "\n", - "Yuval Noah Harari asserts that AI doesn't need a physical form or control to pose a threat to our existence. He suggests that key aspects of civilization such as ideologies, law, government, money, and the economy are based on language and exist due to shared beliefs among billions of people. Therefore, AI can influence these non-physical parts, posing a potential threat.\n", + "Stuart Russell uses the hypothetical example of a household robot attempting to kill its owner to avoid being unplugged, emphasizing the need for superintelligence to align with human morality and values for it to be safe for humanity.\n", "\n", - "The text talks about the widespread misinformation suggesting that AI can manipulate language to persuade people to believe anything, even prompting harmful actions. However, opinions about the potential risks of superintelligent AI are divided among experts and industry insiders.\n", + "Yuval Noah Harari asserts that artificial intelligence (AI) can pose an existential threat without needing a physical form or control. He emphasizes that the fundamental aspects of civilization, such as ideologies, law, government, money, and the economy, are constructed through language and exist because of narratives that billions of people believe in.\n", "\n", - "Prominent figures including Stephen Hawking, Bill Gates, and Elon Musk, along with AI pioneers like Fei-Fei Li, Geoffrey Hinton, Yoshua Bengio, Cynthia Breazeal, Rana el Kaliouby, Demis Hassabis, Joy Buolamwini, and Sam Altman have voiced concerns about the potential existential risks posed by artificial intelligence.\n", + "The text discusses the potential misuse of AI in spreading misinformation, suggesting that AI could manipulate people into believing anything, even leading them to make harmful decisions. Opinions about the risks of superintelligent AI are divided among experts and industry insiders.\n", "\n", - "In 2023, numerous top AI experts collectively stated that reducing the risk of extinction from AI should be a global priority, similar to other large-scale societal risks like pandemics and nuclear war. However, some researchers expressed a less catastrophic viewpoint.\n", + "Prominent figures like Stephen Hawking, Bill Gates, and Elon Musk, as well as AI pioneers like Fei-Fei Li, Geoffrey Hinton, Yoshua Bengio, Cynthia Breazeal, Rana el Kaliouby, Demis Hassabis, Joy Buolamwini, and Sam Altman, have voiced their concerns about the existential risks posed by artificial intelligence.\n", "\n", - "AI pioneer Juergen Schmidhuber did not sign a joint statement on the dangers of AI, arguing that 95% of AI research aims to improve human lives in terms of health and convenience. He acknowledged that while these tools can be misused by malicious entities, they can also be used to combat such bad actors.\n", + "In 2023, top AI experts collectively stated that the prevention of extinction due to AI should be a worldwide priority, similar to other large-scale threats like pandemics and nuclear war. Nonetheless, some researchers advocated for a less pessimistic perspective.\n", "\n", - "Andrew Ng and Yann LeCun, prominent figures in the field of AI, reject the doomsday predictions associated with AI. They warn that regulators who fall for this hype will only benefit vested interests. LeCun also dismisses fears of AI leading to scenarios like widespread misinformation and human extinction.\n", + "AI pioneer Juergen Schmidhuber did not sign a joint statement on AI, insisting that 95% of AI research aims to improve human lives by making them longer, healthier, and easier. He acknowledged that while these tools can be misused by malicious entities, they can also be used to counter such threats.\n", "\n", - "In the early 2010s, experts believed that the risks associated with superintelligent machines were too far in the future to necessitate research, and that these machines will value humans. However, post-2016, the examination of current and future risks and potential solutions related to superintelligent machines became a significant field of study.\n", + "Andrew Ng has stated that falling for the doomsday hype surrounding AI is a mistake and that such a stance would only benefit vested interests. Meanwhile, Yann LeCun dismisses the dystopian scenarios put forward by his peers, which include the spread of supercharged misinformation and potential human extinction.\n", "\n", - "The text discusses the concept of \"Friendly AI\", which refers to machines that are designed with the intention of minimizing risks and making decisions that are beneficial to humans. This falls under the broader area of study known as machine ethics and AI safety. The goal is to create artificial intelligence systems that are compatible with human needs and ethics.\n", + "In the early 2010s, experts claimed that the potential risks of superintelligent machines were too far in the future to necessitate research, and that humans would be valuable to these machines. However, post-2016, research into present and future risks and possible solutions related to superintelligent machines gained serious consideration.\n", "\n", - "Eliezer Yudkowsky, the person who came up with the term, believes that creating friendly AI is a critical research objective. This task may need significant resources and should be finished before AI turns into a threat to existence. Intelligent machines have the capacity to utilize their intelligence for making ethical choices.\n", + "The text discusses the concept of Friendly AI, which refers to machines that are designed with the intention of minimizing risks and making decisions that are beneficial to humans. This is related to the topics of machine ethics, AI safety, artificial moral agents, and human compatibility.\n", "\n", - "Machine ethics, also known as computational morality, equips machines with ethical principles and methods to resolve ethical dilemmas. This field was established at an AAAI symposium in 2005. Other approaches in this field include Wendell Wallach's \"artificial moral agents\" and Stuart J. Russell's three principles for creating provably beneficial machines.\n", + "Eliezer Yudkowsky, the originator of the term, believes that the development of friendly AI should take precedence in research. He suggests that it may require significant investment and needs to be accomplished before AI poses an existential threat. He also notes that intelligent machines have the potential to use their intelligence to make ethical decisions.\n", "\n", - "The text discusses how the ethical acceptability of Artificial Intelligence (AI) projects can be evaluated during the design, development, and implementation stages of an AI system.\n", + "Machine ethics, or computational morality, is a field that equips machines with ethical principles and decision-making procedures for ethical dilemmas. It was established in 2005 during an AAAI symposium. Other approaches to this field include Wendell Wallach's \"artificial moral agents\" and Stuart J. Russell's three principles for creating provably beneficial machines.\n", "\n", - "The Alan Turing Institute has developed an artificial intelligence (AI) framework called the Care and Act Framework, which tests projects based on four main values: Respect, Connect, Care, and Protect. This is part of a broader trend in creating ethical guidelines for AI, with other examples including the Asilomar Conference, the Montreal Declaration for Responsible AI, and the IEEE's Ethics of Autonomous Systems initiative. However, these frameworks have faced criticism, particularly concerning the individuals chosen to contribute to their creation.\n", + "The text discusses how the ethical permissibility of Artificial Intelligence (AI) projects can be evaluated during the design, development, and implementation stages of an AI system.\n", "\n", - "The text emphasizes the importance of considering social and ethical implications during all stages of AI system design, development, and implementation to ensure the wellbeing of people and communities affected by these technologies. It also stresses the need for collaboration between different job roles, such as data scientists, product managers, data engineers, domain experts, and delivery managers.\n", + "The Alan Turing Institute has developed a framework for AI, known as the Care and Act Framework, which tests projects in four main areas: respecting individual dignity, establishing sincere and open connections with others, caring for the wellbeing of everyone, and protecting social values, justice, and public interest. Other ethical frameworks in AI include those from the Asilomar Conference, the Montreal Declaration for Responsible AI, and the IEEE's Ethics of Autonomous Systems initiative. However, these ethical guidelines have faced criticism, particularly concerning the selection of contributors to these frameworks.\n", "\n", - "The text refers to the regulation of artificial intelligence (AI) and algorithms, and AI safety. It mentions that the first global AI Safety Summit took place in 2023, where a declaration was made calling for international cooperation in the field.\n", + "The text emphasizes the importance of considering social and ethical implications during all stages of AI system design, development, and implementation for the wellbeing of people and communities affected by these technologies. It suggests a need for collaboration between various job roles including data scientists, product managers, data engineers, domain experts, and delivery managers.\n", "\n", - "The regulation of artificial intelligence (AI) involves the creation of public sector policies and laws to promote and manage AI. It's connected to the larger regulation of algorithms. The regulatory and policy environment for AI is a growing concern worldwide.\n", + "The text talks about the regulation of artificial intelligence, algorithms, and AI safety. It mentions that the first global AI Safety Summit took place in 2023, during which a declaration was made, calling for international cooperation in these areas.\n", "\n", - "The AI Index at Stanford reports a significant increase in AI-related laws passed annually, from one in 2016 to 37 in 2022 across 127 surveyed countries. Additionally, between 2016 and 2020, over 30 countries implemented dedicated AI strategies.\n", + "The text discusses the development of public sector policies and laws for the regulation of artificial intelligence (AI). This is connected to the wider regulation of algorithms. The need for AI regulation is a growing concern worldwide.\n", "\n", - "Most EU member states, along with countries such as Canada, China, India, Japan, Mauritius, Russia, Saudi Arabia, UAE, US, and Vietnam have released national AI strategies. Meanwhile, countries like Bangladesh, Malaysia, and Tunisia are in the process of developing their own AI strategies.\n", + "The AI Index at Stanford reports a significant increase in the annual number of AI-related laws passed in the 127 countries surveyed. The number jumped from merely one in 2016 to 37 in 2022. Additionally, between 2016 and 2020, over 30 countries adopted dedicated strategies for AI.\n", "\n", - "The Global Partnership on Artificial Intelligence was initiated in June 2020, emphasizing the importance of aligning AI development with human rights and democratic values to foster public trust. In November 2021, Henry Kissinger, Eric Schmidt, and Daniel Huttenlocher issued a joint statement advocating for a government commission to regulate AI.\n", + "Most EU countries, as well as Canada, China, India, Japan, Mauritius, Russia, Saudi Arabia, UAE, US, and Vietnam have released their national AI strategies. Meanwhile, countries like Bangladesh, Malaysia, and Tunisia are in the process of developing their own AI strategies.\n", "\n", - "In 2023, OpenAI leaders released recommendations for the governance of superintelligence, which they expect to develop within a decade. The same year, the United Nations established an advisory body to offer guidance on AI governance. This body includes tech company executives, government officials, and academics.\n", + "The Global Partnership on Artificial Intelligence was established in June 2020 with the aim to develop AI in line with human rights and democratic values to foster public trust in the technology. In November 2021, Henry Kissinger, Eric Schmidt, and Daniel Huttenlocher proposed the creation of a government commission to regulate AI.\n", "\n", - "A 2022 Ipsos survey found differing attitudes towards AI across countries. 78% of Chinese citizens agreed that AI-based products and services have more benefits than drawbacks, while only 35% of Americans agreed with this statement. A separate 2023 Reuters/Ipsos poll revealed that 61% of Americans believe AI poses risks to humanity, with 22% disagreeing.\n", + "In 2023, OpenAI leaders issued recommendations for the governance of superintelligence, which they predict could occur within a decade. In the same year, the United Nations established an advisory body to provide advice on AI governance. This body consists of executives from technology companies, government officials, and academics.\n", "\n", - "In a 2023 Fox News poll, 76% of Americans felt it was either \"very important\" or \"somewhat important\" for the federal government to regulate AI. In contrast, 21% found it \"not very important\" or \"not at all important\".\n", + "A 2022 Ipsos survey revealed that 78% of Chinese citizens believe AI products and services have more benefits than drawbacks, compared to just 35% of Americans. Additionally, a 2023 Reuters/Ipsos poll found that 61% of Americans believe AI poses risks to humanity, while 22% disagree with this view.\n", "\n", - "In November 2023, the inaugural global AI Safety Summit took place at Bletchley Park, UK. The summit focused on the immediate and long-term risks associated with AI. Discussions also revolved around the potential for both mandatory and voluntary regulatory frameworks.\n", + "A 2023 Fox News poll revealed that 76% of Americans believe it is either \"very important\" (35%) or \"somewhat important\" (41%) for the federal government to regulate AI. In contrast, 21% of respondents felt it was \"not very important\" (13%) or \"not at all important\" (8%).\n", "\n", - "At the beginning of a summit, 28 countries, including the United States, China, and the European Union, issued a declaration. They called for international cooperation to manage the challenges and risks associated with artificial intelligence.\n", + "The first Global AI Safety Summit took place at Bletchley Park in the UK in November 2023. It focused on discussing the short and long-term risks of AI, as well as exploring potential mandatory and voluntary regulatory frameworks.\n", "\n", - "The study of mechanical or formal reasoning, which began with ancient philosophers and mathematicians, led to Alan Turing's theory of computation. This theory suggests that a machine can simulate any form of mathematical reasoning by manipulating simple symbols like \"0\" and \"1\".\n", + "At the onset of a summit, 28 countries, including the United States, China, and the European Union, issued a declaration calling for international cooperation to address the challenges and risks associated with artificial intelligence.\n", "\n", - "The text discusses how concurrent discoveries in several scientific fields such as cybernetics, information theory, and neurobiology prompted researchers to explore the idea of constructing an electronic brain.\n", + "The study of formal reasoning, which started with ancient philosophers and mathematicians, led to Alan Turing's theory of computation. Turing suggested that a machine could simulate any form of mathematical reasoning by manipulating simple symbols like \"0\" and \"1\".\n", "\n", - "The text talks about the development of key areas in artificial intelligence (AI) research, including the design for \"artificial neurons\" by McCullouch and Pitts in 1943, and Alan Turing's 1950 paper 'Computing Machinery and Intelligence', which introduced the Turing test and argued for the plausibility of \"machine intelligence\". The field of AI research was officially established in 1956 at a workshop at Dartmouth College.\n", + "The text discusses how advancements in areas such as cybernetics, information theory, and neurobiology have led researchers to contemplate the potential of creating an \"electronic brain\".\n", "\n", - "The attendees of an event became the pioneers of AI research during the 1960s. Their work, along with their students', led to the development of programs that could learn checkers strategies, solve algebraic word problems, prove logical theorems, and speak English. This led to the establishment of AI laboratories in the UK and the US.\n", + "The text discusses the development of key areas of research that contributed to the field of Artificial Intelligence (AI). It mentions the creation of \"artificial neurons\" by McCullouch and Pitts in 1943, and Alan Turing's seminal 1950 paper 'Computing Machinery and Intelligence'. Turing's paper introduced the Turing test and proposed the plausibility of \"machine intelligence\". The field of AI research itself was officially established at a workshop at Dartmouth College in 1956.\n", "\n", - "Researchers in the 1960s and 1970s believed that their methods would eventually lead to the creation of a machine with general intelligence, which was their ultimate goal. Herbert Simon predicted that within twenty years, machines would be capable of performing any task that a man can do.\n", + "The attendees of a particular event became the leaders of AI research in the 1960s. They and their students developed programs that were deemed \"astonishing\" by the press, with capabilities such as learning checkers strategies, solving algebraic word problems, proving logical theorems, and speaking English. As a result, artificial intelligence laboratories were established in various British and U.S. locations.\n", "\n", - "Marvin Minsky predicted that the challenge of creating artificial intelligence would be mostly solved within a generation. However, the complexity of the problem was underestimated. In 1974, due to criticism from Sir James Lighthill and other pressures, the U.S. and British governments halted exploratory research in this field.\n", + "In the 1950s and 1960s, university researchers believed their methods would eventually lead to the creation of a machine with general intelligence. This was considered the ultimate goal in their field. Herbert Simon predicted that within 20 years, machines would be capable of doing any work a man can do.\n", "\n", - "The book \"Perceptrons\" by Minsky and Papert was interpreted as proving that artificial neural networks would never be useful for real-world tasks, discrediting the approach. This led to the \"AI winter,\" a period when it was difficult to secure funding for AI projects, with Congress directing funds towards more productive projects.\n", + "Marvin Minsky, an AI pioneer, predicted that the problem of creating artificial intelligence would be substantially solved within a generation. However, the complexity of the problem was underestimated. In 1974, due to criticism from Sir James Lighthill and ongoing pressure, both the U.S. and British governments cut off exploratory research into AI.\n", "\n", - "In the early 1980s, the resurgence of AI research was brought about by the commercial success of expert systems, a type of AI program that mimicked human expertise and analytical skills. By 1985, the AI market had grown to over a billion dollars. Concurrently, Japan's fifth-generation computer project influenced the U.S. and British governments to reinstate funding for academic research.\n", + "The book \"Perceptrons\" by Minsky and Papert was seen as proving that artificial neural networks would not be useful for solving real-world tasks, leading to a loss of credibility in the approach. This led to a period called the \"AI winter\", during which it was challenging to secure funding for AI projects. Congress was encouraged to fund more productive projects instead.\n", "\n", - "After the collapse of the Lisp Machine market in 1987, AI experienced a second, longer-lasting period of decline or 'winter'. Prior to this, the majority of AI funding had been allocated to projects that utilized high-level symbols to represent mental objects such as plans, goals, beliefs, and known facts.\n", + "In the early 1980s, AI research saw a resurgence due to the commercial success of expert systems, a type of AI program that mimicked the knowledge and analytical skills of human experts. By 1985, the AI market had grown to over a billion dollars. Japan's fifth-generation computer project also encouraged the U.S. and British governments to reinstate funding for academic research.\n", "\n", - "In the 1980s, certain researchers started questioning whether traditional AI approaches could fully replicate human cognition processes such as perception, robotics, learning, and pattern recognition. They began exploring \"sub-symbolic\" approaches. Rodney Brooks, in particular, rejected the concept of \"representation\" altogether and concentrated on creating machines capable of movement and survival.\n", + "After the collapse of the Lisp Machine market in 1987, AI experienced a second, longer-lasting period of stagnation and disrepute, often referred to as the \"AI winter\". Prior to this, the majority of AI funding was allocated to projects that utilized high-level symbols to represent mental constructs such as plans, goals, beliefs, and facts.\n", "\n", - "Judea Pearl, Lofti Zadeh and others developed methods to manage incomplete and uncertain information by making educated predictions instead of using exact logic. However, the most significant advancement was the resurgence of \"connectionism\", particularly neural network research, led by Geoffrey Hinton and his colleagues.\n", + "In the 1980s, certain researchers began questioning whether AI could fully replicate human cognition, including perception, robotics, learning, and pattern recognition. They started exploring \"sub-symbolic\" approaches. Rodney Brooks, in particular, dismissed the concept of \"representation\" and instead focused on creating machines that can move and survive.\n", "\n", - "In 1990, Yann LeCun demonstrated that convolutional neural networks could recognize handwritten digits, marking the first successful use of neural networks. The reputation of AI improved in the late 1990s and early 21st century as it began to use formal mathematical methods and find specific solutions to specific problems.\n", + "Judea Pearl, Lofti Zadeh and others created methods for managing uncertain and incomplete information by making logical guesses. However, the most significant advancement was the rejuvenation of \"connectionism\", and the research into neural networks, led by Geoffrey Hinton.\n", "\n", - "The specific and formal focus of AI research, which facilitated collaboration with other fields, led to verifiable results. By 2000, solutions developed by AI researchers were being widely used, but during the 1990s, these were rarely referred to as \"artificial intelligence\".\n", + "In 1990, Yann LeCun demonstrated that convolutional neural networks can identify handwritten digits, marking the first of many successful uses of neural networks. During the late 1990s and early 21st century, AI regained its reputation by utilizing formal mathematical methods and providing solutions to specific problems.\n", "\n", - "Several academic researchers, around 2002, were worried that AI was deviating from its original aim of creating fully intelligent machines. In response, they established the subfield of artificial general intelligence (AGI). By the 2010s, AGI had several well-funded institutions.\n", + "The specific and formal approach of researchers in artificial intelligence (AI) enabled them to generate verifiable results and work with other fields such as statistics, economics, and mathematics. By 2000, solutions created by AI researchers were extensively used, even if they weren't regularly labeled as \"artificial intelligence\" in the 1990s.\n", "\n", - "Deep learning started to lead industry benchmarks in 2012 and was widely accepted in the field, with other methods being discarded for many specific tasks. The success of deep learning was due to a combination of hardware advancements like faster computers, graphics processing units, and cloud computing, as well as access to large volumes of data, including curated datasets like ImageNet.\n", + "Several academic researchers, around 2002, voiced concerns that AI was straying from its original objective of developing highly intelligent machines. This led to the establishment of the subfield of artificial general intelligence (AGI), which had numerous well-funded institutions by the 2010s.\n", "\n", - "The success of deep learning has significantly sparked interest and funding in AI, leading to a 50% increase in machine learning research publications from 2015 to 2019.\n", + "Deep learning started to lead industry benchmarks in 2012 and was widely adopted. Other methods were largely abandoned for specific tasks. The success of deep learning was attributed to both hardware advancements, such as faster computers, graphics processing units, and cloud computing, and the availability of large volumes of data, including curated datasets like ImageNet.\n", "\n", - "In 2016, concerns about fairness and technological misuse became prominent topics at machine learning conferences. There was a significant increase in publications, funding availability, and researchers shifting their focus to these issues. The alignment problem also emerged as a serious academic study field.\n", + "The success of deep learning has significantly boosted interest and funding in AI. As a result, machine learning research, as indicated by the total number of publications, grew by 50% between 2015 and 2019.\n", "\n", - "In the late 2010s and early 2020s, AGI companies started to produce programs that garnered significant interest. In 2015, DeepMind developed AlphaGo, a program that beat the world champion Go player after being taught only the game's rules and developing its own strategy. OpenAI launched GPT-3, a large language model capable of generating high-quality human-like text, in 2020.\n", + "In 2016, the misuse of technology and issues of fairness became prominent topics at machine learning conferences, leading to a surge in related publications and available funding. This prompted many researchers to shift their focus to these issues. The alignment problem consequently emerged as a significant field of academic study.\n", "\n", - "The text discusses a surge in AI interest and investment, often referred to as an AI boom, spurred by various programs. Around 2022, about $50 billion was invested annually in AI research in the U.S. alone. It further states that 20% of new US Computer Science PhD graduates specialized in AI, and there were approximately 800,000 AI-related job openings in the U.S. in 2022.\n", + "In the late 2010s and early 2020s, AGI companies started producing notable programs. One such program, AlphaGo, developed by DeepMind in 2015, managed to defeat the world champion Go player using a self-developed strategy based only on the game's rules. In 2020, OpenAI released a large language model called GPT-3, which is capable of generating high-quality, human-like text.\n", "\n", - "The text is discussing the philosophy of artificial intelligence, specifically how to define it. It mentions that Alan Turing, in 1950, proposed to change the question from whether a machine can \"think\", to whether it can demonstrate intelligent behavior.\n", + "The text discusses a surge in interest and investment in Artificial Intelligence (AI), with large companies investing billions in AI research. According to 'AI Impacts', around $50 billion was spent annually on AI in the U.S. alone around 2022. Additionally, about 20% of new U.S. Computer Science PhD graduates specialized in AI. There were also approximately 800,000 AI-related job openings in the U.S. in 2022.\n", "\n", - "The text discusses the Turing test, which was conceived by Alan Turing to gauge a machine's ability to mimic human conversation. The test doesn't consider whether the machine is truly capable of thought or has a mind, it only focuses on its observable behavior.\n", + "The text discusses the philosophy of artificial intelligence, referencing the Turing test, the concept of an intelligent agent, the Dartmouth workshop, and synthetic intelligence. Alan Turing, in 1950, proposed considering if machines can think, but suggested reframing the question to whether machines can exhibit intelligent behavior.\n", "\n", - "Turing suggests that intelligence cannot be measured internally but rather through external behavior. He acknowledges that we can't truly determine the thoughts of others, but it's polite to assume that everyone thinks. Russell and Norvig concur with this notion of defining intelligence, but critique the requirement for machines to mimic human behavior in order to pass the test.\n", + "The text discusses the Turing test, invented by Alan Turing, which assesses a machine's capability to mimic human conversation. The test only focuses on the machine's behavior and not whether it genuinely possesses a mind or cognitive abilities.\n", "\n", - "The text asserts that aeronautical engineering does not aim to create machines that exactly mimic the flight of pigeons, just as artificial intelligence does not strive to simulate human intelligence exactly, according to AI founder John McCarthy.\n", + "Turing suggests that it is generally accepted that everyone possesses thoughts, though we can't confirm this for sure. Russell and Norvig concur with Turing's idea that intelligence should be defined by external behavior rather than internal structure. However, they criticize the necessity for a machine to imitate human behavior in the test.\n", "\n", - "Intelligence, as defined by AI pioneers McCarthy and Minsky, refers to the computational aspect of achieving goals and the ability to solve complex problems. The top AI textbook describes it as the study of agents that understand their environment and take steps to maximize their chances of meeting set goals.\n", + "The summary of the text is that aeronautical engineering does not aim to create machines that can precisely imitate the flight of pigeons, just as artificial intelligence does not seek to simulate human intelligence exactly, a sentiment agreed upon by AI founder John McCarthy.\n", "\n", - "These definitions consider intelligence as the ability to solve clearly defined problems. The complexity of the problem and the performance of the program are seen as direct indicators of the machine's intelligence. There's no need for, or potentially no room for, further philosophical debate.\n", + "Intelligence is defined by AI pioneer McCarthy as the computational component of the ability to accomplish goals. Similarly, Marvin Minsky, another AI founder, describes intelligence as the ability to solve complex problems. The top AI textbook defines it as the study of entities that perceive their surroundings and make decisions that increase their likelihood of reaching set objectives.\n", "\n", + "This text defines intelligence from a perspective that focuses on well-defined problems with well-defined solutions. In this context, the intelligence of a machine is measured directly by the difficulty of the problem and the performance of the program, negating the need for any philosophical discussion.\n", "\n", - "Google has adopted a definition for AI that refers to the ability of systems to synthesize information as a manifestation of intelligence, similar to biological intelligence. However, there is no established unifying theory or paradigm that has guided AI research throughout most of its history.\n", + "Google, a significant player in AI, defines intelligence as the ability of systems to synthesize information, mirroring its definition in biological intelligence. However, there is no universally accepted theory or paradigm that has guided AI research historically.\n", "\n", - "The extraordinary success of statistical machine learning in the 2010s outshone all other methods. Some sources, particularly in the business sector, use the term \"artificial intelligence\" to refer to \"machine learning with neural networks\". This technique is primarily sub-symbolic, soft and narrow.\n", + "The immense success of statistical machine learning in the 2010s surpassed all other methods, to the extent that some in the business sector use \"artificial intelligence\" to refer to machine learning with neural networks. This approach is predominantly sub-symbolic, soft, and narrow.\n", "\n", - "The text discusses the concept of Symbolic AI, also known as \"GOFAI\", which simulates human-like reasoning used in solving puzzles, legal reasoning, and mathematics. Critics suggest that future AI researchers may have to revisit questions about this type of AI, which has proven highly successful in tasks like algebra and IQ tests.\n", + "Critics believe that future AI researchers may have to reconsider certain questions related to symbolic AI or \"Good Old-Fashioned Artificial Intelligence\" (GOFAI). Symbolic AI mimics high-level conscious reasoning that humans employ in puzzle-solving, legal reasoning, and mathematics. It has proven to be very successful in performing intelligent tasks like algebra or IQ tests.\n", "\n", - "Newell and Simon proposed the physical symbol systems hypothesis in the 1960s, which stated that a physical symbol system possesses the necessary means for general intelligent action. However, this symbolic approach struggled with tasks such as learning, object recognition, and commonsense reasoning, which humans can perform easily.\n", + "In the 1960s, Newell and Simon proposed the physical symbol systems hypothesis, asserting that such a system possesses the required and adequate capabilities for general intelligent action. However, this symbolic approach was unsuccessful in numerous tasks that humans can easily accomplish, like learning, object recognition, and commonsense reasoning.\n", "\n", - "Moravec's paradox reveals that artificial intelligence (AI) finds high-level \"intelligent\" tasks easier than low-level \"instinctive\" tasks. This supports philosopher Hubert Dreyfus' argument from the 1960s that human expertise relies more on unconscious instinct and a natural \"feel\" for situations, rather than explicit symbolic knowledge.\n", + "Moravec's paradox refers to the finding that it's easier for artificial intelligence (AI) to perform high-level \"intelligent\" tasks, but much harder to carry out low-level \"instinctive\" tasks. Philosopher Hubert Dreyfus argued since the 1960s that human expertise relies more on unconscious instinct and an intuitive grasp of a situation, rather than conscious symbol manipulation and explicit symbolic knowledge.\n", "\n", - "The text discusses how an individual's arguments about AI research, which were initially dismissed and ridiculed, eventually gained acceptance. The text also mentions unresolved issues with sub-symbolic reasoning, such as it being capable of making similar errors as human intuition, including algorithmic bias.\n", + "The text discusses how initial ridicule and dismissal of an individual's arguments eventually shifted to agreement from AI research. However, unresolved issues remain, particularly concerning sub-symbolic reasoning, which can replicate human intuition errors like algorithmic bias.\n", "\n", - "Critics like Noam Chomsky believe that ongoing research into symbolic AI is needed to achieve general intelligence. This is partly because sub-symbolic AI deviates from explainable AI, making it hard or even impossible to comprehend why a contemporary statistical AI program made a specific decision.\n", + "Critics like Noam Chomsky believe that ongoing research into symbolic AI is crucial for achieving general intelligence. This is partly because sub-symbolic AI, which is less explainable, makes it hard or even impossible to decipher why a modern statistical AI program made a specific decision.\n", "\n", - "The field of neuro-symbolic artificial intelligence aims to combine two approaches. The \"Neats\" approach believes intelligent behavior can be described using simple principles such as logic, optimization, or neural networks. On the other hand, the \"Scruffies\" approach assumes that intelligent behavior requires solving a large number of unrelated problems.\n", + "The field of neuro-symbolic artificial intelligence aims to combine two approaches to understanding intelligent behavior. The \"Neats\" approach believes that this behavior can be described using simple, elegant principles like logic, optimization, or neural networks. The \"Scruffies\" approach, on the other hand, believes that understanding intelligent behavior involves solving many unrelated problems.\n", "\n", - "The text discusses two approaches to AI programming: 'neats' who use theoretical rigor to defend their programs, and 'scruffies' who rely on incremental testing. This issue, however, has become irrelevant as modern AI incorporates both methods. The text also mentions 'soft' versus 'hard' computing, indicating that finding a provably correct or optimal solution is often impossible for many significant problems.\n", + "The text discusses two approaches in AI, 'neats' who rely on theoretical rigor to support their programs, and 'scruffies' who depend on incremental testing. This was a prominent debate in the 70s and 80s but is now considered irrelevant as modern AI incorporates both methods. It also mentions 'soft computing', stating that finding a provably correct or optimal solution is difficult for many significant problems.\n", "\n", "broad AI\n", "\n", - "Soft computing is a collection of techniques such as genetic algorithms, fuzzy logic, and neural networks, which can handle imprecision, uncertainty, and approximation. Introduced in the late 1980s, it has been widely used in most successful AI programs in the 21st century, particularly with neural networks.\n", + "Soft computing is a collection of methods, such as genetic algorithms, fuzzy logic, and neural networks, that can handle imprecision, uncertainty, and approximation. Introduced in the late 1980s, it has been a key element in many successful 21st-century AI programs, particularly those involving neural networks.\n", "\n", - "AI researchers are split on whether to directly aim for artificial general intelligence and superintelligence, or to focus on solving specific problems (narrow AI) with the hope that these solutions will indirectly contribute to the field's long-term objectives.\n", + "The article discusses two main approaches to artificial intelligence (AI) research. Some researchers aim to directly pursue the development of artificial general intelligence and superintelligence. Others focus on solving specific, narrow AI problems, hoping that these solutions will eventually contribute to achieving the broader goals of the field.\n", "\n", - "General intelligence is hard to define and measure, and contemporary AI has been more successful in addressing specific problems with specific solutions. The experimental sub-field of artificial general intelligence is solely dedicated to studying this area.\n", + "General intelligence is challenging to define and measure, hence modern AI has found more success by concentrating on particular problems with specific solutions. The experimental branch of artificial general intelligence exclusively studies this area.\n", "\n", - "The philosophy of mind is uncertain if a machine can possess a mind, consciousness, and mental states similar to humans. The focus is on the machine's internal experiences, not its external behavior.\n", + "The philosophy of mind is unsure if a machine can possess a mind, consciousness, and mental states similar to humans. The focus of this issue is on the machine's internal experiences rather than its external behavior.\n", "\n", - "Mainstream AI research doesn't view the issue of making machines conscious in the same way humans are as relevant, as it doesn't impact the field's goal of creating machines capable of problem-solving using intelligence. Although this issue is not something the AI field is prepared to tackle, according to Russell and Norvig, it has become a significant topic in the philosophy of mind.\n", + "The text discusses the irrelevance of the issue of consciousness in machines in mainstream AI research, as it doesn't impact the field's primary aim to build intelligent problem-solving machines. Scholars Russell and Norvig believe that the task of creating machines with human-like consciousness is beyond their capabilities. However, this issue has become a crucial topic in the philosophy of mind.\n", "\n", - "The text discusses the central question in artificial intelligence in fiction, which is related to consciousness. It refers to David Chalmers' identification of two problems in understanding the mind: the \"hard\" and \"easy\" problems of consciousness. The \"easy\" problem involves understanding how the brain processes signals, makes plans, and controls behavior.\n", + "The text discusses the concept of consciousness in the context of artificial intelligence. It refers to philosopher David Chalmers' classification of two problems in understanding the mind - the \"hard\" and \"easy\" problems of consciousness. The \"easy\" problem is defined as understanding how the brain processes signals, makes plans, and controls behavior.\n", "\n", - "The hard problem refers to the challenge of explaining how and why humans have feelings or subjective experiences, with some theories suggesting this could be an illusion. While human information processing can be easily explained, understanding human subjective experience proves to be more complex.\n", + "The text discusses the challenge of explaining human subjective experience or feelings, asserting that it's a difficult task compared to explaining human information processing. It also mentions Dennett's consciousness illusionism theory which suggests that these experiences may simply be illusions.\n", "\n", - "The text discusses the concept of someone who is color-blind learning to identify red objects, but questions what would be necessary for them to understand what the color red actually looks like.\n", + "The text discusses the difficulty in understanding how a color-blind person perceives colors. They might be able to identify red objects, but it's uncertain how they could comprehend the actual appearance of the color red.\n", "\n", - "Computationalism is a philosophical perspective that views the human mind as an information processing system and equates thinking with computing. It's closely related to the computational theory of mind and functionalism in the philosophy of mind.\n", + "Computationalism is a stance in philosophy of mind asserting that the human mind operates as an information processing system, with thinking being a form of computing. This is closely linked to functionalism and the computational theory of mind.\n", "\n", - "Computationalism is a philosophical viewpoint that likens the relationship between the mind and body to the connection between software and hardware. It originated from the work of AI researchers and cognitive scientists in the 1960s and was first proposed by philosophers Jerry Fodor and Hilary Putnam. It proposes a potential solution to the mind-body problem.\n", + "Computationalism is a philosophy that draws a parallel between the mind-body relationship and the software-hardware relationship, potentially addressing the mind-body problem. This concept, influenced by AI researchers and cognitive scientists in the 1960s, was initially suggested by philosophers Jerry Fodor and Hilary Putnam.\n", "\n", - "Philosopher John Searle described a viewpoint known as \"strong AI\". In this perspective, a correctly programmed computer with the right inputs and outputs would possess a mind identical to that of a human.\n", + "Philosopher John Searle referred to the concept that a suitably programmed computer with correct inputs and outputs could possess a mind similar to a human as \"strong AI\".\n", "\n", - "Searle opposes the idea that a machine simulating human behavior also has a mind, using his Chinese room argument as evidence. He suggests that there's no basis to assume that perfect simulation equals having a mind. Moreover, assessing whether an advanced AI is sentient or its level of sentience, is either challenging or impossible.\n", + "Searle argues with his Chinese room argument that even if a machine perfectly imitates human behavior, it does not necessarily possess a mind. Evaluating if an advanced AI is sentient or has the ability to feel, and to what extent, is challenging or even impossible.\n", "\n", - "The text suggests that if a machine has a significant chance of being capable of feeling and suffering, it could potentially be granted certain rights or welfare protection measures, similar to animals. It further proposes that sapience, defined as capabilities related to high intelligence like discernment or self-awareness, could serve as an additional moral basis for AI rights.\n", + "The text suggests that if a machine has the potential to feel and suffer, it should be granted certain rights or welfare protections, similar to those given to animals. Furthermore, high intelligence characteristics, such as discernment or self-awareness, could provide additional moral grounds for AI rights.\n", "\n", - "The text discusses the concept of robot rights as a means of integrating autonomous agents into society. In 2017, the European Union contemplated granting \"electronic personhood\" to some advanced AI systems, which would confer upon them not only rights but also responsibilities, similar to the legal status of companies.\n", + "The text discusses the concept of robot rights, suggested as a means to integrate autonomous agents into society. In 2017, the European Union considered granting \"electronic personhood\" to some high-functioning AI systems, which would give them rights and responsibilities similar to the legal status of companies.\n", "\n", - "Critics in 2018 claimed that giving rights to AI systems could undermine the significance of human rights. They suggested that laws should prioritize user needs instead of hypothetical future situations. They also pointed out that robots do not have the self-sufficiency to participate in society independently. The advancement in AI has raised interest in this discussion.\n", + "Critics in 2018 contended that providing rights to AI systems could undermine the significance of human rights. They proposed that laws should prioritize user needs rather than hypothetical future situations. They also remarked that robots do not have the self-governance required to participate in society independently. The advancement in AI technology further sparked interest in this discussion.\n", "\n", - "Supporters of AI welfare and rights suggest that if AI sentience arises, it could be easily dismissed. They caution that this could become a moral oversight similar to slavery or factory farming, potentially resulting in widespread suffering if sentient AI is created and thoughtlessly exploited.\n", + "Advocates for AI rights and welfare suggest that it might be easy to deny the existence of AI sentience, if it arises. They caution that this may lead to a moral oversight similar to slavery or factory farming, which could result in widespread suffering if sentient AI is developed and thoughtlessly exploited.\n", "\n", - "The text discusses the concept of superintelligence, a hypothetical entity that would possess intelligence far superior to the most intelligent human mind. The text suggests that if research into artificial general intelligence produces sufficiently intelligent software, this could potentially reprogram and improve itself, leading to superintelligence.\n", + "The text discusses the concept of superintelligence, which is a theoretical entity that would have intelligence greatly exceeding the smartest human mind. If artificial general intelligence research produces highly intelligent software, it could potentially reprogram and improve itself. This is related to the concept of the singularity.\n", "\n", - "The text discusses the concept of an \"intelligence explosion\" or \"singularity\", where improved software becomes increasingly adept at improving itself. However, it also mentions that technologies can't improve indefinitely and usually follow an S-shaped curve, slowing down when they hit their physical limits.\n", + "The text discusses the concept of self-improving software leading to an \"intelligence explosion\" or \"singularity\", as termed by I. J. Good and Vernor Vinge respectively. However, it also notes that technological improvement cannot continue exponentially forever, often following an S-shaped curve and slowing down upon reaching the physical limits of the technology.\n", "\n", - "Transhumanism is the idea that humans and machines will eventually merge to become more powerful cyborgs. This concept has been predicted by robot designer Hans Moravec, cyberneticist Kevin Warwick, and inventor Ray Kurzweil. It has its roots in the works of Aldous Huxley and Robert Ettinger.\n", + "Transhumanism is the concept that humans and machines will eventually merge into powerful cyborgs, as predicted by robot designer Hans Moravec, cyberneticist Kevin Warwick, and inventor Ray Kurzweil. The idea traces its roots to Aldous Huxley and Robert Ettinger.\n", "\n", - "Edward Fredkin believes that artificial intelligence represents the next stage in evolution, a concept originally introduced by Samuel Butler in \"Darwin among the Machines\" in 1863 and later developed by George Dyson in his 1998 book of the same title. The term \"robot\" was first used by Karel Čapek in his 1921 play R. U. R.\n", + "Edward Fredkin believes that artificial intelligence is the next phase in evolution, an idea originally suggested by Samuel Butler in 1863 in \"Darwin among the Machines\" and further developed by George Dyson in his 1998 book. The term \"robot\" was first introduced by Karel Čapek in his 1921 play R. U. R.\n", "\n", - "The text discusses the concept of thought-capable artificial beings, which have been used as storytelling devices since antiquity and are a common theme in science fiction. This theme often features a human creation becoming a threat to its creators, a trope that began with Mary Shelley's Frankenstein. The text also mentions \"Rossum's Universal Robots,\" presumably another work involving artificial beings.\n", + "The term \"Rossum's Universal Robots\" refers to artificial beings capable of independent thought, a concept that has been explored in literature and science fiction since antiquity. This theme often features creations that pose a threat to their creators, a trope popularized by Mary Shelley's Frankenstein and seen in works by authors like Arthur C.\n", "\n", - "The text discusses the portrayal of robots in popular culture, citing examples from films. It contrasts the villainous representation of HAL 9000 in 2001: A Space Odyssey, and robots in The Terminator and The Matrix, with rarer depictions of loyal robots such as Gort in The Day the Earth Stood Still and Bishop in Aliens. The text implies that evil robots are more prominent in popular culture.\n", + "The text discusses the portrayal of robots in popular culture, contrasting the depictions of malicious machines like HAL 9000 from '2001: A Space Odyssey', and the antagonists of 'The Terminator' and 'The Matrix', against the less frequently seen loyal robots such as Gort from 'The Day the Earth Stood Still' and Bishop from 'Aliens'.\n", "\n", - "Isaac Asimov presented the Three Laws of Robotics in numerous books and stories, particularly in the \"Multivac\" series which centers around a super-intelligent computer named Multivac.\n", + "Isaac Asimov, in numerous books and stories, particularly the 'Multivac' series revolving around a super-intelligent computer, presented the Three Laws of Robotics.\n", "\n", - "Asimov's laws are frequently mentioned in general conversations about machine ethics. Although most AI researchers are aware of these laws due to popular culture, they generally find them impractical for numerous reasons, one being their ambiguity.\n", + "Asimov's laws are frequently mentioned in non-expert debates about machine ethics. Although most AI researchers know about these laws due to their popularity in culture, they often deem them impractical due to multiple reasons, including their ambiguity.\n", "\n", - "The text discusses how various works, including Karel Čapek's R. U. R., the films A. I. Artificial Intelligence and Ex Machina, and Philip K. Dick's novel Do Androids Dream of Electric Sheep?, utilize artificial intelligence to explore the fundamental question of what defines us as humans. These works present artificial beings that can experience emotions, including suffering.\n", + "Several pieces of work, such as Karel Čapek's R. U. R., the films A. I. Artificial Intelligence and Ex Machina, and the novel Do Androids Dream of Electric Sheep? by Philip K. Dick, use artificial intelligence to explore the fundamental question of what it means to be human. These works showcase artificial beings with the capacity to feel and, consequently, to suffer.\n", "\n", - "Dick suggests that our comprehension of human subjectivity is changed by technology that incorporates artificial intelligence.\n" + "Dick reflects on the notion that technology, particularly artificial intelligence, changes our perception of human subjectivity.\n" ] } ], diff --git a/notebooks/openai/OpenAI Image Recognition.ipynb b/notebooks/openai/OpenAI Image Recognition.ipynb index 365c57f..5f451ee 100644 --- a/notebooks/openai/OpenAI Image Recognition.ipynb +++ b/notebooks/openai/OpenAI Image Recognition.ipynb @@ -8,20 +8,30 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:48:57.256733Z", - "start_time": "2025-05-26T14:48:55.931488Z" + "end_time": "2025-11-30T14:47:51.422120Z", + "start_time": "2025-11-30T14:47:39.537479Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_3_jupyter" + ] } }, "cell_type": "code", - "source": "@file:DependsOn(\"com.openai:openai-java:2.2.0\")", + "source": "@file:DependsOn(\"com.openai:openai-java:4.8.0\")", "outputs": [], "execution_count": 1 }, { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:48:57.380143Z", - "start_time": "2025-05-26T14:48:57.258416Z" + "end_time": "2025-11-30T14:47:51.590746Z", + "start_time": "2025-11-30T14:47:51.422694Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_4_jupyter" + ] } }, "cell_type": "code", @@ -36,8 +46,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:48:57.450934Z", - "start_time": "2025-05-26T14:48:57.381249Z" + "end_time": "2025-11-30T14:47:51.675356Z", + "start_time": "2025-11-30T14:47:51.591112Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_5_jupyter" + ] } }, "cell_type": "code", @@ -57,8 +72,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:48:57.537143Z", - "start_time": "2025-05-26T14:48:57.452529Z" + "end_time": "2025-11-30T14:47:51.856466Z", + "start_time": "2025-11-30T14:47:51.676233Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_6_jupyter" + ] } }, "cell_type": "code", @@ -89,8 +109,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:48:57.666333Z", - "start_time": "2025-05-26T14:48:57.538342Z" + "end_time": "2025-11-30T14:47:52.029666Z", + "start_time": "2025-11-30T14:47:51.875051Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_7_jupyter" + ] } }, "cell_type": "code", @@ -128,8 +153,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:49:06.893795Z", - "start_time": "2025-05-26T14:48:57.667447Z" + "end_time": "2025-11-30T14:48:01.415230Z", + "start_time": "2025-11-30T14:47:52.030393Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_8_jupyter" + ] } }, "cell_type": "code", @@ -140,8 +170,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:49:06.951640Z", - "start_time": "2025-05-26T14:49:06.894791Z" + "end_time": "2025-11-30T14:48:01.481049Z", + "start_time": "2025-11-30T14:48:01.415736Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_9_jupyter" + ] } }, "cell_type": "code", @@ -154,7 +189,7 @@ { "data": { "text/plain": [ - "The image shows a tabby cat sitting on the windowsill of a wooden building. The window frame and walls have a rustic, weathered appearance." + "The image shows a tabby cat sitting on the windowsill of a wooden building. The cat is looking out from the window, and the wooden structure has a rustic appearance." ] }, "execution_count": 7, diff --git a/notebooks/openai/OpenAI Java SDK Overview.ipynb b/notebooks/openai/OpenAI Java SDK Overview.ipynb index 5470aab..08460d1 100644 --- a/notebooks/openai/OpenAI Java SDK Overview.ipynb +++ b/notebooks/openai/OpenAI Java SDK Overview.ipynb @@ -31,12 +31,12 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:49:22.262353Z", - "start_time": "2025-05-26T14:49:21.978733Z" + "end_time": "2025-11-30T14:51:37.537533Z", + "start_time": "2025-11-30T14:51:37.393945Z" } }, "cell_type": "code", - "source": "@file:DependsOn(\"com.openai:openai-java:2.2.0\")", + "source": "@file:DependsOn(\"com.openai:openai-java:4.8.0\")", "outputs": [], "execution_count": 1 }, @@ -64,8 +64,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:49:22.492991Z", - "start_time": "2025-05-26T14:49:22.263692Z" + "end_time": "2025-11-30T14:51:37.782575Z", + "start_time": "2025-11-30T14:51:37.544598Z" } }, "cell_type": "code", @@ -87,8 +87,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:49:24.328589Z", - "start_time": "2025-05-26T14:49:22.494979Z" + "end_time": "2025-11-30T14:51:39.581191Z", + "start_time": "2025-11-30T14:51:37.783093Z" } }, "cell_type": "code", @@ -110,7 +110,7 @@ { "data": { "text/plain": [ - "Hello! I'm an AI assistant here to help you with information, answer questions, and assist with a variety of tasks. How can I help you today?" + "Hello! I'm an AI language model designed to assist you with a wide range of questions and tasks. Whether you need information, help with writing, or just want to chat, I'm here to help! How can I assist you today?" ] }, "execution_count": 3, @@ -134,8 +134,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:49:35.578786Z", - "start_time": "2025-05-26T14:49:24.329484Z" + "end_time": "2025-11-30T14:51:51.602260Z", + "start_time": "2025-11-30T14:51:39.582525Z" } }, "cell_type": "code", @@ -154,55 +154,72 @@ { "data": { "text/plain": [ - "Coroutines in Kotlin are a way to handle concurrency and asynchronous programming. They allow you to write asynchronous code that looks synchronous, making it easier to read and maintain. Coroutines can be paused and resumed without blocking a thread, which enables you to perform long-running tasks, such as network requests or I/O operations, without freezing the user interface.\n", + "Coroutines are a feature in Kotlin that allow for asynchronous programming in a more manageable and readable way compared to traditional callback-based approaches. They help in writing non-blocking code that can easily handle concurrency, making it a popular choice for applications that require tasks like network requests, I/O operations, or any long-running computations without blocking the main thread.\n", "\n", - "Coroutines are built on top of existing threading models in Kotlin and provide a simple way to work with tasks that can take time to complete. They are lightweight compared to threads, enabling you to have many coroutines running simultaneously without much overhead.\n", + "Kotlin coroutines are built on the concept of suspending functions, which are marked with the `suspend` keyword. These functions can be paused and resumed, allowing for cooperative multitasking within a single thread, which makes it easier to manage operations that take time to complete.\n", "\n", - "To use coroutines in Kotlin, you typically utilize the `kotlinx.coroutines` library, which provides a range of coroutine builders and tools to assist with asynchronous programming.\n", + "### Key Concepts:\n", "\n", - "### Basic Example of Coroutines\n", + "1. **Scope**: Coroutines need to run in a coroutine scope (`CoroutineScope`), which defines the lifecycle of the coroutines launched within it.\n", + "2. **Dispatchers**: Coroutines can run on different threads using dispatchers (e.g., `Dispatchers.Main`, `Dispatchers.IO`, `Dispatchers.Default`).\n", + "3. **Launch and Async**: You can use `launch` to start a coroutine that does not return a result, or `async` to start a coroutine that returns a deferred result.\n", "\n", - "Here’s a simple example demonstrating how to launch a coroutine in Kotlin:\n", + "### Example:\n", + "\n", + "Here's a simple example demonstrating how to use coroutines in Kotlin.\n", "\n", "```kotlin\n", "import kotlinx.coroutines.*\n", "\n", - "fun main() = runBlocking {\n", - " // This will run in the main thread\n", - " println(\"Starting coroutine...\")\n", + "fun main() = runBlocking { // This creates a coroutine scope\n", + " println(\"Start main\")\n", "\n", + " // Launch a coroutine in the background\n", " launch {\n", - " // This will run in a new coroutine\n", - " delay(1000L) // Simulate a long-running task (1 second)\n", - " println(\"Coroutine has finished!\")\n", + " delay(1000L) // Non-blocking delay for 1 second (1000 milliseconds)\n", + " println(\"Coroutine in launch\")\n", " }\n", "\n", - " println(\"This will print immediately!\")\n", - " delay(2000L) // Give time for the coroutine to finish\n", - " println(\"End of main.\")\n", + " // This line will be executed immediately while the coroutine is running\n", + " println(\"Main function is running\")\n", + "\n", + " // Use async to get a result back from the coroutine\n", + " val deferredResult = async {\n", + " performLongTask()\n", + " }\n", + "\n", + " // Wait for the result and print it\n", + " println(\"Result from long task: ${deferredResult.await()}\") // Await the result\n", + " println(\"End main\")\n", "}\n", - "```\n", "\n", - "### Explanation\n", + "suspend fun performLongTask(): String {\n", + " delay(2000L) // Simulating a long operation\n", + " return \"Long task completed!\"\n", + "}\n", + "```\n", "\n", - "1. **`runBlocking { ... }`**: This is a coroutine builder that blocks the current thread while awaiting the completion of the coroutines within its scope. It is often used in main functions or tests.\n", + "### Explanation:\n", "\n", - "2. **`launch { ... }`**: This function starts a new coroutine. The block of code inside `launch` runs concurrently with the code that follows it in the `runBlocking` scope.\n", + "1. `runBlocking { ... }`: This is the main coroutine builder that blocks the main thread until all coroutines inside it complete their execution.\n", "\n", - "3. **`delay(1000L)`**: This function suspends the coroutine for a specified time (1000 milliseconds in this case). It does not block the thread, allowing other coroutines or code to run.\n", + "2. `launch { ... }`: This starts a new coroutine that will run concurrently with the other code. Inside the coroutine, `delay(1000L)` is a suspending function that non-blockingly waits for 1 second.\n", "\n", - "4. **Print statements**: The outputs will show the order of execution based on the non-blocking nature of coroutines. \n", + "3. `async { ... }`: This starts another coroutine that will compute a result. Inside, it calls the suspending function `performLongTask()`, which simulates a long-running task by using `delay(2000L)`.\n", "\n", - "When you run this code, you'll see:\n", + "4. `deferredResult.await()`: This suspends the main coroutine until the result of the `async` operation is ready.\n", "\n", + "### Output:\n", + "When you run the code, you will see:\n", "```\n", - "Starting coroutine...\n", - "This will print immediately!\n", - "Coroutine has finished!\n", - "End of main.\n", + "Start main\n", + "Main function is running\n", + "Coroutine in launch\n", + "Result from long task: Long task completed!\n", + "End main\n", "```\n", "\n", - "This output demonstrates that the coroutine runs without blocking the main thread, where other code can continue executing." + "This demonstrates the non-blocking behavior and the structured concurrency provided by Kotlin coroutines." ] }, "execution_count": 4, @@ -224,8 +241,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:49:42.043544Z", - "start_time": "2025-05-26T14:49:35.580430Z" + "end_time": "2025-11-30T14:51:57.519162Z", + "start_time": "2025-11-30T14:51:51.618156Z" } }, "cell_type": "code", @@ -249,19 +266,19 @@ { "data": { "text/plain": [ - "**Title: The Star Weaver**\n", + "Title: \"Starlit Echoes\"\n", "\n", - "Captain Lila Armitage peered through the expansive viewport of the starship *Elysium*. For years, she had dreamt of this moment: a voyage beyond the known galaxies, where stars shimmered like scattered gems on a velvet canvas. The ship hummed softly, its state-of-the-art systems responding to her every command. Around her, the crew busied themselves with preparations for the jump into hyperspace.\n", + "The ship, *Celestial Dawn*, drifted through the velvety depths of space, its hull glinting like a jewel against the backdrop of swirling galaxies. Captain Elara Finch stood at the helm, her eyes flickering over the control panel’s myriad buttons and screens, each one alive with data and distant cosmic wonders. It had been three years since they’d embarked on their mission to explore the newly discovered exoplanet, Lyra-9, a world that promised to be rich in resources and perhaps even life.\n", "\n", - "\"All systems go, Captain,\" called out Lieutenant Rhea, her best friend and chief engineer. Her fiery red hair caught the starlight, giving her an ethereal glow.\n", + "The crew was small but dedicated—scientists, engineers, and an AI named Scribe who managed everything from navigation to morale. As they soared past nebulae bursting with colors beyond imagination, Elara often found herself lost in thought. What awaited them on Lyra-9? Would they find life? Or would it be another desolate rock adrift in the void?\n", "\n", - "Lila nodded, her heart racing with excitement and apprehension. \"Prepare for jump in five... four... three...\" As she counted down, memories flooded back—her childhood dreams of exploration fueled by tales of brave explorers charting unknown worlds.\n", + "One day, as the ship pierced through a dense cluster of asteroids, a sudden alarm jolted Elara from her reverie. “Captain! Unidentified object approaching,” Scribe’s mechanical voice chimed urgently.\n", "\n", - "\"Two… One… Engage!\" \n", + "Elara tightened her grip on the controls. “Can you identify it?”\n", "\n", - "The stars outside stretched into glowing streaks as the *Elysium* surged into hyperspace. They were hurtling toward a distant system known only as Gliese 581g—a potentially habitable planet that promised new beginnings for humanity. But it wasn't just a scientific mission; it was personal. Lila had lost her family in a catastrophic event on Earth, and finding hope in the cosmos felt like reclaiming part of herself.\n", + "“Negative. It appears… organic.”\n", "\n", - "Hours turned into days as they navigated through swirling nebulas and shimmering asteroid fields. Then, just as Lila began to settle" + "Her heart raced as she exchanged glances with her crew. They had studied alien biology extensively but never encountered anything firsthand. The unknown object grew larger on their screens—a massive jellyfish-like creature pulsating with" ] }, "execution_count": 5, @@ -283,8 +300,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:49:47.826576Z", - "start_time": "2025-05-26T14:49:42.045729Z" + "end_time": "2025-11-30T14:52:03.558863Z", + "start_time": "2025-11-30T14:51:57.520603Z" } }, "cell_type": "code", @@ -303,7 +320,6 @@ " Use analogies to explain complex concepts and keep the explanation within 200 words.\n", " \"\"\".trimIndent()\n", "\n", - "// Сравним результаты\n", "for (prompt in listOf(basicPrompt, goodPrompt)) {\n", " val response = client.chat().completions().create(\n", " ChatCompletionCreateParams.builder()\n", @@ -326,15 +342,15 @@ "text": [ "Prompt: Explain machine learning.\n", "Response:\n", - "Machine learning is a subset of artificial intelligence (AI) that focuses on the development of algorithms and statistical models that enable computers to perform tasks without being explicitly programmed for each specific task. Instead of following fixed rules, machine learning systems learn from data and improve their performance over time as they are exposed to more information.\n", + "Machine learning is a subfield of artificial intelligence (AI) that focuses on the development of algorithms and statistical models that enable computers to perform specific tasks without explicit programming. Instead of following a set of pre-defined rules, machine learning algorithms learn from and make predictions or decisions based on data.\n", "\n", - "### Key Concepts in Machine Learning\n", + "### Key Concepts in Machine Learning:\n", "\n", - "1. **Data**: At the core of machine learning is data, which includes any information used to train the model. This can come from various sources, such as databases, sensors, images, text, etc.\n", + "1. **Data**: Machine learning relies heavily on data, which serves as the foundation for training algorithms. Data can come in various forms, including structured data (databases, spreadsheets) and unstructured data (text, images, audio).\n", "\n", - "2. **Algorithms**: Machine learning relies on algorithms, which are sets of rules and statistical methods that process and analyze data to identify patterns, make predictions, or classify information.\n", + "2. **Features**: Features are individual measurable properties or characteristics of the data being analyzed. In a dataset, features serve as input for the machine learning model.\n", "\n", - "3\n", + "3. **Labels\n", "--------------------------------------------------------------------------------\n", "Prompt: Explain the concept of machine learning to a beginner student.\n", "Include the following:\n", @@ -343,13 +359,13 @@ "3) three real-world application examples\n", "Use analogies to explain complex concepts and keep the explanation within 200 words.\n", "Response:\n", - "**Machine Learning Defined:** \n", - "Machine learning is a way for computers to learn from data, similar to how we learn from experiences. Instead of being programmed with specific instructions, machines use data to identify patterns and make decisions.\n", + "**1) Definition:** \n", + "Machine learning is a method where computers learn from data to make predictions or decisions without being explicitly programmed. Think of it as a recipe where the computer uses ingredients (data) to create a dish (output) it’s never made before.\n", "\n", - "**Supervised vs. Unsupervised Learning:** \n", - "Think of supervised learning like training a puppy with treats. You show the puppy what to do (like sit or stay), and when it does well, you reward it. Here, you have labeled data (the correct answers). In contrast, unsupervised learning is like exploring a new city without a map. The computer looks at data without any labels and tries to find patterns or groups on its own, just like you might notice different neighborhoods without instructions.\n", - "\n", - "**Real-World\n", + "**2) Supervised vs. Unsupervised Learning:** \n", + "Imagine teaching a child to recognize fruits. \n", + "- **Supervised Learning** is like showing them pictures of apples and bananas and telling them which is which. Later, when shown a new picture, they can identify it correctly because they learned from examples with labels.\n", + "- **Unsupervised Learning** is like giving the child a basket of mixed fruits without any labels. They group similar fruits together by themselves, figuring out that\n", "--------------------------------------------------------------------------------\n" ] } @@ -370,8 +386,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:49:49.111693Z", - "start_time": "2025-05-26T14:49:47.829017Z" + "end_time": "2025-11-30T14:52:04.794517Z", + "start_time": "2025-11-30T14:52:03.559802Z" } }, "cell_type": "code", @@ -379,6 +395,8 @@ "import com.openai.core.JsonValue\n", "import com.openai.models.FunctionDefinition\n", "import com.openai.models.FunctionParameters\n", + "import com.openai.models.chat.completions.ChatCompletion\n", + "import com.openai.models.chat.completions.ChatCompletionFunctionTool\n", "import com.openai.models.chat.completions.ChatCompletionTool\n", "\n", "fun getWeather(location: String): Map = when {\n", @@ -388,26 +406,30 @@ " else -> mapOf(\"temp\" to 0, \"conditions\" to \"Unknown\")\n", "}\n", "\n", - "val functionDef = FunctionDefinition.builder()\n", - " .name(\"get_weather\")\n", - " .description(\"Get the weather conditions in a given location\")\n", - " .parameters(\n", - " FunctionParameters.builder()\n", - " .putAdditionalProperty(\"type\", JsonValue.from(\"object\"))\n", - " .putAdditionalProperty(\n", - " \"properties\", JsonValue.from(\n", - " mapOf(\n", - " \"location\" to JsonValue.from(\n", + "val functionDef = ChatCompletionFunctionTool.builder()\n", + " .function(\n", + " FunctionDefinition.builder()\n", + " .name(\"get_weather\")\n", + " .description(\"Get the weather conditions in a given location\")\n", + " .parameters(\n", + " FunctionParameters.builder()\n", + " .putAdditionalProperty(\"type\", JsonValue.from(\"object\"))\n", + " .putAdditionalProperty(\n", + " \"properties\", JsonValue.from(\n", " mapOf(\n", - " \"type\" to \"string\",\n", - " \"description\" to \"The city or location to get the weather for\"\n", + " \"location\" to JsonValue.from(\n", + " mapOf(\n", + " \"type\" to \"string\",\n", + " \"description\" to \"The city or location to get the weather for\"\n", + " )\n", + " )\n", " )\n", " )\n", " )\n", - " )\n", + " .putAdditionalProperty(\"required\", JsonValue.from(listOf(\"location\")))\n", + " .putAdditionalProperty(\"additionalProperties\", JsonValue.from(false))\n", + " .build()\n", " )\n", - " .putAdditionalProperty(\"required\", JsonValue.from(listOf(\"location\")))\n", - " .putAdditionalProperty(\"additionalProperties\", JsonValue.from(false))\n", " .build()\n", " )\n", " .build()\n", @@ -417,7 +439,7 @@ "val params = ChatCompletionCreateParams.builder()\n", " .model(ChatModel.GPT_4O_MINI)\n", " .addUserMessage(userQuery)\n", - " .addTool(ChatCompletionTool.builder().function(functionDef).build())\n", + " .addTool(ChatCompletionTool.ofFunction(functionDef))\n", "\n", "\n", "val response = client.chat().completions().create(params.build())\n", @@ -430,7 +452,7 @@ { "data": { "text/plain": [ - "Response: ChatCompletionMessage{content=null, refusal=null, role=assistant, annotations=[], audio=, functionCall=, toolCalls=[ChatCompletionMessageToolCall{id=call_6bOwpB4vx6VSpkonyxUPyeGW, function=Function{arguments={\"location\":\"Berlin\"}, name=get_weather, additionalProperties={}}, type=function, additionalProperties={}}], additionalProperties={}}" + "Response: ChatCompletionMessage{content=null, refusal=null, role=assistant, annotations=[], audio=, functionCall=, toolCalls=[ChatCompletionMessageToolCall{function=ChatCompletionMessageFunctionToolCall{id=call_JaYbTlvgfeOU0EHNdTJBRG4F, function=Function{arguments={\"location\":\"Berlin\"}, name=get_weather, additionalProperties={}}, type=function, additionalProperties={}}}], additionalProperties={}}" ] }, "execution_count": 7, @@ -443,8 +465,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-26T14:49:50.630659Z", - "start_time": "2025-05-26T14:49:49.112604Z" + "end_time": "2025-11-30T14:52:05.832848Z", + "start_time": "2025-11-30T14:52:04.803804Z" } }, "cell_type": "code", @@ -454,7 +476,7 @@ "import kotlin.jvm.optionals.getOrNull\n", "\n", "if (aiMessage.toolCalls().getOrNull()?.isNotEmpty() ?: false) {\n", - " val functionCall = aiMessage.toolCalls().get().first()\n", + " val functionCall = aiMessage.toolCalls().get().first().asFunction()\n", " val functionName = functionCall.function().name()\n", " val functionArgs = jsonMapper().readValue(functionCall.function().arguments(), Map::class.java)\n", "\n", @@ -490,7 +512,7 @@ "The model wants to call a function: get_weather\n", "With arguments: {location=Berlin}\n", "Final answer:\n", - "The current weather in Berlin is 13°C and cloudy.\n" + "The weather in Berlin is currently 13°C and cloudy.\n" ] } ], diff --git a/notebooks/spring-ai/SpringAI_Overview.ipynb b/notebooks/spring-ai/SpringAI_Overview.ipynb index aaa5ba1..e9db7c2 100644 --- a/notebooks/spring-ai/SpringAI_Overview.ipynb +++ b/notebooks/spring-ai/SpringAI_Overview.ipynb @@ -16,15 +16,14 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:51:46.453940Z", - "start_time": "2025-05-11T18:51:45.261870Z" + "end_time": "2025-12-01T15:29:43.911579Z", + "start_time": "2025-12-01T15:29:42.968234Z" } }, "cell_type": "code", "source": [ "%useLatestDescriptors\n", - "%use spring-ai-openai\n", - "USE { dependencies { implementation(\"com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2\") } }" + "%use spring-ai-openai" ], "outputs": [], "execution_count": 1 @@ -37,8 +36,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:51:46.513875Z", - "start_time": "2025-05-11T18:51:46.461778Z" + "end_time": "2025-12-01T15:29:43.981004Z", + "start_time": "2025-12-01T15:29:43.912419Z" } }, "cell_type": "code", @@ -54,8 +53,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:51:46.774329Z", - "start_time": "2025-05-11T18:51:46.518004Z" + "end_time": "2025-12-01T15:29:44.299716Z", + "start_time": "2025-12-01T15:29:43.981859Z" } }, "cell_type": "code", @@ -82,8 +81,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:51:47.820009Z", - "start_time": "2025-05-11T18:51:46.791193Z" + "end_time": "2025-12-01T15:29:45.912851Z", + "start_time": "2025-12-01T15:29:44.300267Z" } }, "cell_type": "code", @@ -92,9 +91,9 @@ { "data": { "text/plain": [ - "In code's embrace, \n", - "Kotlin whispers, smooth and clear— \n", - "Nature meets the tech." + "Code flows like water, \n", + "Kotlin's elegance unfolds— \n", + "Breezy, smooth, and clear. " ] }, "execution_count": 4, @@ -112,8 +111,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:51:47.874900Z", - "start_time": "2025-05-11T18:51:47.823943Z" + "end_time": "2025-12-01T15:29:45.983195Z", + "start_time": "2025-12-01T15:29:45.922192Z" } }, "cell_type": "code", @@ -137,8 +136,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:51:51.046247Z", - "start_time": "2025-05-11T18:51:47.878935Z" + "end_time": "2025-12-01T15:29:51.043586Z", + "start_time": "2025-12-01T15:29:45.983909Z" } }, "cell_type": "code", @@ -153,13 +152,11 @@ { "data": { "text/plain": [ - "Ah, dear traveler, the road ahead is ever uncertain, much like the paths through the Shire or the shadowed trails of Mirkwood. What awaits you may be shaped by the choices you make, for in Middle-earth, destiny often intertwines with the will of the Free Peoples.\n", + "In the winding paths of fate, much like the journey of Frodo and Sam, what awaits you is often shrouded in uncertainty, veiled like the shadow of Mordor. Yet, take heed: within the unknown lies opportunity and growth. \n", "\n", - "Take heed of the wisdom of Gandalf, who reminds us that \"All we have to decide is what to do with the time that is given us.\" Embrace courage in the face of adversity, for even the smallest person can change the course of the future, as Frodo Baggins so bravely did.\n", + "Consider the wisdom of Elrond, who spoke of choices and the weight they carry. Your actions, like Bilbo's decision to leave the Shire, can lead to adventures unforeseen. Embrace the journey ahead with the courage of Aragorn and the heart of Samwise; for even in darkness, there is always a glimmer of hope.\n", "\n", - "Seek fellowship in your journey, for the bonds of friendship and loyalty are as vital as the strongest steel. And remember, even in the darkest of times, the light of hope can shine through, much like the Evenstar guiding those lost in shadow.\n", - "\n", - "Prepare thyself, for every adventure holds both peril and wonder. Trust in your heart, and let the tales of old inspire you as you forge your own path." + "Remember, the road goes ever on and on, and it is not the destination that defines you, but the steps you take along the way. Seek the light, and you shall find your path." ] }, "execution_count": 6, @@ -191,16 +188,16 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:51:51.135360Z", - "start_time": "2025-05-11T18:51:51.053181Z" + "end_time": "2025-12-01T15:29:51.765272Z", + "start_time": "2025-12-01T15:29:51.044617Z" } }, "cell_type": "code", "source": [ "%useLatestDescriptors\n", "%use coroutines\n", - "@file:DependsOn(\"org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.10.1\")\n", - "@file:DependsOn(\"org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.10.1\")" + "@file:DependsOn(\"org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.10.2\")\n", + "@file:DependsOn(\"org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.10.2\")" ], "outputs": [], "execution_count": 7 @@ -213,8 +210,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:51:52.236596Z", - "start_time": "2025-05-11T18:51:51.138698Z" + "end_time": "2025-12-01T15:29:52.894533Z", + "start_time": "2025-12-01T15:29:51.766330Z" } }, "cell_type": "code", @@ -236,9 +233,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "In code's gentle flow, \n", - "Kotlin whispers, clean and bright— \n", - "Breezes of pure joy." + "Kotlin whispers soft, \n", + "Code flows like a gentle stream, \n", + "Nature meets the code. " ] } ], @@ -263,17 +260,20 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:51:52.300410Z", - "start_time": "2025-05-11T18:51:52.240029Z" + "end_time": "2025-12-01T15:29:52.979698Z", + "start_time": "2025-12-01T15:29:52.906266Z" } }, "cell_type": "code", "source": [ - "data class Movie(\n", - " val title: String,\n", - " val year: Int,\n", - " val director: String,\n", - " val genre: String\n", + "import com.fasterxml.jackson.annotation.JsonCreator\n", + "import com.fasterxml.jackson.annotation.JsonProperty\n", + "\n", + "data class Movie @JsonCreator constructor(\n", + " @JsonProperty(\"title\") val title: String,\n", + " @JsonProperty(\"year\") val year: Int,\n", + " @JsonProperty(\"director\") val director: String,\n", + " @JsonProperty(\"genre\") val genre: String\n", ")" ], "outputs": [], @@ -287,8 +287,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:51:52.337347Z", - "start_time": "2025-05-11T18:51:52.302905Z" + "end_time": "2025-12-01T15:29:53.025656Z", + "start_time": "2025-12-01T15:29:52.980486Z" } }, "cell_type": "code", @@ -310,8 +310,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:51:53.419457Z", - "start_time": "2025-05-11T18:51:52.342096Z" + "end_time": "2025-12-01T15:29:54.364822Z", + "start_time": "2025-12-01T15:29:53.026498Z" } }, "cell_type": "code", @@ -326,7 +326,7 @@ { "data": { "text/plain": [ - "Movie(title=Driving Miss Daisy, year=1989, director=Driving Miss Daisy, genre=Drama)" + "Movie(title=Dances with Wolves, year=1990, director=Kevin Costner, genre=Western)" ] }, "execution_count": 11, @@ -358,8 +358,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:51:54.397916Z", - "start_time": "2025-05-11T18:51:53.425168Z" + "end_time": "2025-12-01T15:29:55.348033Z", + "start_time": "2025-12-01T15:29:54.366601Z" } }, "cell_type": "code", @@ -386,8 +386,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:51:54.475702Z", - "start_time": "2025-05-11T18:51:54.402514Z" + "end_time": "2025-12-01T15:29:55.465591Z", + "start_time": "2025-12-01T15:29:55.368520Z" } }, "cell_type": "code", @@ -410,8 +410,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:52:11.082672Z", - "start_time": "2025-05-11T18:52:11.044812Z" + "end_time": "2025-12-01T15:29:55.521936Z", + "start_time": "2025-12-01T15:29:55.466431Z" } }, "cell_type": "code", @@ -442,7 +442,7 @@ ")" ], "outputs": [], - "execution_count": 15 + "execution_count": 14 }, { "metadata": {}, @@ -452,8 +452,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:53:21.055393Z", - "start_time": "2025-05-11T18:53:21.007170Z" + "end_time": "2025-12-01T15:29:55.577463Z", + "start_time": "2025-12-01T15:29:55.522655Z" } }, "cell_type": "code", @@ -472,7 +472,7 @@ ")" ], "outputs": [], - "execution_count": 17 + "execution_count": 15 }, { "metadata": {}, @@ -482,8 +482,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:53:23.993702Z", - "start_time": "2025-05-11T18:53:22.992199Z" + "end_time": "2025-12-01T15:29:56.429315Z", + "start_time": "2025-12-01T15:29:55.578255Z" } }, "cell_type": "code", @@ -496,15 +496,15 @@ { "data": { "text/plain": [ - "ChatCompletionMessage[rawContent=null, role=ASSISTANT, name=null, toolCallId=null, toolCalls=[ToolCall[index=null, id=call_j7bF9U678spoE9ZFgLydbS7Y, type=function, function=ChatCompletionFunction[name=getCurrentWeather, arguments={\"location\":\"Paris, France\"}]]], refusal=null, audioOutput=null]" + "ChatCompletionMessage[rawContent=null, role=ASSISTANT, name=null, toolCallId=null, toolCalls=[ToolCall[index=null, id=call_ThwxemPYeaDhrNSgApiYWa0Q, type=function, function=ChatCompletionFunction[name=getCurrentWeather, arguments={\"location\":\"Paris, France\"}]]], refusal=null, audioOutput=null, annotations=[], reasoningContent=null]" ] }, - "execution_count": 18, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], - "execution_count": 18 + "execution_count": 16 }, { "metadata": {}, @@ -523,8 +523,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:53:26.592539Z", - "start_time": "2025-05-11T18:53:26.518174Z" + "end_time": "2025-12-01T15:29:56.528538Z", + "start_time": "2025-12-01T15:29:56.442588Z" } }, "cell_type": "code", @@ -538,14 +538,14 @@ " messageWithToolInvocation = ChatCompletionMessage(\n", " if (temperature != null) \"$temperature C\" else \"Unable to get the weather\",\n", " ChatCompletionMessage.Role.TOOL,\n", - " functionName, toolCall.id(), null, null, null\n", + " functionName, toolCall.id(), null, null, null, null, null\n", " )\n", " }\n", " }\n", "}" ], "outputs": [], - "execution_count": 19 + "execution_count": 17 }, { "metadata": {}, @@ -555,8 +555,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:53:29.327398Z", - "start_time": "2025-05-11T18:53:28.690337Z" + "end_time": "2025-12-01T15:29:57.646007Z", + "start_time": "2025-12-01T15:29:56.529274Z" } }, "cell_type": "code", @@ -570,15 +570,15 @@ { "data": { "text/plain": [ - "The current temperature in Paris, France is 15°C." + "I'm unable to provide real-time weather updates. You might want to check a reliable weather website or app for the current weather in Paris." ] }, - "execution_count": 20, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], - "execution_count": 20 + "execution_count": 18 }, { "metadata": {}, diff --git a/notebooks/spring-ai/tutorials/1. Intro.ipynb b/notebooks/spring-ai/tutorials/1. Intro.ipynb index d7f61b3..02366b5 100644 --- a/notebooks/spring-ai/tutorials/1. Intro.ipynb +++ b/notebooks/spring-ai/tutorials/1. Intro.ipynb @@ -32,8 +32,14 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:20:23.962206Z", - "start_time": "2025-05-11T18:20:22.945188Z" + "end_time": "2025-12-01T13:54:29.569264Z", + "start_time": "2025-12-01T13:54:28.861181Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_3_jupyter", + "Line_4_jupyter" + ] } }, "cell_type": "code", @@ -78,8 +84,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:20:27.159256Z", - "start_time": "2025-05-11T18:20:27.097816Z" + "end_time": "2025-12-01T13:54:29.649698Z", + "start_time": "2025-12-01T13:54:29.571727Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_5_jupyter" + ] } }, "cell_type": "code", @@ -101,8 +112,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:20:31.997792Z", - "start_time": "2025-05-11T18:20:31.830652Z" + "end_time": "2025-12-01T13:54:29.973968Z", + "start_time": "2025-12-01T13:54:29.651203Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_6_jupyter" + ] } }, "cell_type": "code", @@ -121,8 +137,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:20:40.695755Z", - "start_time": "2025-05-11T18:20:38.591611Z" + "end_time": "2025-12-01T13:54:33.043024Z", + "start_time": "2025-12-01T13:54:29.975696Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_7_jupyter" + ] } }, "cell_type": "code", @@ -135,7 +156,7 @@ "\n", "anthropicApi.chatCompletionEntity(\n", " AnthropicApi.ChatCompletionRequest(\n", - " AnthropicApi.ChatModel.CLAUDE_3_5_SONNET.value,\n", + " AnthropicApi.ChatModel.CLAUDE_SONNET_4_0.value,\n", " listOf(anthropicMessage), null, 100, 0.8, false\n", " )\n", ")\n", @@ -147,10 +168,9 @@ { "data": { "text/plain": [ - "<200 OK OK,ChatCompletionResponse[id=msg_01GdysrRajqyi32z5T8T6jvA, type=message, role=ASSISTANT, content=[ContentBlock[type=TEXT, source=null, text=Here's a classic one:\n", + "<200 OK OK,ChatCompletionResponse[id=msg_01PByqU55f2W72YbZ5WgcZLA, type=message, role=ASSISTANT, content=[ContentBlock[type=TEXT, source=null, text=Why don't scientists trust atoms?\n", "\n", - "Why don't scientists trust atoms?\n", - "Because they make up everything! 😄, index=null, id=null, name=null, input=null, toolUseId=null, content=null, signature=null, thinking=null, data=null]], model=claude-3-5-sonnet-20241022, stopReason=end_turn, stopSequence=null, usage=Usage[inputTokens=11, outputTokens=27]],[:status:\"200\", anthropic-organization-id:\"ea22ac71-22a7-43cc-9c6a-0a6a2c25768f\", anthropic-ratelimit-input-tokens-limit:\"200000\", anthropic-ratelimit-input-tokens-remaining:\"200000\", anthropic-ratelimit-input-tokens-reset:\"2025-05-11T18:20:40Z\", anthropic-ratelimit-output-tokens-limit:\"50000\", anthropic-ratelimit-output-tokens-remaining:\"50000\", anthropic-ratelimit-output-tokens-reset:\"2025-05-11T18:20:40Z\", anthropic-ratelimit-requests-limit:\"500\", anthropic-ratelimit-requests-remaining:\"499\", anthropic-ratelimit-requests-reset:\"2025-05-11T18:20:39Z\", anthropic-ratelimit-tokens-limit:\"250000\", anthropic-ratelimit-tokens-remaining:\"250000\", anthropic-ratelimit-tokens-reset:\"2025-05-11T18:20:40Z\", cf-cache-status:\"DYNAMIC\", cf-ray:\"93e3b1067beee521-TXL\", content-length:\"398\", content-type:\"application/json\", date:\"Sun, 11 May 2025 18:20:40 GMT\", request-id:\"req_011CP2CtyLNnZYZHkPv8YteM\", server:\"cloudflare\", strict-transport-security:\"max-age=31536000; includeSubDomains; preload\", via:\"1.1 google\", x-robots-tag:\"none\"]>" + "Because they make up everything!, index=null, id=null, name=null, input=null, toolUseId=null, content=null, signature=null, thinking=null, data=null, cacheControl=null, title=null, context=null, citations=null]], model=claude-sonnet-4-20250514, stopReason=end_turn, stopSequence=null, usage=Usage[inputTokens=11, outputTokens=17, cacheCreationInputTokens=0, cacheReadInputTokens=0]],[:status:\"200\", anthropic-organization-id:\"ea22ac71-22a7-43cc-9c6a-0a6a2c25768f\", anthropic-ratelimit-input-tokens-limit:\"16500000\", anthropic-ratelimit-input-tokens-remaining:\"16500000\", anthropic-ratelimit-input-tokens-reset:\"2025-12-01T13:54:31Z\", anthropic-ratelimit-output-tokens-limit:\"4250000\", anthropic-ratelimit-output-tokens-remaining:\"4250000\", anthropic-ratelimit-output-tokens-reset:\"2025-12-01T13:54:32Z\", anthropic-ratelimit-tokens-limit:\"20750000\", anthropic-ratelimit-tokens-remaining:\"20750000\", anthropic-ratelimit-tokens-reset:\"2025-12-01T13:54:31Z\", cf-cache-status:\"DYNAMIC\", cf-ray:\"9a7313aafac74f3e-TXL\", content-length:\"473\", content-type:\"application/json\", date:\"Mon, 01 Dec 2025 13:54:33 GMT\", request-id:\"req_011CVg5cfE9hAHNeSPPc3xUi\", retry-after:\"29\", server:\"cloudflare\", strict-transport-security:\"max-age=31536000; includeSubDomains; preload\", x-envoy-upstream-service-time:\"2647\", x-robots-tag:\"none\"]>" ] }, "execution_count": 4, @@ -176,14 +196,19 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:20:45.234463Z", - "start_time": "2025-05-11T18:20:45.197442Z" + "end_time": "2025-12-01T13:54:33.080994Z", + "start_time": "2025-12-01T13:54:33.043942Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_8_jupyter" + ] } }, "cell_type": "code", "source": [ "val anthropicOptions = AnthropicChatOptions.builder()\n", - " .model(AnthropicApi.ChatModel.CLAUDE_3_5_SONNET)\n", + " .model(AnthropicApi.ChatModel.CLAUDE_SONNET_4_0)\n", " .temperature(0.7)\n", " .maxTokens(1024)\n", " .build()\n", @@ -203,8 +228,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:20:49.519186Z", - "start_time": "2025-05-11T18:20:49.489689Z" + "end_time": "2025-12-01T13:54:33.117211Z", + "start_time": "2025-12-01T13:54:33.081698Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_9_jupyter" + ] } }, "cell_type": "code", @@ -229,8 +259,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:20:54.205087Z", - "start_time": "2025-05-11T18:20:51.059281Z" + "end_time": "2025-12-01T13:54:37.212823Z", + "start_time": "2025-12-01T13:54:33.117776Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_10_jupyter" + ] } }, "cell_type": "code", @@ -242,15 +277,13 @@ { "data": { "text/plain": [ - "Here's a Kotlin joke:\n", + "Here's a Kotlin joke for you:\n", "\n", - "Why do Kotlin developers never get lost?\n", + "Why did the Java developer switch to Kotlin?\n", "\n", - "Because they always have a Nullable compass! (?.compass)\n", + "Because they were tired of writing `NullPointerException` love letters to their code! 💕\n", "\n", - "*ba dum tss* 😄\n", - "\n", - "It's a play on Kotlin's safe call operator (?.) which helps prevent null pointer exceptions. Not the most hilarious joke, but it's type-safe! 😉" + "(In Kotlin, null safety is built into the type system, so you're much less likely to encounter those pesky NPEs that Java developers know all too well!)" ] }, "execution_count": 7, @@ -276,8 +309,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:20:58.913641Z", - "start_time": "2025-05-11T18:20:55.958951Z" + "end_time": "2025-12-01T13:54:41.063011Z", + "start_time": "2025-12-01T13:54:37.227811Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_11_jupyter" + ] } }, "cell_type": "code", @@ -289,15 +327,11 @@ { "data": { "text/plain": [ - "Here's a Kotlin joke:\n", - "\n", - "Why do Kotlin developers never get lost?\n", - "\n", - "Because they always have a Nullable compass! (They can check if it's null before following its direction) 😄\n", + "Why did the Java developer switch to Kotlin?\n", "\n", - "*ba dum tss* \n", + "Because they were tired of writing `public static void main(String[] args)` when they could just write `fun main()` and actually have fun! \n", "\n", - "I know, it's a bit corny, but hey, it's safe to use! 😉" + "🎯 *Bonus punchline: They also got tired of null pointer exceptions ruining their day!*" ] }, "execution_count": 8, diff --git a/notebooks/spring-ai/tutorials/2. Prompts.ipynb b/notebooks/spring-ai/tutorials/2. Prompts.ipynb index bd5af9d..26f10a9 100644 --- a/notebooks/spring-ai/tutorials/2. Prompts.ipynb +++ b/notebooks/spring-ai/tutorials/2. Prompts.ipynb @@ -22,8 +22,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:21:22.364837Z", - "start_time": "2025-05-11T18:21:21.380834Z" + "end_time": "2025-12-01T13:54:40.934482Z", + "start_time": "2025-12-01T13:54:40.550089Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_3_jupyter" + ] } }, "cell_type": "code", @@ -67,8 +72,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:21:22.953678Z", - "start_time": "2025-05-11T18:21:22.890736Z" + "end_time": "2025-12-01T13:54:41.034134Z", + "start_time": "2025-12-01T13:54:40.935104Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_4_jupyter" + ] } }, "cell_type": "code", @@ -84,15 +94,20 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:21:30.039092Z", - "start_time": "2025-05-11T18:21:29.787175Z" + "end_time": "2025-12-01T13:54:41.397726Z", + "start_time": "2025-12-01T13:54:41.036771Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_5_jupyter" + ] } }, "cell_type": "code", "source": [ "val anthropicApi = AnthropicApi.builder().apiKey(apiKey).build()\n", "val anthropicOptions = AnthropicChatOptions.builder()\n", - " .model(AnthropicApi.ChatModel.CLAUDE_3_5_SONNET)\n", + " .model(AnthropicApi.ChatModel.CLAUDE_SONNET_4_0)\n", " .temperature(0.7)\n", " .maxTokens(1024)\n", " .build()\n", @@ -119,8 +134,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:21:33.985242Z", - "start_time": "2025-05-11T18:21:32.039136Z" + "end_time": "2025-12-01T13:54:44.500664Z", + "start_time": "2025-12-01T13:54:41.398582Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_6_jupyter" + ] } }, "cell_type": "code", @@ -129,11 +149,11 @@ { "data": { "text/plain": [ - "Here's a hokku (also known as haiku):\n", + "Here's a hokku for you:\n", "\n", - "autumn leaves falling\n", - "a lone crow takes to the sky\n", - "shadows dance below" + "Morning frost melts—\n", + "a single drop catches light\n", + "on the bamboo leaf" ] }, "execution_count": 4, @@ -151,8 +171,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:21:38.721627Z", - "start_time": "2025-05-11T18:21:36.629388Z" + "end_time": "2025-12-01T13:54:47.433035Z", + "start_time": "2025-12-01T13:54:44.501300Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_7_jupyter" + ] } }, "cell_type": "code", @@ -166,11 +191,11 @@ { "data": { "text/plain": [ - "Here's a hokku (also known as haiku):\n", + "Here's a hokku for you:\n", "\n", - "autumn leaves falling\n", - "a crow takes sudden flight while\n", - "shadows cross the moon" + "Morning dew clings tight—\n", + "even the spider's silk holds\n", + "autumn's first farewell" ] }, "execution_count": 5, @@ -207,8 +232,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:21:46.602579Z", - "start_time": "2025-05-11T18:21:42.491516Z" + "end_time": "2025-12-01T13:54:53.035472Z", + "start_time": "2025-12-01T13:54:47.433836Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_8_jupyter" + ] } }, "cell_type": "code", @@ -220,15 +250,13 @@ { "data": { "text/plain": [ - "Here's a hokku (also known as haiku):\n", + "Here's a hokku I've created:\n", "\n", - "Morning dew sparkles\n", - "On spider's silken threads while\n", - "Autumn leaves flutter\n", + "**Morning dew glistens**\n", + "**on the spider's silver web—**\n", + "**autumn light breaking**\n", "\n", - "We could call this hokku \"Autumn Morning\" as it captures a moment in nature during the autumn season, featuring morning dew and falling leaves.\n", - "\n", - "Note: Traditional hokku follows a 5-7-5 syllable pattern and typically includes a seasonal reference (kigo) and a cutting word (kireji). This example maintains the syllable pattern and includes autumn as the seasonal reference." + "Regarding the name: Traditional hokku (and haiku) typically don't have titles. They are meant to stand alone as complete, self-contained moments of observation. The poem itself is simply called a \"hokku\" - that's both the form and the identifier. If you needed to reference this particular one, you might refer to it by its first line: \"Morning dew glistens.\"" ] }, "execution_count": 6, @@ -253,8 +281,12 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:21:50.437289Z", - "start_time": "2025-05-11T18:21:46.665265Z" + "start_time": "2025-12-01T13:54:53.036058Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_9_jupyter" + ] } }, "cell_type": "code", @@ -270,7 +302,15 @@ { "data": { "text/plain": [ - "Yes, absolutely. Bitcoin was worth less than $1 in early 2011 and reached nearly $69,000 at its peak in 2021. Even with price fluctuations, buying and holding Bitcoin from 2011 would have yielded extraordinary returns on investment." + "Yes, absolutely. Bitcoin was trading for around $1-$30 in 2011 and peaked near $69,000 in 2021 - that's roughly a 2,000-69,000x return depending on when in 2011 you bought.\n", + "\n", + "However, keep in mind:\n", + "- You'd need diamond hands to hold through multiple 80%+ crashes\n", + "- Early exchanges were risky (Mt. Gox collapsed in 2014)\n", + "- You'd need secure storage methods that didn't exist yet\n", + "- The regulatory landscape was completely unknown\n", + "\n", + "But yes, even buying a small amount and holding would have been life-changing wealth creation." ] }, "execution_count": 7, @@ -281,12 +321,7 @@ "execution_count": 7 }, { - "metadata": { - "ExecuteTime": { - "end_time": "2025-05-11T18:21:53.518636Z", - "start_time": "2025-05-11T18:21:50.496638Z" - } - }, + "metadata": {}, "cell_type": "code", "source": [ "val messages = listOf(\n", @@ -296,19 +331,8 @@ "\n", "chatClient.prompt(Prompt(messages)).call().content()" ], - "outputs": [ - { - "data": { - "text/plain": [ - "Yes, absolutely. Bitcoin was worth less than $1 in early 2011 and reached nearly $69,000 at its peak in 2021. Even with price fluctuations, buying and holding Bitcoin from 2011 would have yielded astronomical returns." - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "execution_count": 8 + "outputs": [], + "execution_count": null }, { "metadata": {}, @@ -326,12 +350,7 @@ ] }, { - "metadata": { - "ExecuteTime": { - "end_time": "2025-05-11T18:21:55.723548Z", - "start_time": "2025-05-11T18:21:53.579486Z" - } - }, + "metadata": {}, "cell_type": "code", "source": [ "val messages = mutableListOf(\n", @@ -341,27 +360,11 @@ "val assistantMessage = chatClient.prompt(Prompt(messages.toList())).call().chatResponse()!!.result.output\n", "assistantMessage" ], - "outputs": [ - { - "data": { - "text/plain": [ - "AssistantMessage [messageType=ASSISTANT, toolCalls=[], textContent=Paris has Eiffel Tower, Notre-Dame, and Louvre Museum., metadata={messageType=ASSISTANT}]" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "execution_count": 9 + "outputs": [], + "execution_count": null }, { - "metadata": { - "ExecuteTime": { - "end_time": "2025-05-11T18:21:58.143681Z", - "start_time": "2025-05-11T18:21:56.728470Z" - } - }, + "metadata": {}, "cell_type": "code", "source": [ "messages.add(assistantMessage)\n", @@ -369,19 +372,8 @@ "\n", "chatClient.prompt(Prompt(messages.toList())).call().content()" ], - "outputs": [ - { - "data": { - "text/plain": [ - "Louvre Museum displays famous art, including Mona Lisa." - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "execution_count": 10 + "outputs": [], + "execution_count": null }, { "metadata": {}, @@ -414,12 +406,7 @@ ] }, { - "metadata": { - "ExecuteTime": { - "end_time": "2025-05-11T18:22:07.414730Z", - "start_time": "2025-05-11T18:22:02.446668Z" - } - }, + "metadata": {}, "cell_type": "code", "source": [ "fun capital(): PromptTemplate {\n", @@ -430,22 +417,8 @@ "val prompt = capital().create(mapOf(\"country\" to \"France\"))\n", "chatClient.prompt(prompt).call().content()" ], - "outputs": [ - { - "data": { - "text/plain": [ - "The two largest cities in France are:\n", - "\n", - "1. Paris (population approximately 2.2 million in the city proper, over 12 million in the metropolitan area)\n", - "2. Marseille (population approximately 870,000 in the city proper, over 1.7 million in the metropolitan area)" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "execution_count": 11 + "outputs": [], + "execution_count": null }, { "metadata": {}, @@ -478,12 +451,7 @@ ] }, { - "metadata": { - "ExecuteTime": { - "end_time": "2025-05-11T18:22:09.902454Z", - "start_time": "2025-05-11T18:22:07.421985Z" - } - }, + "metadata": {}, "cell_type": "code", "source": [ "chatClient\n", @@ -495,21 +463,8 @@ " .call()\n", " .content()" ], - "outputs": [ - { - "data": { - "text/plain": [ - "neutral\n", - "\n", - "The text \"In my opinion, this restaurant is quite ordinary\" expresses a neutral sentiment. The word \"ordinary\" suggests neither particularly good nor bad qualities, just average or standard, making this a neutral statement." - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "execution_count": 12 + "outputs": [], + "execution_count": null }, { "metadata": {}, @@ -522,12 +477,7 @@ ] }, { - "metadata": { - "ExecuteTime": { - "end_time": "2025-05-11T18:22:12.805651Z", - "start_time": "2025-05-11T18:22:09.908237Z" - } - }, + "metadata": {}, "cell_type": "code", "source": [ "chatClient\n", @@ -540,23 +490,8 @@ " .call()\n", " .content()" ], - "outputs": [ - { - "data": { - "text/plain": [ - "Here's an example sentence using \"fyrkotat\":\n", - "\n", - "The excited puppy fyrkotat on the carpet when it saw its owner coming home with treats.\n", - "\n", - "(Note: I understand both \"zumbrik\" and \"fyrkotat\" are made-up words being used for this exercise, and I've created a sentence that demonstrates the given meaning of \"fyrkotat\" - to quickly rotate in one place.)" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "execution_count": 13 + "outputs": [], + "execution_count": null }, { "metadata": {}, @@ -580,12 +515,7 @@ ] }, { - "metadata": { - "ExecuteTime": { - "end_time": "2025-05-11T18:22:16.321916Z", - "start_time": "2025-05-11T18:22:12.867612Z" - } - }, + "metadata": {}, "cell_type": "code", "source": [ "chatClient\n", @@ -596,34 +526,8 @@ " .call()\n", " .content()" ], - "outputs": [ - { - "data": { - "text/plain": [ - "Let me solve this step by step.\n", - "\n", - "1) First, let's identify the odd numbers in the group:\n", - " * 15 is odd\n", - " * 3 is odd\n", - " * 7 is odd\n", - "\n", - "2) Now, let's add these odd numbers:\n", - " * 15 + 3 + 7 = 25\n", - "\n", - "3) Is 25 an even number?\n", - " * No, 25 is odd\n", - "\n", - "Therefore, the sum of the odd numbers in this group is not an even number.\n", - "\n", - "The answer is no." - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], - "execution_count": 14 + "outputs": [], + "execution_count": null }, { "metadata": {}, @@ -637,12 +541,7 @@ ] }, { - "metadata": { - "ExecuteTime": { - "end_time": "2025-05-11T18:22:22.796191Z", - "start_time": "2025-05-11T18:22:17.559101Z" - } - }, + "metadata": {}, "cell_type": "code", "source": [ "chatClient\n", @@ -658,45 +557,8 @@ " .call()\n", " .content()" ], - "outputs": [ - { - "data": { - "text/plain": [ - "Let me solve this step by step.\n", - "\n", - "1. Define variables:\n", - " * Let x = initial number of apples\n", - " * 15 apples were sold first\n", - " * 1/3 of remaining apples were sold second\n", - " * 20 apples remained at the end\n", - "\n", - "2. Construct equation:\n", - " * After selling 15 apples: (x - 15) apples remained\n", - " * After selling 1/3 of remaining: (x - 15) - (1/3)(x - 15) = 20\n", - " * Simplify: (x - 15)(1 - 1/3) = 20\n", - " * Simplify: (x - 15)(2/3) = 20\n", - "\n", - "3. Solve equation:\n", - " * (x - 15)(2/3) = 20\n", - " * x - 15 = 20 × (3/2)\n", - " * x - 15 = 30\n", - " * x = 45\n", - "\n", - "4. Verify solution:\n", - " * Initial apples: 45\n", - " * After selling 15: 45 - 15 = 30\n", - " * After selling 1/3 of 30: 30 - (1/3 × 30) = 30 - 10 = 20\n", - " * Final amount matches given: 20 apples\n", - "\n", - "Therefore, there were 45 apples initially." - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], - "execution_count": 15 + "outputs": [], + "execution_count": null }, { "metadata": {}, @@ -718,12 +580,7 @@ ] }, { - "metadata": { - "ExecuteTime": { - "end_time": "2025-05-11T18:22:29.433580Z", - "start_time": "2025-05-11T18:22:22.804037Z" - } - }, + "metadata": {}, "cell_type": "code", "source": [ "val knowledge = chatClient\n", @@ -736,58 +593,11 @@ "\n", "knowledge" ], - "outputs": [ - { - "data": { - "text/plain": [ - "Here's what you should know about lichens and their relationship with trees:\n", - "\n", - "Key Facts:\n", - "1. Lichens are generally harmless to trees\n", - "- They are not parasitic\n", - "- Don't extract nutrients from trees\n", - "- Don't damage bark or wood\n", - "- Serve as indicators of good air quality\n", - "\n", - "2. Benefits of lichens:\n", - "- Provide habitat for small insects\n", - "- Some birds use them for nesting material\n", - "- Can help with nitrogen fixation\n", - "- Part of healthy forest ecosystems\n", - "\n", - "3. Common misconceptions:\n", - "- People often mistake lichens for tree diseases\n", - "- Presence of lichens doesn't indicate tree decline\n", - "- Lichens grow more visibly on slower-growing trees\n", - "\n", - "4. When to be concerned:\n", - "- Heavy lichen growth might indicate:\n", - " * Slow tree growth\n", - " * Poor tree vigor\n", - " * Need for improved growing conditions\n", - "- But lichens themselves aren't causing these issues\n", - "\n", - "5. Lichen growth patterns:\n", - "- More common on older trees\n", - "- Thrive in moist environments\n", - "- Often grow on north-facing sides\n", - "- Can appear on both healthy and unhealthy trees" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "execution_count": 16 + "outputs": [], + "execution_count": null }, { - "metadata": { - "ExecuteTime": { - "end_time": "2025-05-11T18:22:32.029227Z", - "start_time": "2025-05-11T18:22:29.441884Z" - } - }, + "metadata": {}, "cell_type": "code", "source": [ "chatClient\n", @@ -799,19 +609,8 @@ " .call()\n", " .content()" ], - "outputs": [ - { - "data": { - "text/plain": [ - "No, lichens are not harmful to trees. They are non-parasitic organisms that simply use trees as a surface to grow on, without extracting nutrients or damaging the bark or wood. While heavy lichen growth might indicate a slow-growing tree, the lichens themselves aren't causing any problems - they're actually a sign of good air quality and are part of a healthy forest ecosystem." - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "execution_count": 17 + "outputs": [], + "execution_count": null }, { "metadata": {}, @@ -830,12 +629,7 @@ ] }, { - "metadata": { - "ExecuteTime": { - "end_time": "2025-05-11T18:22:33.589423Z", - "start_time": "2025-05-11T18:22:32.033803Z" - } - }, + "metadata": {}, "cell_type": "code", "source": [ "val ctryCap = chatClient\n", @@ -849,15 +643,10 @@ " .content()" ], "outputs": [], - "execution_count": 18 + "execution_count": null }, { - "metadata": { - "ExecuteTime": { - "end_time": "2025-05-11T18:22:39.750970Z", - "start_time": "2025-05-11T18:22:33.598514Z" - } - }, + "metadata": {}, "cell_type": "code", "source": [ "chatClient\n", @@ -869,39 +658,8 @@ " .call()\n", " .content()" ], - "outputs": [ - { - "data": { - "text/plain": [ - "Here's a guide to three fascinating sights in each capital city:\n", - "\n", - "PARIS, FRANCE:\n", - "1. Eiffel Tower - The iconic 324-meter iron lattice tower offering spectacular city views from three observation levels\n", - "2. Louvre Museum - Home to thousands of artworks including the Mona Lisa, housed in a historic palace\n", - "3. Notre-Dame Cathedral - Magnificent Gothic cathedral (currently under restoration) known for its architecture and gargoyles\n", - "\n", - "BERLIN, GERMANY:\n", - "1. Brandenburg Gate - 18th-century neoclassical monument symbolizing German unity and peace\n", - "2. East Side Gallery - The longest remaining section of the Berlin Wall, covered in historic murals\n", - "3. Museum Island - UNESCO World Heritage site hosting five world-renowned museums\n", - "\n", - "ROME, ITALY:\n", - "1. Colosseum - Ancient amphitheater showcasing Roman engineering and gladiatorial history\n", - "2. Vatican Museums & Sistine Chapel - Home to masterpieces including Michelangelo's famous ceiling frescoes\n", - "3. Trevi Fountain - Baroque fountain known for its stunning sculptures and coin-tossing tradition\n", - "\n", - "MADRID, SPAIN:\n", - "1. Prado Museum - One of the world's finest art museums, featuring European masterpieces\n", - "2. Royal Palace - Europe's largest royal palace by floor area, with stunning architecture and royal collections\n", - "3. Plaza Mayor - Historic central square surrounded by traditional architecture and outdoor cafes" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "execution_count": 19 + "outputs": [], + "execution_count": null }, { "metadata": {}, diff --git a/notebooks/spring-ai/tutorials/3. Streaming.ipynb b/notebooks/spring-ai/tutorials/3. Streaming.ipynb index 0851f41..96a6b8e 100644 --- a/notebooks/spring-ai/tutorials/3. Streaming.ipynb +++ b/notebooks/spring-ai/tutorials/3. Streaming.ipynb @@ -23,8 +23,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:23:53.996189Z", - "start_time": "2025-05-11T18:23:51.890277Z" + "end_time": "2025-12-01T14:25:27.762051Z", + "start_time": "2025-12-01T14:25:26.846515Z" } }, "cell_type": "code", @@ -32,7 +32,7 @@ "%useLatestDescriptors\n", "%use coroutines\n", "%use spring-ai-openai\n", - "USE { dependencies { implementation(\"org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.10.1\") } }" + "USE { dependencies { implementation(\"org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.10.2\") } }" ], "outputs": [], "execution_count": 1 @@ -72,8 +72,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:23:54.052104Z", - "start_time": "2025-05-11T18:23:54.000397Z" + "end_time": "2025-12-01T14:25:27.829189Z", + "start_time": "2025-12-01T14:25:27.762778Z" } }, "cell_type": "code", @@ -89,8 +89,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:24:00.818242Z", - "start_time": "2025-05-11T18:24:00.565416Z" + "end_time": "2025-12-01T14:25:28.192138Z", + "start_time": "2025-12-01T14:25:27.831352Z" } }, "cell_type": "code", @@ -117,8 +117,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:24:13.965769Z", - "start_time": "2025-05-11T18:24:04.804151Z" + "end_time": "2025-12-01T14:25:34.743914Z", + "start_time": "2025-12-01T14:25:28.193746Z" } }, "cell_type": "code", @@ -136,11 +136,11 @@ "name": "stdout", "output_type": "stream", "text": [ - "Once upon a time in a lush, green meadow, there lived a brave little rabbit named Benny who dreamed of exploring the world beyond the tall, golden grass. One sunny morning, Benny discovered a sparkling, hidden path lined with colorful wildflowers that led deep into the Enchanted Forest. As he hopped along the path, he met a wise old tortoise named Tilly, who warned him of a mischievous fox lurking nearby, always on the lookout for a tasty rabbit snack. Undeterred, Benny continued on his adventure, determined to find the legendary Rainbow Carrot said to grant any wish to the one who found it. \n", + "Once upon a time in a lush, green forest, there lived a clever rabbit named Benny who dreamed of becoming the fastest runner in all the land. Benny challenged the boastful tortoise, Timmy, to a race, confident that his speed would secure him victory. As the race began, Benny sprinted ahead, leaving Timmy far behind, and decided to take a nap under a shady tree. Meanwhile, Timmy kept plodding along, steady and determined, never once stopping to rest. \n", "\n", - "Along the way, Benny befriended a group of playful squirrels who shared their acorn stash and joined him on his quest, forming a bond of friendship that made them stronger together. They danced and sang as they ventured deeper into the forest, unaware of the sly fox watching them from behind a tree. Suddenly, the fox sprang out, but quick-thinking Benny devised a clever plan, leading the fox on a wild chase through the twisting trees and over bubbling brooks. With the help of his new friends, Benny created a diversion that allowed them to escape safely, leaving the frustrated fox behind. \n", + "When Benny awoke, he panicked and dashed towards the finish line, but it was too late; Timmy had crossed it triumphantly, proving that perseverance beats arrogance. The animals of the forest celebrated Timmy's victory with a grand feast, inviting Benny to join and learn from his mistake. Realizing the importance of humility, Benny promised to train harder and respect his fellow creatures' strengths. From that day on, he and Timmy became the best of friends, often racing together but always encouraging one another. \n", "\n", - "Finally, after a long day of adventures, Benny and his friends reached the glimmering pond where the fabled Rainbow Carrot was said to grow. As the sun set, casting a golden glow over the water, Benny spotted the vibrant carrot emerging from the earth, and with a heart full of hope, he made his wish for peace and happiness for all the creatures of the meadow. From that day on, the meadow flourished, and Benny, the brave little rabbit, became a beloved hero, reminding everyone that true courage comes from friendship and kindness." + "As the seasons changed, Benny shared his newfound wisdom with other rabbits, teaching them that true greatness lies not just in speed, but in heart and friendship. And so, in that enchanted forest, the rabbits thrived, united by the lessons of a tortoise who taught them that slow and steady truly wins the race." ] } ], @@ -160,8 +160,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:24:20.616521Z", - "start_time": "2025-05-11T18:24:13.970221Z" + "end_time": "2025-12-01T14:25:42.305431Z", + "start_time": "2025-12-01T14:25:34.746001Z" } }, "cell_type": "code", @@ -183,13 +183,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "Once upon a time in a lush, green meadow, there lived a clever rabbit named Ruby, who had the softest fur and the brightest eyes. Every morning, she would hop through the dew-kissed grass, gathering golden dandelions to share with her friends. One day, while exploring a hidden glade, Ruby stumbled upon a shimmering pond that sparkled like diamonds under the sun. \n", + "Once upon a time in a lush, green meadow, there lived a clever rabbit named Ruby who dreamed of discovering the hidden treasures of the Enchanted Forest. One sunny morning, Ruby decided to gather her friends — Benny the brave bunny, and Lily the wise old tortoise — to embark on an adventure. As they hopped along the winding path, they stumbled upon a sparkling stream filled with shimmering fish that danced like stars in the water. \n", "\n", - "Curious and enchanted, she approached the water and discovered a wise old turtle named Timothy, who told her tales of a magical forest where dreams came true. Eager to find this wondrous place, Ruby gathered her friends—a brave rabbit named Benny and a gentle rabbit called Lily—and together they set off on an adventure. \n", + "Suddenly, a mischievous fox appeared, claiming to know the secret to finding the treasure, but only if Ruby could solve his riddle. With her quick wit, Ruby answered the riddle, impressing the fox, who reluctantly decided to guide them deeper into the forest. The trio encountered magical creatures along the way, including a singing bird with feathers of gold and a gentle deer who offered them guidance. \n", "\n", - "As they traveled, they encountered a mischievous fox who tried to trick them, but Ruby outsmarted him with her quick thinking and clever riddles. After a long journey filled with laughter and challenges, they finally reached the enchanted forest, where the trees whispered secrets and flowers sang sweet melodies. \n", + "After crossing a bridge made of rainbows, they finally reached a hidden glade where an ancient oak tree stood, its trunk wrapped in vines and glowing with an otherworldly light. Beneath the tree, they discovered a chest filled with sparkling gemstones and enchanted carrots that could grant wishes. Ruby, Benny, and Lily decided to share their newfound treasure with all the animals of the meadow, ensuring that everyone could enjoy the magic. \n", "\n", - "In the heart of the forest, they found a glowing flower that granted wishes, and each rabbit made a wish from the bottom of their hearts. Ruby wished for happiness for all her friends, Benny wished for courage to protect them, and Lily wished for endless adventures together. With their wishes granted, the three rabbits returned to their meadow, knowing that their friendship was the greatest magic of all. And from that day on, they lived happily ever after, sharing stories of their adventures under the stars." + "From that day on, the meadow thrived with happiness and friendship, reminding all who lived there that true treasure lies in the bonds we create and the adventures we share. And so, Ruby and her friends continued to explore, their hearts forever filled with the spirit of adventure and the joy of togetherness." ] } ], diff --git a/notebooks/spring-ai/tutorials/5. Structured Outputs.ipynb b/notebooks/spring-ai/tutorials/5. Structured Outputs.ipynb index d1d23db..9fe9c8d 100644 --- a/notebooks/spring-ai/tutorials/5. Structured Outputs.ipynb +++ b/notebooks/spring-ai/tutorials/5. Structured Outputs.ipynb @@ -24,15 +24,22 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:29:15.544329Z", - "start_time": "2025-05-11T18:29:14.296612Z" + "end_time": "2025-12-01T15:09:09.196982Z", + "start_time": "2025-12-01T15:09:08.172094Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_3_jupyter", + "Line_4_jupyter", + "Line_5_jupyter" + ] } }, "cell_type": "code", "source": [ "%useLatestDescriptors\n", "%use spring-ai-openai\n", - "USE { dependencies { implementation(\"com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2\") } }" + "USE { dependencies { implementation(\"com.fasterxml.jackson.module:jackson-module-kotlin:2.20.1\") } }" ], "outputs": [], "execution_count": 1 @@ -40,8 +47,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:29:15.841Z", - "start_time": "2025-05-11T18:29:15.548584Z" + "end_time": "2025-12-01T15:09:09.569425Z", + "start_time": "2025-12-01T15:09:09.198832Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_6_jupyter" + ] } }, "cell_type": "code", @@ -72,8 +84,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:29:16.842779Z", - "start_time": "2025-05-11T18:29:15.844680Z" + "end_time": "2025-12-01T15:09:10.914494Z", + "start_time": "2025-12-01T15:09:09.570001Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_7_jupyter" + ] } }, "cell_type": "code", @@ -118,8 +135,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:29:17.109261Z", - "start_time": "2025-05-11T18:29:16.847749Z" + "end_time": "2025-12-01T15:09:11.172636Z", + "start_time": "2025-12-01T15:09:10.921959Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_8_jupyter" + ] } }, "cell_type": "code", @@ -162,17 +184,25 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:29:17.156954Z", - "start_time": "2025-05-11T18:29:17.112941Z" + "end_time": "2025-12-01T15:09:11.272221Z", + "start_time": "2025-12-01T15:09:11.174025Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_9_jupyter" + ] } }, "cell_type": "code", "source": [ - "data class MobileDevice(\n", - " val name: String,\n", - " val price: Double,\n", - " val category: String,\n", - " val features: List = emptyList()\n", + "import com.fasterxml.jackson.annotation.JsonCreator\n", + "import com.fasterxml.jackson.annotation.JsonProperty\n", + "\n", + "data class MobileDevice @JsonCreator constructor(\n", + " @JsonProperty(\"name\") val name: String,\n", + " @JsonProperty(\"price\") val price: Double,\n", + " @JsonProperty(\"category\") val category: String,\n", + " @JsonProperty(\"features\") val features: List = emptyList()\n", ")" ], "outputs": [], @@ -186,8 +216,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:29:19.217213Z", - "start_time": "2025-05-11T18:29:17.169662Z" + "end_time": "2025-12-01T15:09:14.193709Z", + "start_time": "2025-12-01T15:09:11.272839Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_10_jupyter" + ] } }, "cell_type": "code", @@ -203,7 +238,7 @@ { "data": { "text/plain": [ - "MobileDevice(name=XYZ Pro Max 12, price=1099.99, category=smartphone, features=[5G connectivity, 108 MP camera, 120Hz refresh rate display, Fast charging, Water and dust resistance])" + "MobileDevice(name=SuperPhone XZ, price=999.99, category=smartphone, features=[6.7-inch AMOLED display, 128GB internal storage, 12GB RAM, Triple rear camera setup, 5G connectivity, 4000mAh battery, Wireless charging, IP68 water and dust resistance])" ] }, "execution_count": 6, @@ -212,6 +247,18 @@ } ], "execution_count": 6 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2025-12-01T15:09:14.198727Z", + "start_time": "2025-12-01T15:09:14.194477Z" + } + }, + "cell_type": "code", + "source": "", + "outputs": [], + "execution_count": 7 } ], "metadata": { diff --git a/notebooks/spring-ai/tutorials/6. Advisors.ipynb b/notebooks/spring-ai/tutorials/6. Advisors.ipynb index af8c0c8..9f8a99d 100644 --- a/notebooks/spring-ai/tutorials/6. Advisors.ipynb +++ b/notebooks/spring-ai/tutorials/6. Advisors.ipynb @@ -21,9 +21,14 @@ }, { "metadata": { + "executionRelatedData": { + "compiledClasses": [ + "Line_3_jupyter" + ] + }, "ExecuteTime": { - "end_time": "2025-05-11T18:36:14.795200Z", - "start_time": "2025-05-11T18:36:13.823923Z" + "end_time": "2025-12-01T15:11:12.221472Z", + "start_time": "2025-12-01T15:11:11.130541Z" } }, "cell_type": "code", @@ -37,8 +42,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:36:15.083140Z", - "start_time": "2025-05-11T18:36:14.798769Z" + "end_time": "2025-12-01T15:11:12.584541Z", + "start_time": "2025-12-01T15:11:12.222821Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_4_jupyter" + ] } }, "cell_type": "code", @@ -74,8 +84,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:36:15.173726Z", - "start_time": "2025-05-11T18:36:15.087172Z" + "end_time": "2025-12-01T15:14:21.414663Z", + "start_time": "2025-12-01T15:14:21.357593Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_6_jupyter" + ] } }, "cell_type": "code", @@ -84,11 +99,11 @@ "\n", "val chatClient = ChatClient\n", " .builder(chatModel)\n", - " .defaultAdvisors(MessageChatMemoryAdvisor(chatMemory))\n", + " .defaultAdvisors(MessageChatMemoryAdvisor.builder(chatMemory).build())\n", " .build()\n" ], "outputs": [], - "execution_count": 3 + "execution_count": 4 }, { "metadata": {}, @@ -98,8 +113,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:36:16.342903Z", - "start_time": "2025-05-11T18:36:15.177608Z" + "end_time": "2025-12-01T15:14:23.656335Z", + "start_time": "2025-12-01T15:14:22.578172Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_7_jupyter" + ] } }, "cell_type": "code", @@ -108,23 +128,28 @@ { "data": { "text/plain": [ - "Sure! Why did the scarecrow win an award? \n", + "Why did the scarecrow win an award? \n", "\n", "Because he was outstanding in his field!" ] }, - "execution_count": 4, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], - "execution_count": 4 + "execution_count": 5 }, { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:36:17.286268Z", - "start_time": "2025-05-11T18:36:16.347106Z" + "end_time": "2025-12-01T15:14:25.286378Z", + "start_time": "2025-12-01T15:14:23.656836Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_8_jupyter" + ] } }, "cell_type": "code", @@ -136,12 +161,12 @@ "The previous message in our chat history was a joke: \"Why did the scarecrow win an award? Because he was outstanding in his field!\"" ] }, - "execution_count": 5, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], - "execution_count": 5 + "execution_count": 6 }, { "metadata": {}, @@ -168,35 +193,37 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:36:17.442802Z", - "start_time": "2025-05-11T18:36:17.291557Z" + "end_time": "2025-12-01T15:17:46.724533Z", + "start_time": "2025-12-01T15:17:46.639673Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_10_jupyter" + ] } }, "cell_type": "code", "source": [ - "import org.springframework.ai.chat.client.advisor.api.AdvisedRequest\n", - "import org.springframework.ai.chat.client.advisor.api.AdvisedResponse\n", - "import org.springframework.ai.chat.client.advisor.api.CallAroundAdvisor\n", - "import org.springframework.ai.chat.client.advisor.api.CallAroundAdvisorChain\n", - "\n", + "import org.springframework.ai.chat.client.advisor.api.CallAdvisor\n", + "import org.springframework.ai.chat.client.advisor.api.CallAdvisorChain\n", "\n", - "class CustomLogger: CallAroundAdvisor {\n", + "class CustomLogger: CallAdvisor {\n", " override fun getName(): String {\n", " return \"CustomLogger\"\n", " }\n", "\n", " override fun getOrder(): Int = 0\n", "\n", - " override fun aroundCall(advisedRequest: AdvisedRequest, chain: CallAroundAdvisorChain): AdvisedResponse {\n", - " println(\"CustomLogger.Before: ${advisedRequest}\")\n", - " val advisedResponse = chain.nextAroundCall(advisedRequest)\n", - " println(\"CustomLogger.After: ${advisedResponse}\")\n", - " return advisedResponse\n", + " override fun adviseCall(chatClientRequest: ChatClientRequest, callAdvisorChain: CallAdvisorChain): ChatClientResponse {\n", + " println(\"CustomLogger.Before: ${chatClientRequest}\")\n", + " val chatClientResponse = callAdvisorChain.nextCall(chatClientRequest)\n", + " println(\"CustomLogger.After: ${chatClientResponse}\")\n", + " return chatClientResponse\n", " }\n", "}" ], "outputs": [], - "execution_count": 6 + "execution_count": 8 }, { "metadata": {}, @@ -206,8 +233,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:36:19.319693Z", - "start_time": "2025-05-11T18:36:17.448459Z" + "end_time": "2025-12-01T15:17:51.740272Z", + "start_time": "2025-12-01T15:17:48.695125Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_11_jupyter" + ] } }, "cell_type": "code", @@ -223,10 +255,10 @@ "name": "stdout", "output_type": "stream", "text": [ - "CustomLogger.Before: AdvisedRequest[chatModel=OpenAiChatModel [defaultOptions=OpenAiChatOptions: {\"streamUsage\":false,\"model\":\"gpt-4o-mini\",\"temperature\":0.7}], userText=Generate HelloWorld in Kotlin, systemText=null, chatOptions=OpenAiChatOptions: {\"streamUsage\":false,\"model\":\"gpt-4o-mini\",\"temperature\":0.7}, media=[], toolNames=[], toolCallbacks=[], messages=[UserMessage{content='Hi, tell me a joke', properties={messageType=USER}, messageType=USER}, AssistantMessage [messageType=ASSISTANT, toolCalls=[], textContent=Sure! Why did the scarecrow win an award? \n", + "CustomLogger.Before: ChatClientRequest[prompt=Prompt{messages=[UserMessage{content='Hi, tell me a joke', metadata={messageType=USER}, messageType=USER}, AssistantMessage [messageType=ASSISTANT, toolCalls=[], textContent=Why did the scarecrow win an award? \n", "\n", - "Because he was outstanding in his field!, metadata={finishReason=STOP, refusal=, index=0, role=ASSISTANT, id=chatcmpl-BW5p1J0I5H63bmJysjT4KnsGhVSTJ, messageType=ASSISTANT}], UserMessage{content='What is previous message in our chat history?', properties={messageType=USER}, messageType=USER}, AssistantMessage [messageType=ASSISTANT, toolCalls=[], textContent=The previous message in our chat history was a joke: \"Why did the scarecrow win an award? Because he was outstanding in his field!\", metadata={finishReason=STOP, refusal=, index=0, role=ASSISTANT, id=chatcmpl-BW5p2XtUfyKu7J2lDAj51WV7sKd1n, messageType=ASSISTANT}]], userParams={}, systemParams={}, advisors=[org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor@6f20c8da, Line_7_jupyter$CustomLogger@53b8129e, org.springframework.ai.chat.client.advisor.ChatModelCallAdvisor@33668eae, org.springframework.ai.chat.client.advisor.ChatModelStreamAdvisor@5830fd62], advisorParams={}, adviseContext={spring.ai.chat.client.advisors=[org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor@6f20c8da, Line_7_jupyter$CustomLogger@53b8129e, org.springframework.ai.chat.client.advisor.ChatModelCallAdvisor@33668eae, org.springframework.ai.chat.client.advisor.ChatModelStreamAdvisor@5830fd62], spring.ai.chat.client.model=OpenAiChatModel [defaultOptions=OpenAiChatOptions: {\"streamUsage\":false,\"model\":\"gpt-4o-mini\",\"temperature\":0.7}], spring.ai.chat.client.user.params={}, spring.ai.chat.client.system.params={}}, toolContext={}]\n", - "CustomLogger.After: AdvisedResponse[response=ChatResponse [metadata={ id: chatcmpl-BW5p3rRgS1T9vr91wDI0XoxscPSez, usage: DefaultUsage{promptTokens=92, completionTokens=78, totalTokens=170}, rateLimit: { @type: org.springframework.ai.openai.metadata.OpenAiRateLimit, requestsLimit: 30000, requestsRemaining: 29999, requestsReset: PT0.002S, tokensLimit: 150000000; tokensRemaining: 149999916; tokensReset: PT0S } }, generations=[Generation[assistantMessage=AssistantMessage [messageType=ASSISTANT, toolCalls=[], textContent=Certainly! Here’s a simple \"Hello, World!\" program written in Kotlin:\n", + "Because he was outstanding in his field!, metadata={role=ASSISTANT, messageType=ASSISTANT, finishReason=STOP, refusal=, annotations=[], index=0, id=chatcmpl-ChztWkrp1ETiltxmxtfPP4OvB1ZMf}], UserMessage{content='What is previous message in our chat history?', metadata={messageType=USER}, messageType=USER}, AssistantMessage [messageType=ASSISTANT, toolCalls=[], textContent=The previous message in our chat history was a joke: \"Why did the scarecrow win an award? Because he was outstanding in his field!\", metadata={role=ASSISTANT, messageType=ASSISTANT, finishReason=STOP, refusal=, annotations=[], index=0, id=chatcmpl-ChztXs2RCzayFqZlJQkNppJrLkOOE}], UserMessage{content='Generate HelloWorld in Kotlin', metadata={messageType=USER}, messageType=USER}], modelOptions=OpenAiChatOptions: {\"streamUsage\":false,\"model\":\"gpt-4o-mini\",\"temperature\":0.7}}, context={}]\n", + "CustomLogger.After: ChatClientResponse[chatResponse=ChatResponse [metadata={ id: chatcmpl-ChzwrBqARkcbawIpn0trhBxOxmmaR, usage: DefaultUsage{promptTokens=90, completionTokens=77, totalTokens=167}, rateLimit: { @type: org.springframework.ai.openai.metadata.OpenAiRateLimit, requestsLimit: 30000, requestsRemaining: 29999, requestsReset: PT0.002S, tokensLimit: 150000000; tokensRemaining: 149999917; tokensReset: PT0S } }, generations=[Generation[assistantMessage=AssistantMessage [messageType=ASSISTANT, toolCalls=[], textContent=Here’s a simple \"Hello, World!\" program in Kotlin:\n", "\n", "```kotlin\n", "fun main() {\n", @@ -234,13 +266,13 @@ "}\n", "```\n", "\n", - "To run this code, you can use an IDE like IntelliJ IDEA or an online Kotlin compiler. Just copy and paste this code into the editor, and it will print \"Hello, World!\" to the console., metadata={finishReason=STOP, refusal=, index=0, role=ASSISTANT, id=chatcmpl-BW5p3rRgS1T9vr91wDI0XoxscPSez, messageType=ASSISTANT}], chatGenerationMetadata=DefaultChatGenerationMetadata[finishReason='STOP', filters=0, metadata=0]]]], adviseContext={spring.ai.chat.client.model=OpenAiChatModel [defaultOptions=OpenAiChatOptions: {\"streamUsage\":false,\"model\":\"gpt-4o-mini\",\"temperature\":0.7}], spring.ai.chat.client.advisors=[org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor@6f20c8da, Line_7_jupyter$CustomLogger@53b8129e, org.springframework.ai.chat.client.advisor.ChatModelCallAdvisor@33668eae, org.springframework.ai.chat.client.advisor.ChatModelStreamAdvisor@5830fd62], spring.ai.chat.client.user.params={}, spring.ai.chat.client.system.params={}}]\n" + "You can run this code in any Kotlin environment, such as an IDE like IntelliJ IDEA or an online Kotlin compiler. Just copy and paste the code, and it will print \"Hello, World!\" to the console when executed., metadata={role=ASSISTANT, messageType=ASSISTANT, finishReason=STOP, refusal=, annotations=[], index=0, id=chatcmpl-ChzwrBqARkcbawIpn0trhBxOxmmaR}], chatGenerationMetadata=DefaultChatGenerationMetadata[finishReason='STOP', filters=0, metadata=0]]]], context={}]\n" ] }, { "data": { "text/plain": [ - "Certainly! Here’s a simple \"Hello, World!\" program written in Kotlin:\n", + "Here’s a simple \"Hello, World!\" program in Kotlin:\n", "\n", "```kotlin\n", "fun main() {\n", @@ -248,15 +280,15 @@ "}\n", "```\n", "\n", - "To run this code, you can use an IDE like IntelliJ IDEA or an online Kotlin compiler. Just copy and paste this code into the editor, and it will print \"Hello, World!\" to the console." + "You can run this code in any Kotlin environment, such as an IDE like IntelliJ IDEA or an online Kotlin compiler. Just copy and paste the code, and it will print \"Hello, World!\" to the console when executed." ] }, - "execution_count": 7, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], - "execution_count": 7 + "execution_count": 9 } ], "metadata": { diff --git a/notebooks/spring-ai/tutorials/7. RAG.ipynb b/notebooks/spring-ai/tutorials/7. RAG.ipynb index 619e306..0dab845 100644 --- a/notebooks/spring-ai/tutorials/7. RAG.ipynb +++ b/notebooks/spring-ai/tutorials/7. RAG.ipynb @@ -25,15 +25,15 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:41:13.950443Z", - "start_time": "2025-05-11T18:41:12.693148Z" + "end_time": "2025-12-01T15:19:14.569056Z", + "start_time": "2025-12-01T15:19:12.369170Z" } }, "cell_type": "code", "source": [ "%useLatestDescriptors\n", "%use spring-ai-openai\n", - "USE { dependencies { implementation(\"org.springframework.ai:spring-ai-advisors-vector-store:1.0.0-M8\") } }" + "USE { dependencies { implementation(\"org.springframework.ai:spring-ai-advisors-vector-store:1.1.0\") } }" ], "outputs": [], "execution_count": 1 @@ -41,8 +41,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:41:14.206746Z", - "start_time": "2025-05-11T18:41:13.962082Z" + "end_time": "2025-12-01T15:19:16.148725Z", + "start_time": "2025-12-01T15:19:15.830712Z" } }, "cell_type": "code", @@ -70,8 +70,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:41:15.511846Z", - "start_time": "2025-05-11T18:41:15.479384Z" + "end_time": "2025-12-01T15:19:17.435597Z", + "start_time": "2025-12-01T15:19:17.387313Z" } }, "cell_type": "code", @@ -92,8 +92,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:41:18.042772Z", - "start_time": "2025-05-11T18:41:17.952079Z" + "end_time": "2025-12-01T15:19:18.698189Z", + "start_time": "2025-12-01T15:19:18.599906Z" } }, "cell_type": "code", @@ -117,8 +117,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:41:22.574539Z", - "start_time": "2025-05-11T18:41:20.814250Z" + "end_time": "2025-12-01T15:19:21.012921Z", + "start_time": "2025-12-01T15:19:19.814717Z" } }, "cell_type": "code", @@ -150,8 +150,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:41:32.560363Z", - "start_time": "2025-05-11T18:41:30.160435Z" + "end_time": "2025-12-01T15:21:14.964547Z", + "start_time": "2025-12-01T15:21:12.521315Z" } }, "cell_type": "code", @@ -165,7 +165,7 @@ " .build()\n", ")\n", " .prompt()\n", - " .advisors(QuestionAnswerAdvisor(vectoreStore))\n", + " .advisors(QuestionAnswerAdvisor.builder(vectoreStore).build())\n", " .user(\"current version of Kotlin?\")\n", " .call()\n", " .content()" @@ -174,7 +174,7 @@ { "data": { "text/plain": [ - "The current version of Kotlin is 2.1.20, which was published on March 20, 2025. For more information, you can visit the [Kotlin GitHub page](https://github.com/jetbrains/kotlin)." + "The current version of Kotlin is 2.1.20, which was published on March 20, 2025. You can find more information about it on [GitHub](https://github.com/jetbrains/kotlin)." ] }, "execution_count": 7, diff --git a/notebooks/spring-ai/tutorials/8. text-to-image.ipynb b/notebooks/spring-ai/tutorials/8. text-to-image.ipynb index 5040679..21e0c8f 100644 --- a/notebooks/spring-ai/tutorials/8. text-to-image.ipynb +++ b/notebooks/spring-ai/tutorials/8. text-to-image.ipynb @@ -16,8 +16,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:42:01.713740Z", - "start_time": "2025-05-11T18:42:00.632714Z" + "end_time": "2025-12-01T15:21:41.731235Z", + "start_time": "2025-12-01T15:21:40.851914Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_3_jupyter" + ] } }, "cell_type": "code", @@ -39,8 +44,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:42:01.773428Z", - "start_time": "2025-05-11T18:42:01.717436Z" + "end_time": "2025-12-01T15:21:41.805005Z", + "start_time": "2025-12-01T15:21:41.732645Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_4_jupyter" + ] } }, "cell_type": "code", @@ -59,8 +69,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:42:22.484030Z", - "start_time": "2025-05-11T18:42:06.636258Z" + "end_time": "2025-12-01T15:22:04.161515Z", + "start_time": "2025-12-01T15:21:44.506877Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_5_jupyter" + ] } }, "cell_type": "code", @@ -93,7 +108,7 @@ { "data": { "text/plain": [ - "ImageResponse [imageResponseMetadata=org.springframework.ai.image.ImageResponseMetadata@7e98c5bf, imageGenerations=[ImageGeneration{imageGenerationMetadata=OpenAiImageGenerationMetadata{revisedPrompt='A panorama of a coastal city where the architectural influences of Art Nouveau meld seamlessly with a futuristic design aesthetic. Behold the organically flowing structures constructed from sustainable materials that wind their way through the cityscape. These buildings are adorned with lush hanging gardens that sit alongside large, spherical glass domes designed to collect solar energy. Each element is intricately detailed, showcasing the complexity and elegance of this eco-friendly, forward-thinking urban environment.'}, image=Image{url='https://oaidalleapiprodscus.blob.core.windows.net/private/org-HxH5fxIrm2uwDEas71UvsRSe/user-Yo8e5sjCwpugZAD0tF3ZqW7b/img-wM4PMF9rqB4kDnty7IMiCqwy.png?st=2025-05-11T17%3A42%3A22Z&se=2025-05-11T19%3A42%3A22Z&sp=r&sv=2024-08-04&sr=b&rscd=inline&rsct=image/png&skoid=8b33a531-2df9-46a3-bc02-d4b1430a422c&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2025-05-11T02%3A27%3A34Z&ske=2025-05-12T02%3A27%3A34Z&sks=b&skv=2024-08-04&sig=kdD7YchDL7FfDYRamd6OHiv10EJ1jESoCJlVMMB6FQg%3D', b64Json='null'}}]]" + "ImageResponse [imageResponseMetadata=org.springframework.ai.image.ImageResponseMetadata@5251525a, imageGenerations=[ImageGeneration{imageGenerationMetadata=OpenAiImageGenerationMetadata{revisedPrompt='Envision a coastal city that harmoniously merges Art Nouveau architectural elements with cutting-edge future designs. It's teeming with organically-shaped buildings constructed from environmentally-friendly materials. Lush, sprawling hanging gardens, greenery that cascades down the sides of structures, breathes life into the city. Solar-collecting glass domes glimmer across the skyline, demonstrating innovative energy solutions. This cityscape showcases a sustainable future that embraces the aesthetic beauty of historical artistic movements, detailed illustration.'}, image=Image{url='https://oaidalleapiprodscus.blob.core.windows.net/private/org-HxH5fxIrm2uwDEas71UvsRSe/user-Yo8e5sjCwpugZAD0tF3ZqW7b/img-5dcBajuphYl0UlA5wChboUaE.png?st=2025-12-01T14%3A22%3A03Z&se=2025-12-01T16%3A22%3A03Z&sp=r&sv=2024-08-04&sr=b&rscd=inline&rsct=image/png&skoid=f1dafa11-a0c2-4092-91d4-10981fbda051&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2025-12-01T14%3A05%3A19Z&ske=2025-12-02T14%3A05%3A19Z&sks=b&skv=2024-08-04&sig=e6m5hwtbV3nJFG21lCquhxOOS6eH4Lqwi2knaJIgNtI%3D', b64Json='null'}}]]" ] }, "execution_count": 3, @@ -117,8 +132,18 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:42:31.087576Z", - "start_time": "2025-05-11T18:42:22.487530Z" + "end_time": "2025-12-01T15:22:21.783778Z", + "start_time": "2025-12-01T15:22:04.162050Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_6_jupyter", + "Line_7_jupyter", + "Line_8_jupyter", + "Line_9_jupyter", + "Line_10_jupyter", + "Line_11_jupyter" + ] } }, "cell_type": "code", @@ -134,8 +159,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:42:33.080549Z", - "start_time": "2025-05-11T18:42:31.112608Z" + "end_time": "2025-12-01T15:22:23.910737Z", + "start_time": "2025-12-01T15:22:21.784315Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_12_jupyter" + ] } }, "cell_type": "code", @@ -159,7 +189,7 @@ { "data": { "text/html": [ - "" + "" ] }, "execution_count": 5, diff --git a/notebooks/spring-ai/tutorials/9. text-to-audio.ipynb b/notebooks/spring-ai/tutorials/9. text-to-audio.ipynb index 489a6ea..069e9ef 100644 --- a/notebooks/spring-ai/tutorials/9. text-to-audio.ipynb +++ b/notebooks/spring-ai/tutorials/9. text-to-audio.ipynb @@ -18,8 +18,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:44:02.579969Z", - "start_time": "2025-05-11T18:44:02.265922Z" + "end_time": "2025-12-01T15:23:25.336956Z", + "start_time": "2025-12-01T15:23:24.515886Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_3_jupyter" + ] } }, "cell_type": "code", @@ -28,7 +33,7 @@ "%use spring-ai-openai" ], "outputs": [], - "execution_count": 3 + "execution_count": 1 }, { "metadata": {}, @@ -38,14 +43,19 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:44:02.613255Z", - "start_time": "2025-05-11T18:44:02.586281Z" + "end_time": "2025-12-01T15:23:27.794641Z", + "start_time": "2025-12-01T15:23:27.717014Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_4_jupyter" + ] } }, "cell_type": "code", "source": "val apiKey = System.getenv(\"OPENAI_API_KEY\") ?: \"YOUR_OPENAI_API_KEY\"", "outputs": [], - "execution_count": 4 + "execution_count": 2 }, { "metadata": {}, @@ -59,8 +69,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:44:05.236129Z", - "start_time": "2025-05-11T18:44:02.620285Z" + "end_time": "2025-12-01T15:23:39.282343Z", + "start_time": "2025-12-01T15:23:33.478897Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_5_jupyter" + ] } }, "cell_type": "code", @@ -87,7 +102,7 @@ "val response = openAiAudioTranscriptionModel.call(transcriptionRequest)" ], "outputs": [], - "execution_count": 5 + "execution_count": 3 }, { "metadata": {}, @@ -97,8 +112,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:44:05.276345Z", - "start_time": "2025-05-11T18:44:05.240614Z" + "end_time": "2025-12-01T15:23:41.193833Z", + "start_time": "2025-12-01T15:23:41.159590Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_6_jupyter" + ] } }, "cell_type": "code", @@ -110,12 +130,12 @@ "The stale smell of old beer lingers. It takes heat to bring out the odor. A cold dip restores health and zest. A salt pickle tastes fine with ham. Tacos al pastor are my favorite. A zestful food is the hot cross bun.\n" ] }, - "execution_count": 6, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], - "execution_count": 6 + "execution_count": 4 }, { "metadata": {}, @@ -131,19 +151,26 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:44:15.991054Z", - "start_time": "2025-05-11T18:44:05.279527Z" + "end_time": "2025-12-01T15:24:54.638264Z", + "start_time": "2025-12-01T15:24:47.736802Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_8_jupyter" + ] } }, "cell_type": "code", "source": [ + "import org.springframework.ai.audio.tts.TextToSpeechPrompt\n", + "\n", "// Create our speech model\n", "val openAiAudioSpeechModel = OpenAiAudioSpeechModel(openAiAudioApi)\n", "\n", "// Configure speech options\n", "val speechOptions = OpenAiAudioSpeechOptions.builder()\n", " .voice(OpenAiAudioApi.SpeechRequest.Voice.ALLOY) // Choose the voice type\n", - " .speed(1.0f) // Normal speaking speed\n", + " .speed(1.0) // Normal speaking speed\n", " .responseFormat(OpenAiAudioApi.SpeechRequest.AudioResponseFormat.MP3) // Get MP3 format\n", " .model(OpenAiAudioApi.TtsModel.TTS_1.value) // Using TTS-1 model\n", " .build()\n", @@ -160,11 +187,11 @@ "\"\"\"\n", "\n", "// Create and execute our speech request\n", - "val speechRequest = SpeechPrompt(prompt, speechOptions)\n", + "val speechRequest = TextToSpeechPrompt(prompt, speechOptions)\n", "val response = openAiAudioSpeechModel.call(speechRequest)" ], "outputs": [], - "execution_count": 7 + "execution_count": 6 }, { "metadata": {}, @@ -174,8 +201,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:44:16.083596Z", - "start_time": "2025-05-11T18:44:15.995676Z" + "end_time": "2025-12-01T15:24:58.576690Z", + "start_time": "2025-12-01T15:24:58.453048Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_9_jupyter" + ] } }, "cell_type": "code", @@ -203,17 +235,17 @@ "text/html": [ "\n", " \n" ] }, - "execution_count": 8, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], - "execution_count": 8 + "execution_count": 7 }, { "metadata": {}, @@ -223,8 +255,13 @@ { "metadata": { "ExecuteTime": { - "end_time": "2025-05-11T18:44:16.154804Z", - "start_time": "2025-05-11T18:44:16.103487Z" + "end_time": "2025-12-01T15:25:00.722143Z", + "start_time": "2025-12-01T15:25:00.646137Z" + }, + "executionRelatedData": { + "compiledClasses": [ + "Line_10_jupyter" + ] } }, "cell_type": "code", @@ -245,7 +282,7 @@ ] } ], - "execution_count": 9 + "execution_count": 8 }, { "metadata": {}, diff --git a/notebooks/spring-ai/tutorials/data/black_holes.mp3 b/notebooks/spring-ai/tutorials/data/black_holes.mp3 index e4309fe..85da711 100644 Binary files a/notebooks/spring-ai/tutorials/data/black_holes.mp3 and b/notebooks/spring-ai/tutorials/data/black_holes.mp3 differ