diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index dc8a0f8f..7fa90307 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -30,5 +30,9 @@ jobs: uv sync - name: Run tests + env: + # WATSONX_APIKEY: ${{ secrets.WATSONX_APIKEY }} + # WATSONX_PROJECTID: ${{ secrets.WATSONX_PROJECTID }} + # WATSONX_URL: ${{ secrets.WATSONX_URL }} run: | uv run pytest diff --git a/pyproject.toml b/pyproject.toml index 57166186..97c67299 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,6 +64,9 @@ dev = [ "invoke>=2.2.0", "papermill>=2.6.0", "pytest-xdist>=3.8.0", + "nbconvert>=7.16.6", + "ipykernel>=6.30.1", + "pre-commit-uv>=4.1.5", ] docling = [ "langchain-docling >=0.2.0,<0.3.0" diff --git a/tasks.py b/tasks.py new file mode 100644 index 00000000..fffa0a65 --- /dev/null +++ b/tasks.py @@ -0,0 +1,187 @@ +# /// script +# requires-python = ">=3.12" +# dependencies = [ +# "invoke", +# "pdbpp", +# "hunter", +# "rich", +# ] +# /// + +""" +You can run this tasks with *any* of these options: + +1. uv run inv -l | --help | [command] +2. uv run tasks.py -l | --help | [command] + +""" +# pylint: disable=dangerous-default-value + +import contextlib +import tempfile +from io import StringIO +from pathlib import Path +from textwrap import dedent +from typing import Annotated, Any, Generator, List + +import rich +from invoke import Task, task +from invoke.collection import Collection +from invoke.context import Context +from rich import pretty +from rich.console import Console + +pretty.install() + +console = Console(stderr=True) + + +TOP_LEVEL: Annotated[Path, "The root directory of the repo"] = Path(__file__).parent + + +@task(default=True, autoprint=True) +def version( + ctx: Context, +): + """Shows package version (git based)""" + with ctx.cd(TOP_LEVEL): + return ctx.run( + "uvx --with uv-dynamic-versioning hatchling version", + hide=not ctx.config.run.echo, + ).stdout.strip() + + +@task() +def cfg(ctx: Context): + """Task configuration file.""" + for key in ctx.config: + rich.print(f"[bold]{key}[/bold]") + rich.print(dict(ctx.config[key])) + + +@task( + help={ + "target_": "Target format", + "output": "Output directory, by default is ./dist/", + }, + autoprint=True, +) +def build(ctx: Context, target_=[], output="./dist/"): + """Builds distributable package""" + args = "" + if target_: + target = " ".join(f"-t {t}" for t in target_) + args = f"{args} {target}" + if output: + args = f"{args} -d {output}" + + return ctx.run( + f"uvx --with uv-dynamic-versioning hatchling build {args}", + hide=not ctx.config.run.echo, + ).stderr.strip() + + +@task() +def clean(ctx: Context): + """Cleans dist""" + ctx.run(r"rm -rf ./dist/*.{tar.gz,whl}") + + +@contextlib.contextmanager +def temp_dir(ctx: Context, post_clean: bool = True) -> Generator["Path", Any, Any]: + """Creates a temporary directory and changes the context to that directory""" + tmp_dir = Path(tempfile.mkdtemp()) + with ctx.cd(tmp_dir): + yield tmp_dir + if post_clean: + with console.status( + "Cleaning temporary directory (keep it with --no-post-clean)" + ): + ctx.run(f"rm -rf {tmp_dir}") + + +NO_VENV = {"VIRTUAL_ENV": ""} + + +@task( + aliases=[ + "tpkg", + ] +) +def test_package_isolated( + ctx: Context, + post_clean: bool = True, + command_to_run: str = "ipython", + python: str = "3.12", +): + """ + Builds the package in a temporary directory, creates a new virtualenv and installs it + there. Then runs the command, by default IPython + """ + + with temp_dir(ctx, post_clean == post_clean) as tmpd: + with console.status("Building wheel"): + with ctx.cd(TOP_LEVEL): + wheel_location = build(ctx, target_=("wheel",), output=tmpd) + + with console.status("Creating virtualenv..."): + ctx.run(f"uv venv --python {python}", env=NO_VENV) + with console.status("Installing freshly backed wheel file"): + ctx.run(f"uv pip install {wheel_location}", env=NO_VENV) + ctx.run( + "uv run python", + in_stream=StringIO( + dedent( + r""" + from importlib.metadata import version + ver = version('agentics-py') + print(f"\n\nagentics-py version: {ver}\n\n", ) + """ + ) + ), + pty=False, + env=NO_VENV, + ) + ctx.run(f"uv run {command_to_run}", pty=True, env=NO_VENV) + + +@task(aliases=["tpypi"]) +def test_package_pypi( + ctx: Context, + package_: List[str] = [], + python: str = "3.12", + command_to_run: str = "ipython", + post_clean: bool = False, +) -> None: + """ + Creates a new virtualenv and installs the package PyPI version in it. + Then runs the command, by default IPython + """ + if not package_: + package_ = ["agentics-py"] + with temp_dir(ctx, post_clean=post_clean) as tmpd: + with console.status("Creating virtualenv..."): + ctx.run(f"uv venv --python {python}", env=NO_VENV) + packages = " ".join(package_) + with console.status(f"Installing {packages}"): + ctx.run(f"uv pip install {packages}", env=NO_VENV) + for pkg in package_: + console.print(f"[bold]{pkg}[/bold]") + ctx.run(f"uv pip show {pkg}", env=NO_VENV) + + ctx.run(f"uv run {command_to_run}", pty=True, env=NO_VENV) + + +# This is only required for configuration +ns: Collection = Collection() +local_tasks: List[Task] = [ + obj for name, obj in list(locals().items()) if isinstance(obj, Task) +] +for tsk in local_tasks: + ns.add_task(tsk) + +if __name__ == "__main__": + from invoke.program import Program + + p = Program(namespace=ns) + p.run() diff --git a/tests/conftest.py b/tests/conftest.py index 9c899e1f..975a6fb8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -46,7 +46,11 @@ def wheel( ) -> Annotated[Path, "The wheel file to install"]: with ctx.cd(git_root): output = tmp_path_factory.mktemp("dist") - ctx.run(f"uv build -o {output}", in_stream=False) + # uv build is not compatible with uv-dynamic-versioning + ctx.run( + f"uvx --with uv-dynamic-versioning hatchling build -d {output} -t wheel", + in_stream=False, + ) wheel_file, *_ = output.glob("*.whl") return wheel_file @@ -59,3 +63,8 @@ def llm_provider(): return get_llm_provider() except ValueError: raise pytest.skip(reason="No available LLM") + + +@pytest.fixture() +def jupyter_kernel(ctx): + ctx.run() diff --git a/tests/notebooks/tests.ipynb b/tests/notebooks/tests.ipynb new file mode 100644 index 00000000..8045634a --- /dev/null +++ b/tests/notebooks/tests.ipynb @@ -0,0 +1,469 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "0", + "metadata": {}, + "source": [ + "# Agentics Mini Tutorial\n", + "\n", + "Agentics provides the implementation of **AG**, a powerful datatype that connects\n", + "LLMs to Pydantic objects and enables **logical transduction**.\n", + "\n", + "---\n", + "\n", + "## Installation\n", + "\n", + "```bash\n", + "!uv pip install agentics-py" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1", + "metadata": {}, + "outputs": [], + "source": [ + "! uv pip install agentics-py\n", + "\n", + "! uv pip install agentics-py\n", + "\n", + "\n", + "import os\n", + "from pathlib import Path\n", + "import sys\n", + "from getpass import getpass\n", + "\n", + "from dotenv import find_dotenv, load_dotenv\n", + "\n", + "CURRENT_PATH = \"\"\n", + "\n", + "IN_COLAB = \"google.colab\" in sys.modules\n", + "print(\"In Colab:\", IN_COLAB)\n", + "\n", + "\n", + "if IN_COLAB:\n", + " CURRENT_PATH = \"/content/drive/MyDrive/\"\n", + " # Mount your google drive\n", + " from google.colab import drive\n", + " \n", + " drive.mount(\"/content/drive\")\n", + " from google.colab import userdata\n", + " \n", + " os.environ[\"GEMINI_API_KEY\"] = getpass(\"Enter your GEMINI_API_KEY:\")\n", + "else:\n", + "\n", + " CURRENT_PATH = os.getcwd()\n", + " load_dotenv(find_dotenv())\n", + "\n", + "if not os.getenv(\"GEMINI_API_KEY\"):\n", + " os.environ[\"GEMINI_API_KEY\"] = getpass(\"Enter your GEMINI_API_KEY:\")\n", + "\n", + "base = Path(CURRENT_PATH)" + ] + }, + { + "cell_type": "markdown", + "id": "2", + "metadata": {}, + "source": [ + "## Use Agentics as Lists\n", + "\n", + "Agentics objects (`AG`) can be used similarly to Python lists, allowing you to store and manage collections of states. You can append new elements using the `.append()` method, and access all states via the `.states` attribute.\n", + "\n", + "For example, after creating an empty `AG` object, you can add elements:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3", + "metadata": {}, + "outputs": [], + "source": [ + "from agentics import AG\n", + "my_first_agentics = AG()\n", + "\n", + "print(\"The agentics is empty :\", len(my_first_agentics))\n", + "\n", + " ## Add elements to the list\n", + "my_first_agentics.append(\"Alfio\")\n", + "## internally, agentics stores the elements in the attribute states\n", + "my_first_agentics.states += [\"Naweed\" , \"Junkyuu\"] \n", + "\n", + "print(\"The agentics now has more instances :\",len(my_first_agentics))\n", + "\n", + "try:\n", + " print(\"this triggers an error\")\n", + " my_first_agentics = my_first_agentics + my_first_agentics\n", + "except:\n", + " my_first_agentics.states= my_first_agentics.states + my_first_agentics.states\n", + " print(\"This is the right way to concetenate two agentics. Be careful, the states should be instances of the same atype\")\n", + " my_first_agentics.pretty_print()\n", + "\n", + "print(\"Iterating over agentics:\") \n", + "for state in my_first_agentics:\n", + " print(state)\n", + "\n", + "print(\"Be careful, the AG itself is not a list :\" , my_first_agentics) \n", + "\n" + ] + }, + { + "cell_type": "markdown", + "id": "4", + "metadata": {}, + "source": [ + "## Atypes\n", + "\n", + "Agentics supports **typed AGs** using Pydantic models, enabling you to enforce schema validation and structure on the states stored in an AG. This is useful when you want all elements in your AG to follow a specific format or contain certain fields.\n", + "\n", + "To define a typed AG:\n", + "\n", + "1. **Create a Pydantic model** that describes the schema for your states.\n", + "2. **Instantiate an AG** with the `atype` parameter set to your Pydantic model.\n", + "3. **Add instances** of your model to the AG. Only objects matching the schema will be accepted.\n", + "\n", + "This approach ensures data consistency and allows you to leverage Pydantic's validation features within Agentics workflows.\n", + "\n", + "For example, you can define a `Movie` type and create an AG that only accepts `Movie` instances as its states. See the next cell for a practical demonstration." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5", + "metadata": {}, + "outputs": [], + "source": [ + "from pydantic import BaseModel\n", + "from typing import Optional\n", + "\n", + "# Define the Movie Pydantic model for use with Agentics AG\n", + "class Movie(BaseModel):\n", + " movie_name: Optional[str] = None\n", + " genre: Optional[str] = None\n", + " description: Optional[str] = None\n", + "\n", + "\n", + "movies = AG(atype=Movie)\n", + "movies.append(Movie(movie_name=\"La dolce vita\"))\n", + "movies.pretty_print()" + ] + }, + { + "cell_type": "markdown", + "id": "6", + "metadata": {}, + "source": [ + "## Extending and Merging AGs\n", + "AGs can evolve by adding new fields or combining with other AGs to form richer schemas.\n", + "\n", + "### Add attributes\n", + "Use `.add_attribute()` to dynamically extend the schema of an AG. \n", + "This operation mutates the AG in place." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7", + "metadata": {}, + "outputs": [], + "source": [ + "movies = AG(atype=Movie)\n", + "movies.append(Movie(movie_name=\"La dolce vita\"))\n", + "movies.pretty_print()\n", + "\n", + "print(\"adding a new attribute to the type and rebinding the object\")\n", + "movies = movies.add_attribute(\"email\", \n", + " description=\"Write an email to tell a fried about this movie\",\n", + " slot_type=Optional[str])\n", + "\n", + "movies.pretty_print()\n", + "print(\"Note that the AG changed\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "8", + "metadata": {}, + "source": [ + "### Subtypes\n", + "You can project an AG onto a subset of its fields, e.g. `movies(\"title\", \"genre\")`. \n", + "This creates a new AG without modifying the original." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9", + "metadata": {}, + "outputs": [], + "source": [ + "movies_subtype = movies(\"movie_name\", \"genre\")\n", + "print(\"This is a subtype\")\n", + "movies_subtype.pretty_print()\n", + "\n", + "print(\"This is the original type.\\nNote that the AG didn't change after subtype\")\n", + "movies.pretty_print()\n", + "print(\"Note that the AG didn't change after subtyping it\")" + ] + }, + { + "cell_type": "markdown", + "id": "10", + "metadata": {}, + "source": [ + "### Merge AGs\n", + "You can merge AGs of different types (e.g., `Movie` with `Director`), combining their states into a new AG with a union of fields. \n", + "On field conflicts, values from the right-hand AG’s states take precedence." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "11", + "metadata": {}, + "outputs": [], + "source": [ + "# Define a new Pydantic type for directors\n", + "class Director(BaseModel):\n", + " director_name: Optional[str] = None\n", + "\n", + "# Merge movies (Movie type) with directors (Director type)\n", + "# The result AG will have fields from both Movie and Director\n", + "prod_movies = movies.merge(\n", + " AG(atype=Director, states=[Director(director_name=\"Fellini\")])\n", + ")\n", + "\n", + "# Add another movie to the original AG\n", + "movies.append(Movie(movie_name=\"Superman\"))\n", + "\n", + "print(\"Merging AGs will combine states:\")\n", + "\n", + "# Merge with one director state; the single director is aligned with each movie\n", + "movies.merge(\n", + " AG(atype=Director, states=[Director(director_name=\"Fellini\")])\n", + ").pretty_print()\n", + "\n", + "# Merge with two director states; directors are aligned by index with movies\n", + "# If the AGs are different lengths, extra states are still included\n", + "movies.merge(\n", + " AG(atype=Director, states=[\n", + " Director(director_name=\"Fellini\"),\n", + " Director(director_name=\"Donner\")\n", + " ])\n", + ").pretty_print()" + ] + }, + { + "cell_type": "markdown", + "id": "12", + "metadata": {}, + "source": [ + "## Logical Transduction\n", + "\n", + "Once an AG is initialized with an atype, Agentics can **transduce** any string of text and/or pydantic object into that type. If a list of strings is provided, they are processed asynchronously." + ] + }, + { + "cell_type": "markdown", + "id": "13", + "metadata": {}, + "source": [ + "## Untyped transduction\n", + "\n", + "If no target atype is provided, transduction works as a regular llm call, where the input text or pydantic object is given to the LLM and the output is the LLM response. In this use case, agentics provides an off the shelp **async scale-out framework for LLM calls**. \n", + "\n", + "Note that no AType is specified, the output of transduction is alist of strings. So it is not recommended to use this notation for transduction algebra. In addition, Unconstrained trnasduction tends to me less efficient as it requires the LLM to guess the type of output required, often resulting in verbose and unecessary information . " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "14", + "metadata": {}, + "outputs": [], + "source": [ + "import time\n", + "\n", + "questions = [\n", + " \"What are the benefits of using Agentic AI for data workflows?\",\n", + " \"Will AI improve working conditions for the middle class?\",\n", + " \"How can Agentic AI enhance decision-making in finance?\",\n", + " # \"What risks should companies consider when adopting AI agents?\",\n", + " # \"Can AG objects integrate with existing data pipelines?\",\n", + " # \"Who won the latest FIFA worldcup\",\n", + "]\n", + "start = time.time()\n", + "answers = await (AG() << questions)\n", + "end = time.time()\n", + "\n", + "for question, answer in zip(questions, answers):\n", + " print(f\"Question: {question}\\nAnswer{answer}\\n\")\n", + "print(f\"Uncostrained transduction done in {end-start} seconds\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "15", + "metadata": {}, + "source": [ + "### Transduction into Atype\n", + "\n", + "You can define a target schema with Pydantic (e.g., `Answer`) and transduce text into it. \n", + "The LLM output is parsed and validated into the fields `answer`, `justification`, and `confidence`. \n", + "Note that the output is more clean and organized, and the time required to execute the transduction is one order of magnitude lower. " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "16", + "metadata": {}, + "outputs": [], + "source": [ + "# Define a Pydantic model for a structured answer\n", + "class Answer(BaseModel):\n", + " # The main response text\n", + " answer: Optional[str] = None\n", + " # An explanation or reasoning behind the answer\n", + " justification: Optional[str] = None\n", + " # A numeric confidence score (e.g. from 0.0 to 1.0)\n", + " confidence: Optional[float] = None\n", + "\n", + "# Transduce a natural language question into the structured Answer schema\n", + "start= time.time()\n", + "answers = await (AG(atype=Answer) << questions)\n", + "end= time.time()\n", + "print(f\"Typed transduction done in {end-start} seconds\")\n", + "answers.pretty_print()" + ] + }, + { + "cell_type": "markdown", + "id": "17", + "metadata": {}, + "source": [ + "### Transduction Between AGs\n", + "\n", + "You can control transduction more precisely by converting **from one AG to another**:\n", + "- The **source AG** provides the input states (rendered via the prompt).\n", + "- The **target AG** defines the output schema and validation.\n", + "- Agentics renders each source state → sends it to the LLM → parses into the target type.\n", + "\n", + "This pattern is ideal when you want consistent, structured outputs from heterogeneous inputs while keeping prompts and schema separate." + ] + }, + { + "cell_type": "markdown", + "id": "18", + "metadata": {}, + "source": [ + "### Transduction Between AGs \n", + "Here we convert product reviews (`ProductReview`) into sentiment summaries (`SentimentSummary`). \n", + "The source AG provides the reviews, and the target AG enforces structured outputs (positive/neutral/negative with a reason). " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "19", + "metadata": {}, + "outputs": [], + "source": [ + "from typing import Optional, Literal\n", + "from pydantic import BaseModel\n", + "from agentics import AG\n", + "\n", + "# Source schema: product reviews\n", + "class ProductReview(BaseModel):\n", + " reviewer: Optional[str] = None\n", + " text: Optional[str] = None\n", + " stars: Optional[int] = None\n", + "\n", + "# Target schema: summarized sentiment\n", + "class SentimentSummary(BaseModel):\n", + " customer_sentiment: Optional[Literal[\"positive\", \"neutral\", \"negative\"]] = None\n", + " reason: Optional[str] = None\n", + "\n", + "# Example reviews\n", + "reviews = [\n", + " ProductReview(reviewer=\"Alice\", text=\"Excellent quality and fast delivery!\", stars=5),\n", + " ProductReview(reviewer=\"Bob\", text=\"Okay, but packaging was damaged\", stars=3),\n", + " ProductReview(reviewer=\"Carol\", text=\"Terrible, broke after one use\", stars=1),\n", + "]\n", + "\n", + "# Create source and target AGs\n", + "source = AG(atype=ProductReview, states=reviews)\n", + "target = AG(atype=SentimentSummary)\n", + "\n", + "# Transduce reviews into sentiment summaries\n", + "sentiments = await (target << source)\n", + "sentiments.pretty_print()" + ] + }, + { + "cell_type": "markdown", + "id": "20", + "metadata": {}, + "source": [ + "### Customizing Transduction \n", + "\n", + "You can fine-tune how logical transduction works by configuring: \n", + "\n", + "- **LLMs** – choose the underlying language model to run the transduction. \n", + "- **Instructions** – add task-specific guidance for the LLM. \n", + "- **Prompt Templates** – control how inputs are rendered into prompts. \n", + "- **Few-Shot Examples** – provide examples to steer the model’s behavior. \n", + "- **Verbose Options** – enable detailed logging and debug outputs. " + ] + }, + { + "cell_type": "markdown", + "id": "21", + "metadata": {}, + "source": [ + "#### Task instructions\n", + "The example below illustrate how to provide a llm and task specific instructions to transduction" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "22", + "metadata": {}, + "outputs": [], + "source": [ + "questions_answering_ag=AG(atype=Answer,\n", + " llm=AG.get_llm_provider(\"watsonx\"),\n", + " instructions= \"Answer in italian\")\n", + "\n", + "print((await (questions_answering_ag << questions)).pretty_print())\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/tests/test_tutorials.py b/tests/test_hello_world.py similarity index 64% rename from tests/test_tutorials.py rename to tests/test_hello_world.py index b8e9df7e..7c2e554a 100644 --- a/tests/test_tutorials.py +++ b/tests/test_hello_world.py @@ -1,33 +1,6 @@ -from pathlib import Path - -import papermill as pm import pytest -@pytest.mark.skip(reason="User input not mocked") -@pytest.mark.parametrize( - "notebook", - ( - "tutorials/llms.ipynb", - # "tutorials/transduction.ipynb", - # "tutorials/agentics_basics.ipynb", - # "tutorials/amap_reduce.ipynb", - # tutorials/mcp_tools.ipynb" - ), -) -def test_tutorials(git_root, tmp_path: Path, notebook): - input_notebook = Path(git_root) / notebook - - out_nb = tmp_path / "report_out.ipynb" - pm.execute_notebook( - input_notebook, - out_nb, - parameters={"RUN_MODE": "test", "LIMIT": 100}, - cwd=".", - kernel_name="python3", - ) - - @pytest.mark.asyncio async def test_hello_world(llm_provider): from typing import Optional diff --git a/tests/test_notebooks.py b/tests/test_notebooks.py new file mode 100644 index 00000000..502c78d2 --- /dev/null +++ b/tests/test_notebooks.py @@ -0,0 +1,34 @@ +import shlex +import subprocess +from pathlib import Path + +import nbformat +import pytest +from nbconvert.preprocessors import ExecutePreprocessor + +repo: Path = Path( + subprocess.check_output(shlex.split("git rev-parse --show-toplevel")) + .decode() + .strip() +) + +TEST_NOTEBOOKS = list(repo.glob("tests/**/*.ipynb")) +NOTEOBOOKS_FOR_TESTING = {p.name: p for p in TEST_NOTEBOOKS} + +TIMEOUT = 600 + + +@pytest.mark.parametrize( + "notebook", + NOTEOBOOKS_FOR_TESTING.values(), + ids=NOTEOBOOKS_FOR_TESTING.keys(), +) +def test_notebook_execution(notebook: Path, monkeypatch: pytest.MonkeyPatch): + """Verifies that the notebook can be executed. + + If the test fails, check the report""" + with notebook.open(encoding="utf-8") as f: + nb = nbformat.read(f, as_version=4) + monkeypatch.chdir(notebook.parent) + ep = ExecutePreprocessor(timeout=TIMEOUT) + ep.preprocess(nb) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index aaf76d91..9d4211e2 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -1,18 +1,21 @@ -import shlex -import subprocess -from pathlib import Path - -import pytest - - def test_install_in_venv_as_folder(venv, ctx, tmp_path, git_root): with ctx.cd(tmp_path): ctx.run(f"uv pip install {git_root}", in_stream=False) ctx.run("uv pip list | grep agentics", in_stream=False) + ctx.run( + "uv run ipython -c 'from agentics import AG'", + in_stream=False, + env={"VIRTUAL_ENV": ""}, + ) def test_dist_install(wheel, tmp_path_factory, ctx, venv): with ctx.cd(venv): # res = ctx.run("uv pip list --help", in_stream=False) ctx.run(f"uv pip install {wheel}", in_stream=False) - ctx.run("uv pip list | grep agentics", in_stream=False) + # ctx.run("uv pip list | grep agentics", in_stream=False) + ctx.run( + "uv run ipython -c 'from agentics import AG'", + in_stream=False, + env={"VIRTUAL_ENV": ""}, + ) diff --git a/tutorials/tests.ipynb b/tutorials/tests.ipynb deleted file mode 100644 index 9fd3ae47..00000000 --- a/tutorials/tests.ipynb +++ /dev/null @@ -1,3059 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "ac25a395", - "metadata": {}, - "source": [ - "# Agentics Mini Tutorial\n", - "\n", - "Agentics provides the implementation of **AG**, a powerful datatype that connects\n", - "LLMs to Pydantic objects and enables **logical transduction**.\n", - "\n", - "---\n", - "\n", - "## Installation\n", - "\n", - "```bash\n", - "!uv pip install agentics-py" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "dfb79bd4", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[2mUsing Python 3.12.9 environment at: /Users/gliozzo/Code/agentics911/agentics/.venv\u001b[0m\n", - "\u001b[2mAudited \u001b[1m1 package\u001b[0m \u001b[2min 16ms\u001b[0m\u001b[0m\n", - "In Colab: False\n" - ] - } - ], - "source": [ - "! uv pip install agentics-py\n", - "\n", - "! uv pip install agentics-py\n", - "\n", - "\n", - "import os\n", - "from pathlib import Path\n", - "import sys\n", - "from getpass import getpass\n", - "\n", - "from dotenv import find_dotenv, load_dotenv\n", - "\n", - "CURRENT_PATH = \"\"\n", - "\n", - "IN_COLAB = \"google.colab\" in sys.modules\n", - "print(\"In Colab:\", IN_COLAB)\n", - "\n", - "\n", - "if IN_COLAB:\n", - " CURRENT_PATH = \"/content/drive/MyDrive/\"\n", - " # Mount your google drive\n", - " from google.colab import drive\n", - " \n", - " drive.mount(\"/content/drive\")\n", - " from google.colab import userdata\n", - " \n", - " os.environ[\"GEMINI_API_KEY\"] = getpass(\"Enter your GEMINI_API_KEY:\")\n", - "else:\n", - "\n", - " CURRENT_PATH = os.getcwd()\n", - " load_dotenv(find_dotenv())\n", - "\n", - "if not os.getenv(\"GEMINI_API_KEY\"):\n", - " os.environ[\"GEMINI_API_KEY\"] = getpass(\"Enter your GEMINI_API_KEY:\")\n", - "\n", - "base = Path(CURRENT_PATH)" - ] - }, - { - "cell_type": "markdown", - "id": "b8341824", - "metadata": {}, - "source": [ - "## Use Agentics as Lists\n", - "\n", - "Agentics objects (`AG`) can be used similarly to Python lists, allowing you to store and manage collections of states. You can append new elements using the `.append()` method, and access all states via the `.states` attribute.\n", - "\n", - "For example, after creating an empty `AG` object, you can add elements:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "dda356ed", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2025-09-29 07:00:04.627 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The agentics is empty : 0\n", - "The agentics now has more instances : 3\n", - "this triggers an error\n", - "This is the right way to concetenate two agentics. Be careful, the states should be instances of the same atype\n", - "Atype : None\n", - "Alfio\n", - "...\n", - "\n", - "Naweed\n", - "...\n", - "\n", - "Junkyuu\n", - "...\n", - "\n", - "Alfio\n", - "...\n", - "\n", - "Naweed\n", - "...\n", - "\n", - "Junkyuu\n", - "...\n", - "\n", - "\n", - "Atype : None\n", - "Alfio\n", - "...\n", - "\n", - "Naweed\n", - "...\n", - "\n", - "Junkyuu\n", - "...\n", - "\n", - "Alfio\n", - "...\n", - "\n", - "Naweed\n", - "...\n", - "\n", - "Junkyuu\n", - "...\n", - "\n", - "\n", - "Iterating over agentics:\n", - "Alfio\n", - "Naweed\n", - "Junkyuu\n", - "Alfio\n", - "Naweed\n", - "Junkyuu\n", - "Be careful, the AG itself is not a list : atype=None crew_prompt_params={'role': 'Task Executor', 'goal': 'You execute tasks', 'backstory': 'You are always faithful and provide only fact based answers.', 'expected_output': 'Described by Pydantic Type'} instructions='Generate an object of the specified type from the following input.' llm= max_iter=3 prompt_template=None reasoning=None skip_intentional_definition=False states=['Alfio', 'Naweed', 'Junkyuu', 'Alfio', 'Naweed', 'Junkyuu'] tools=None transduce_fields=None transduction_logs_path=None transduction_timeout=None verbose_transduction=True verbose_agent=False\n" - ] - } - ], - "source": [ - "from agentics import AG\n", - "my_first_agentics = AG()\n", - "\n", - "print(\"The agentics is empty :\", len(my_first_agentics))\n", - "\n", - " ## Add elements to the list\n", - "my_first_agentics.append(\"Alfio\")\n", - "## internally, agentics stores the elements in the attribute states\n", - "my_first_agentics.states += [\"Naweed\" , \"Junkyuu\"] \n", - "\n", - "print(\"The agentics now has more instances :\",len(my_first_agentics))\n", - "\n", - "try:\n", - " print(\"this triggers an error\")\n", - " my_first_agentics = my_first_agentics + my_first_agentics\n", - "except:\n", - " my_first_agentics.states= my_first_agentics.states + my_first_agentics.states\n", - " print(\"This is the right way to concetenate two agentics. Be careful, the states should be instances of the same atype\")\n", - " my_first_agentics.pretty_print()\n", - "\n", - "print(\"Iterating over agentics:\") \n", - "for state in my_first_agentics:\n", - " print(state)\n", - "\n", - "print(\"Be careful, the AG itself is not a list :\" , my_first_agentics) \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "id": "334b3dbd", - "metadata": {}, - "source": [ - "## Atypes\n", - "\n", - "Agentics supports **typed AGs** using Pydantic models, enabling you to enforce schema validation and structure on the states stored in an AG. This is useful when you want all elements in your AG to follow a specific format or contain certain fields.\n", - "\n", - "To define a typed AG:\n", - "\n", - "1. **Create a Pydantic model** that describes the schema for your states.\n", - "2. **Instantiate an AG** with the `atype` parameter set to your Pydantic model.\n", - "3. **Add instances** of your model to the AG. Only objects matching the schema will be accepted.\n", - "\n", - "This approach ensures data consistency and allows you to leverage Pydantic's validation features within Agentics workflows.\n", - "\n", - "For example, you can define a `Movie` type and create an AG that only accepts `Movie` instances as its states. See the next cell for a practical demonstration." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "51bc332c", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2025-09-29 07:00:04.638 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Atype : \n", - "movie_name: La dolce vita\n", - "genre: null\n", - "description: null\n", - "\n", - "\n", - "Atype : \n", - "movie_name: La dolce vita\n", - "genre: null\n", - "description: null\n", - "\n", - "\n" - ] - } - ], - "source": [ - "from pydantic import BaseModel\n", - "from typing import Optional\n", - "\n", - "# Define the Movie Pydantic model for use with Agentics AG\n", - "class Movie(BaseModel):\n", - " movie_name: Optional[str] = None\n", - " genre: Optional[str] = None\n", - " description: Optional[str] = None\n", - "\n", - "\n", - "movies = AG(atype=Movie)\n", - "movies.append(Movie(movie_name=\"La dolce vita\"))\n", - "movies.pretty_print()" - ] - }, - { - "cell_type": "markdown", - "id": "86058b3e", - "metadata": {}, - "source": [ - "## Extending and Merging AGs\n", - "AGs can evolve by adding new fields or combining with other AGs to form richer schemas.\n", - "\n", - "### Add attributes\n", - "Use `.add_attribute()` to dynamically extend the schema of an AG. \n", - "This operation mutates the AG in place." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "93272247", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2025-09-29 07:00:04.646 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Atype : \n", - "movie_name: La dolce vita\n", - "genre: null\n", - "description: null\n", - "\n", - "\n", - "adding a new attribute to the type and rebinding the object\n", - "Atype : \n", - "movie_name: La dolce vita\n", - "genre: null\n", - "description: null\n", - "\n", - "\n", - "Atype : \n", - "movie_name: La dolce vita\n", - "genre: null\n", - "description: null\n", - "\n", - "\n", - "Note that the AG changed\n" - ] - } - ], - "source": [ - "movies = AG(atype=Movie)\n", - "movies.append(Movie(movie_name=\"La dolce vita\"))\n", - "movies.pretty_print()\n", - "\n", - "print(\"adding a new attribute to the type and rebinding the object\")\n", - "movies.add_attribute(\"email\", \n", - " description=\"Write an email to tell a fried about this movie\")\n", - "\n", - "movies.pretty_print()\n", - "print(\"Note that the AG changed\")\n" - ] - }, - { - "cell_type": "markdown", - "id": "fccb667d", - "metadata": {}, - "source": [ - "### Subtypes\n", - "You can project an AG onto a subset of its fields, e.g. `movies(\"title\", \"genre\")`. \n", - "This creates a new AG without modifying the original." - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "id": "e824689b", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "This is a subtype\n", - "Atype : \n", - "movie_name: The Shawshank Redemption\n", - "genre: Drama, Crime\n", - "\n", - "movie_name: The Godfather\n", - "genre: Drama, Crime\n", - "\n", - "movie_name: The Godfather Part II\n", - "genre: Drama, Crime\n", - "\n", - "movie_name: Schindler's List\n", - "genre: Drama, History, War\n", - "\n", - "movie_name: 12 Angry Men\n", - "genre: Drama\n", - "\n", - "movie_name: Spirited Away\n", - "genre: Animation, Family, Fantasy\n", - "\n", - "movie_name: The Dark Knight\n", - "genre: Drama, Action, Crime, Thriller\n", - "\n", - "movie_name: Dilwale Dulhania Le Jayenge\n", - "genre: Comedy, Drama, Romance\n", - "\n", - "movie_name: The Green Mile\n", - "genre: Fantasy, Drama, Crime\n", - "\n", - "movie_name: Parasite\n", - "genre: ''\n", - "\n", - "movie_name: Pulp Fiction\n", - "genre: ''\n", - "\n", - "movie_name: Your Name.\n", - "genre: ''\n", - "\n", - "movie_name: 'The Lord of the Rings: The Return of the King'\n", - "genre: ''\n", - "\n", - "movie_name: Forrest Gump\n", - "genre: ''\n", - "\n", - "movie_name: The Good, the Bad and the Ugly\n", - "genre: ''\n", - "\n", - "movie_name: Seven Samurai\n", - "genre: ''\n", - "\n", - "movie_name: GoodFellas\n", - "genre: ''\n", - "\n", - "movie_name: Interstellar\n", - "genre: ''\n", - "\n", - "movie_name: Grave of the Fireflies\n", - "genre: ''\n", - "\n", - "movie_name: Life Is Beautiful\n", - "genre: ''\n", - "\n", - "\n", - "This is the original type.\n", - "Note that the AG didn't change after subtype\n", - "Atype : \n", - "movie_name: The Shawshank Redemption\n", - "genre: Drama, Crime\n", - "description: Imprisoned in the 1940s for the double murder of his wife and her lover,\n", - " upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where\n", - " he puts his accounting skills to work for an amoral warden. During his long stretch\n", - " in prison, Dufresne comes to be admired by the other inmates -- including an older\n", - " prisoner named Red -- for his integrity and unquenchable sense of hope.\n", - "\n", - "movie_name: The Godfather\n", - "genre: Drama, Crime\n", - "description: Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American\n", - " Corleone crime family. When organized crime family patriarch, Vito Corleone barely\n", - " survives an attempt on his life, his youngest son, Michael steps in to take care\n", - " of the would-be killers, launching a campaign of bloody revenge.\n", - "\n", - "movie_name: The Godfather Part II\n", - "genre: Drama, Crime\n", - "description: In the continuing saga of the Corleone crime family, a young Vito Corleone\n", - " grows up in Sicily and in 1910s New York. In the 1950s, Michael Corleone attempts\n", - " to expand the family business into Las Vegas, Hollywood and Cuba.\n", - "\n", - "movie_name: Schindler's List\n", - "genre: Drama, History, War\n", - "description: The true story of how businessman Oskar Schindler saved over a thousand\n", - " Jewish lives from the Nazis while they worked as slaves in his factory during World\n", - " War II.\n", - "\n", - "movie_name: 12 Angry Men\n", - "genre: Drama\n", - "description: The defense and the prosecution have rested and the jury is filing into\n", - " the jury room to decide if a young Spanish-American is guilty or innocent of murdering\n", - " his father. What begins as an open and shut case soon becomes a mini-drama of each\n", - " of the jurors' prejudices and preconceptions about the trial, the accused, and each\n", - " other.\n", - "\n", - "movie_name: Spirited Away\n", - "genre: Animation, Family, Fantasy\n", - "description: A young girl, Chihiro, becomes trapped in a strange new world of spirits.\n", - " When her parents undergo a mysterious transformation, she must call upon the courage\n", - " she never knew she had to free her family.\n", - "\n", - "movie_name: The Dark Knight\n", - "genre: Drama, Action, Crime, Thriller\n", - "description: Batman raises the stakes in his war on crime. With the help of Lt. Jim\n", - " Gordon and District Attorney Harvey Dent, Batman sets out to dismantle the remaining\n", - " criminal organizations that plague the streets. The partnership proves to be effective,\n", - " but they soon find themselves prey to a reign of chaos unleashed by a rising criminal\n", - " mastermind known to the terrified citizens of Gotham as the Joker.\n", - "\n", - "movie_name: Dilwale Dulhania Le Jayenge\n", - "genre: Comedy, Drama, Romance\n", - "description: \"Raj is a rich, carefree, happy-go-lucky second generation NRI. Simran\\\n", - " \\ is the daughter of Chaudhary Baldev Singh, who in spite of being an NRI is very\\\n", - " \\ strict about adherence to Indian values. Simran has left for India to be married\\\n", - " \\ to her childhood fianc\\xE9. Raj leaves for India with a mission at his hands,\\\n", - " \\ to claim his lady love under the noses of her whole family. Thus begins a saga.\"\n", - "\n", - "movie_name: The Green Mile\n", - "genre: Fantasy, Drama, Crime\n", - "description: A supernatural tale set on death row in a Southern prison, where gentle\n", - " giant John Coffey possesses the mysterious power to heal people's ailments. When\n", - " the cell block's head guard, Paul Edgecomb, recognizes Coffey's miraculous gift,\n", - " he tries desperately to help stave off the condemned man's execution.\n", - "\n", - "movie_name: Parasite\n", - "genre: ''\n", - "description: All unemployed, Ki-taek's family takes peculiar interest in the wealthy\n", - " and glamorous Parks for their livelihood until they get entangled in an unexpected\n", - " incident.\n", - "\n", - "movie_name: Pulp Fiction\n", - "genre: ''\n", - "description: A burger-loving hit man, his philosophical partner, a drug-addled gangster's\n", - " moll and a washed-up boxer converge in this sprawling, comedic crime caper. Their\n", - " adventures unfurl in three stories that ingeniously trip back and forth in time.\n", - "\n", - "movie_name: Your Name.\n", - "genre: ''\n", - "description: \"High schoolers Mitsuha and Taki are complete strangers living separate\\\n", - " \\ lives. But one night, they suddenly switch places. Mitsuha wakes up in Taki\\u2019\\\n", - " s body, and he in hers. This bizarre occurrence continues to happen randomly, and\\\n", - " \\ the two must adjust their lives around each other.\"\n", - "\n", - "movie_name: 'The Lord of the Rings: The Return of the King'\n", - "genre: ''\n", - "description: \"As armies mass for a final battle that will decide the fate of the world--and\\\n", - " \\ powerful, ancient forces of Light and Dark compete to determine the outcome--one\\\n", - " \\ member of the Fellowship of the Ring is revealed as the noble heir to the throne\\\n", - " \\ of the Kings of Men. Yet, the sole hope for triumph over evil lies with a brave\\\n", - " \\ hobbit, Frodo, who, accompanied by his loyal friend Sam and the hideous, wretched\\\n", - " \\ Gollum, ventures deep into the very dark heart of Mordor on his seemingly impossible\\\n", - " \\ quest to destroy the Ring of Power.\\u200B\"\n", - "\n", - "movie_name: Forrest Gump\n", - "genre: ''\n", - "description: \"A man with a low IQ has accomplished great things in his life and been\\\n", - " \\ present during significant historic events\\u2014in each case, far exceeding what\\\n", - " \\ anyone imagined he could do. But despite all he has achieved, his one true love\\\n", - " \\ eludes him.\"\n", - "\n", - "movie_name: The Good, the Bad and the Ugly\n", - "genre: ''\n", - "description: \"While the Civil War rages on between the Union and the Confederacy,\\\n", - " \\ three men \\u2013 a quiet loner, a ruthless hitman, and a Mexican bandit \\u2013\\\n", - " \\ comb the American Southwest in search of a strongbox containing $200,000 in stolen\\\n", - " \\ gold.\"\n", - "\n", - "movie_name: Seven Samurai\n", - "genre: ''\n", - "description: A samurai answers a village's request for protection after he falls on\n", - " hard times. The town needs protection from bandits, so the samurai gathers six others\n", - " to help him teach the people how to defend themselves, and the villagers provide\n", - " the soldiers with food.\n", - "\n", - "movie_name: GoodFellas\n", - "genre: ''\n", - "description: The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid\n", - " who is adopted by neighbourhood gangsters at an early age and climbs the ranks of\n", - " a Mafia family under the guidance of Jimmy Conway.\n", - "\n", - "movie_name: Interstellar\n", - "genre: ''\n", - "description: The adventures of a group of explorers who make use of a newly discovered\n", - " wormhole to surpass the limitations on human space travel and conquer the vast distances\n", - " involved in an interstellar voyage.\n", - "\n", - "movie_name: Grave of the Fireflies\n", - "genre: ''\n", - "description: In the final months of World War II, 14-year-old Seita and his sister\n", - " Setsuko are orphaned when their mother is killed during an air raid in Kobe, Japan.\n", - " After a falling out with their aunt, they move into an abandoned bomb shelter. With\n", - " no surviving relatives and their emergency rations depleted, Seita and Setsuko struggle\n", - " to survive.\n", - "\n", - "movie_name: Life Is Beautiful\n", - "genre: ''\n", - "description: A touching story of an Italian book seller of Jewish ancestry who lives\n", - " in his own little fairy tale. His creative and happy life would come to an abrupt\n", - " halt when his entire family is deported to a concentration camp during World War\n", - " II. While locked up he tries to convince his son that the whole thing is just a\n", - " game.\n", - "\n", - "\n", - "Note that the AG didn't change after subtyping it\n" - ] - } - ], - "source": [ - "movies_subtype = movies(\"movie_name\", \"genre\")\n", - "print(\"This is a subtype\")\n", - "movies_subtype.pretty_print()\n", - "\n", - "print(\"This is the original type.\\nNote that the AG didn't change after subtype\")\n", - "movies.pretty_print()\n", - "print(\"Note that the AG didn't change after subtyping it\")" - ] - }, - { - "cell_type": "markdown", - "id": "878bc43f", - "metadata": {}, - "source": [ - "### Merge AGs\n", - "You can merge AGs of different types (e.g., `Movie` with `Director`), combining their states into a new AG with a union of fields. \n", - "On field conflicts, values from the right-hand AG’s states take precedence." - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "id": "e1cdc248", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2025-09-29 09:19:41.948 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n", - "2025-09-29 09:19:41.950 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n", - "2025-09-29 09:19:41.951 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n", - "2025-09-29 09:19:41.952 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n", - "2025-09-29 09:19:41.958 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n", - "2025-09-29 09:19:41.966 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Merging AGs will combine states:\n", - "Atype : \n", - "movie_name: The Shawshank Redemption\n", - "genre: Drama, Crime\n", - "description: Imprisoned in the 1940s for the double murder of his wife and her lover,\n", - " upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where\n", - " he puts his accounting skills to work for an amoral warden. During his long stretch\n", - " in prison, Dufresne comes to be admired by the other inmates -- including an older\n", - " prisoner named Red -- for his integrity and unquenchable sense of hope.\n", - "director_name: Fellini\n", - "\n", - "movie_name: The Godfather\n", - "genre: Drama, Crime\n", - "description: Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American\n", - " Corleone crime family. When organized crime family patriarch, Vito Corleone barely\n", - " survives an attempt on his life, his youngest son, Michael steps in to take care\n", - " of the would-be killers, launching a campaign of bloody revenge.\n", - "director_name: null\n", - "\n", - "movie_name: The Godfather Part II\n", - "genre: Drama, Crime\n", - "description: In the continuing saga of the Corleone crime family, a young Vito Corleone\n", - " grows up in Sicily and in 1910s New York. In the 1950s, Michael Corleone attempts\n", - " to expand the family business into Las Vegas, Hollywood and Cuba.\n", - "director_name: null\n", - "\n", - "movie_name: Schindler's List\n", - "genre: Drama, History, War\n", - "description: The true story of how businessman Oskar Schindler saved over a thousand\n", - " Jewish lives from the Nazis while they worked as slaves in his factory during World\n", - " War II.\n", - "director_name: null\n", - "\n", - "movie_name: 12 Angry Men\n", - "genre: Drama\n", - "description: The defense and the prosecution have rested and the jury is filing into\n", - " the jury room to decide if a young Spanish-American is guilty or innocent of murdering\n", - " his father. What begins as an open and shut case soon becomes a mini-drama of each\n", - " of the jurors' prejudices and preconceptions about the trial, the accused, and each\n", - " other.\n", - "director_name: null\n", - "\n", - "movie_name: Spirited Away\n", - "genre: Animation, Family, Fantasy\n", - "description: A young girl, Chihiro, becomes trapped in a strange new world of spirits.\n", - " When her parents undergo a mysterious transformation, she must call upon the courage\n", - " she never knew she had to free her family.\n", - "director_name: null\n", - "\n", - "movie_name: The Dark Knight\n", - "genre: Drama, Action, Crime, Thriller\n", - "description: Batman raises the stakes in his war on crime. With the help of Lt. Jim\n", - " Gordon and District Attorney Harvey Dent, Batman sets out to dismantle the remaining\n", - " criminal organizations that plague the streets. The partnership proves to be effective,\n", - " but they soon find themselves prey to a reign of chaos unleashed by a rising criminal\n", - " mastermind known to the terrified citizens of Gotham as the Joker.\n", - "director_name: null\n", - "\n", - "movie_name: Dilwale Dulhania Le Jayenge\n", - "genre: Comedy, Drama, Romance\n", - "description: \"Raj is a rich, carefree, happy-go-lucky second generation NRI. Simran\\\n", - " \\ is the daughter of Chaudhary Baldev Singh, who in spite of being an NRI is very\\\n", - " \\ strict about adherence to Indian values. Simran has left for India to be married\\\n", - " \\ to her childhood fianc\\xE9. Raj leaves for India with a mission at his hands,\\\n", - " \\ to claim his lady love under the noses of her whole family. Thus begins a saga.\"\n", - "director_name: null\n", - "\n", - "movie_name: The Green Mile\n", - "genre: Fantasy, Drama, Crime\n", - "description: A supernatural tale set on death row in a Southern prison, where gentle\n", - " giant John Coffey possesses the mysterious power to heal people's ailments. When\n", - " the cell block's head guard, Paul Edgecomb, recognizes Coffey's miraculous gift,\n", - " he tries desperately to help stave off the condemned man's execution.\n", - "director_name: null\n", - "\n", - "movie_name: Parasite\n", - "genre: ''\n", - "description: All unemployed, Ki-taek's family takes peculiar interest in the wealthy\n", - " and glamorous Parks for their livelihood until they get entangled in an unexpected\n", - " incident.\n", - "director_name: null\n", - "\n", - "movie_name: Pulp Fiction\n", - "genre: ''\n", - "description: A burger-loving hit man, his philosophical partner, a drug-addled gangster's\n", - " moll and a washed-up boxer converge in this sprawling, comedic crime caper. Their\n", - " adventures unfurl in three stories that ingeniously trip back and forth in time.\n", - "director_name: null\n", - "\n", - "movie_name: Your Name.\n", - "genre: ''\n", - "description: \"High schoolers Mitsuha and Taki are complete strangers living separate\\\n", - " \\ lives. But one night, they suddenly switch places. Mitsuha wakes up in Taki\\u2019\\\n", - " s body, and he in hers. This bizarre occurrence continues to happen randomly, and\\\n", - " \\ the two must adjust their lives around each other.\"\n", - "director_name: null\n", - "\n", - "movie_name: 'The Lord of the Rings: The Return of the King'\n", - "genre: ''\n", - "description: \"As armies mass for a final battle that will decide the fate of the world--and\\\n", - " \\ powerful, ancient forces of Light and Dark compete to determine the outcome--one\\\n", - " \\ member of the Fellowship of the Ring is revealed as the noble heir to the throne\\\n", - " \\ of the Kings of Men. Yet, the sole hope for triumph over evil lies with a brave\\\n", - " \\ hobbit, Frodo, who, accompanied by his loyal friend Sam and the hideous, wretched\\\n", - " \\ Gollum, ventures deep into the very dark heart of Mordor on his seemingly impossible\\\n", - " \\ quest to destroy the Ring of Power.\\u200B\"\n", - "director_name: null\n", - "\n", - "movie_name: Forrest Gump\n", - "genre: ''\n", - "description: \"A man with a low IQ has accomplished great things in his life and been\\\n", - " \\ present during significant historic events\\u2014in each case, far exceeding what\\\n", - " \\ anyone imagined he could do. But despite all he has achieved, his one true love\\\n", - " \\ eludes him.\"\n", - "director_name: null\n", - "\n", - "movie_name: The Good, the Bad and the Ugly\n", - "genre: ''\n", - "description: \"While the Civil War rages on between the Union and the Confederacy,\\\n", - " \\ three men \\u2013 a quiet loner, a ruthless hitman, and a Mexican bandit \\u2013\\\n", - " \\ comb the American Southwest in search of a strongbox containing $200,000 in stolen\\\n", - " \\ gold.\"\n", - "director_name: null\n", - "\n", - "movie_name: Seven Samurai\n", - "genre: ''\n", - "description: A samurai answers a village's request for protection after he falls on\n", - " hard times. The town needs protection from bandits, so the samurai gathers six others\n", - " to help him teach the people how to defend themselves, and the villagers provide\n", - " the soldiers with food.\n", - "director_name: null\n", - "\n", - "movie_name: GoodFellas\n", - "genre: ''\n", - "description: The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid\n", - " who is adopted by neighbourhood gangsters at an early age and climbs the ranks of\n", - " a Mafia family under the guidance of Jimmy Conway.\n", - "director_name: null\n", - "\n", - "movie_name: Interstellar\n", - "genre: ''\n", - "description: The adventures of a group of explorers who make use of a newly discovered\n", - " wormhole to surpass the limitations on human space travel and conquer the vast distances\n", - " involved in an interstellar voyage.\n", - "director_name: null\n", - "\n", - "movie_name: Grave of the Fireflies\n", - "genre: ''\n", - "description: In the final months of World War II, 14-year-old Seita and his sister\n", - " Setsuko are orphaned when their mother is killed during an air raid in Kobe, Japan.\n", - " After a falling out with their aunt, they move into an abandoned bomb shelter. With\n", - " no surviving relatives and their emergency rations depleted, Seita and Setsuko struggle\n", - " to survive.\n", - "director_name: null\n", - "\n", - "movie_name: Life Is Beautiful\n", - "genre: ''\n", - "description: A touching story of an Italian book seller of Jewish ancestry who lives\n", - " in his own little fairy tale. His creative and happy life would come to an abrupt\n", - " halt when his entire family is deported to a concentration camp during World War\n", - " II. While locked up he tries to convince his son that the whole thing is just a\n", - " game.\n", - "director_name: null\n", - "\n", - "movie_name: Superman\n", - "genre: null\n", - "description: null\n", - "director_name: null\n", - "\n", - "\n", - "Atype : \n", - "movie_name: The Shawshank Redemption\n", - "genre: Drama, Crime\n", - "description: Imprisoned in the 1940s for the double murder of his wife and her lover,\n", - " upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where\n", - " he puts his accounting skills to work for an amoral warden. During his long stretch\n", - " in prison, Dufresne comes to be admired by the other inmates -- including an older\n", - " prisoner named Red -- for his integrity and unquenchable sense of hope.\n", - "director_name: Fellini\n", - "\n", - "movie_name: The Godfather\n", - "genre: Drama, Crime\n", - "description: Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American\n", - " Corleone crime family. When organized crime family patriarch, Vito Corleone barely\n", - " survives an attempt on his life, his youngest son, Michael steps in to take care\n", - " of the would-be killers, launching a campaign of bloody revenge.\n", - "director_name: Donner\n", - "\n", - "movie_name: The Godfather Part II\n", - "genre: Drama, Crime\n", - "description: In the continuing saga of the Corleone crime family, a young Vito Corleone\n", - " grows up in Sicily and in 1910s New York. In the 1950s, Michael Corleone attempts\n", - " to expand the family business into Las Vegas, Hollywood and Cuba.\n", - "director_name: null\n", - "\n", - "movie_name: Schindler's List\n", - "genre: Drama, History, War\n", - "description: The true story of how businessman Oskar Schindler saved over a thousand\n", - " Jewish lives from the Nazis while they worked as slaves in his factory during World\n", - " War II.\n", - "director_name: null\n", - "\n", - "movie_name: 12 Angry Men\n", - "genre: Drama\n", - "description: The defense and the prosecution have rested and the jury is filing into\n", - " the jury room to decide if a young Spanish-American is guilty or innocent of murdering\n", - " his father. What begins as an open and shut case soon becomes a mini-drama of each\n", - " of the jurors' prejudices and preconceptions about the trial, the accused, and each\n", - " other.\n", - "director_name: null\n", - "\n", - "movie_name: Spirited Away\n", - "genre: Animation, Family, Fantasy\n", - "description: A young girl, Chihiro, becomes trapped in a strange new world of spirits.\n", - " When her parents undergo a mysterious transformation, she must call upon the courage\n", - " she never knew she had to free her family.\n", - "director_name: null\n", - "\n", - "movie_name: The Dark Knight\n", - "genre: Drama, Action, Crime, Thriller\n", - "description: Batman raises the stakes in his war on crime. With the help of Lt. Jim\n", - " Gordon and District Attorney Harvey Dent, Batman sets out to dismantle the remaining\n", - " criminal organizations that plague the streets. The partnership proves to be effective,\n", - " but they soon find themselves prey to a reign of chaos unleashed by a rising criminal\n", - " mastermind known to the terrified citizens of Gotham as the Joker.\n", - "director_name: null\n", - "\n", - "movie_name: Dilwale Dulhania Le Jayenge\n", - "genre: Comedy, Drama, Romance\n", - "description: \"Raj is a rich, carefree, happy-go-lucky second generation NRI. Simran\\\n", - " \\ is the daughter of Chaudhary Baldev Singh, who in spite of being an NRI is very\\\n", - " \\ strict about adherence to Indian values. Simran has left for India to be married\\\n", - " \\ to her childhood fianc\\xE9. Raj leaves for India with a mission at his hands,\\\n", - " \\ to claim his lady love under the noses of her whole family. Thus begins a saga.\"\n", - "director_name: null\n", - "\n", - "movie_name: The Green Mile\n", - "genre: Fantasy, Drama, Crime\n", - "description: A supernatural tale set on death row in a Southern prison, where gentle\n", - " giant John Coffey possesses the mysterious power to heal people's ailments. When\n", - " the cell block's head guard, Paul Edgecomb, recognizes Coffey's miraculous gift,\n", - " he tries desperately to help stave off the condemned man's execution.\n", - "director_name: null\n", - "\n", - "movie_name: Parasite\n", - "genre: ''\n", - "description: All unemployed, Ki-taek's family takes peculiar interest in the wealthy\n", - " and glamorous Parks for their livelihood until they get entangled in an unexpected\n", - " incident.\n", - "director_name: null\n", - "\n", - "movie_name: Pulp Fiction\n", - "genre: ''\n", - "description: A burger-loving hit man, his philosophical partner, a drug-addled gangster's\n", - " moll and a washed-up boxer converge in this sprawling, comedic crime caper. Their\n", - " adventures unfurl in three stories that ingeniously trip back and forth in time.\n", - "director_name: null\n", - "\n", - "movie_name: Your Name.\n", - "genre: ''\n", - "description: \"High schoolers Mitsuha and Taki are complete strangers living separate\\\n", - " \\ lives. But one night, they suddenly switch places. Mitsuha wakes up in Taki\\u2019\\\n", - " s body, and he in hers. This bizarre occurrence continues to happen randomly, and\\\n", - " \\ the two must adjust their lives around each other.\"\n", - "director_name: null\n", - "\n", - "movie_name: 'The Lord of the Rings: The Return of the King'\n", - "genre: ''\n", - "description: \"As armies mass for a final battle that will decide the fate of the world--and\\\n", - " \\ powerful, ancient forces of Light and Dark compete to determine the outcome--one\\\n", - " \\ member of the Fellowship of the Ring is revealed as the noble heir to the throne\\\n", - " \\ of the Kings of Men. Yet, the sole hope for triumph over evil lies with a brave\\\n", - " \\ hobbit, Frodo, who, accompanied by his loyal friend Sam and the hideous, wretched\\\n", - " \\ Gollum, ventures deep into the very dark heart of Mordor on his seemingly impossible\\\n", - " \\ quest to destroy the Ring of Power.\\u200B\"\n", - "director_name: null\n", - "\n", - "movie_name: Forrest Gump\n", - "genre: ''\n", - "description: \"A man with a low IQ has accomplished great things in his life and been\\\n", - " \\ present during significant historic events\\u2014in each case, far exceeding what\\\n", - " \\ anyone imagined he could do. But despite all he has achieved, his one true love\\\n", - " \\ eludes him.\"\n", - "director_name: null\n", - "\n", - "movie_name: The Good, the Bad and the Ugly\n", - "genre: ''\n", - "description: \"While the Civil War rages on between the Union and the Confederacy,\\\n", - " \\ three men \\u2013 a quiet loner, a ruthless hitman, and a Mexican bandit \\u2013\\\n", - " \\ comb the American Southwest in search of a strongbox containing $200,000 in stolen\\\n", - " \\ gold.\"\n", - "director_name: null\n", - "\n", - "movie_name: Seven Samurai\n", - "genre: ''\n", - "description: A samurai answers a village's request for protection after he falls on\n", - " hard times. The town needs protection from bandits, so the samurai gathers six others\n", - " to help him teach the people how to defend themselves, and the villagers provide\n", - " the soldiers with food.\n", - "director_name: null\n", - "\n", - "movie_name: GoodFellas\n", - "genre: ''\n", - "description: The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid\n", - " who is adopted by neighbourhood gangsters at an early age and climbs the ranks of\n", - " a Mafia family under the guidance of Jimmy Conway.\n", - "director_name: null\n", - "\n", - "movie_name: Interstellar\n", - "genre: ''\n", - "description: The adventures of a group of explorers who make use of a newly discovered\n", - " wormhole to surpass the limitations on human space travel and conquer the vast distances\n", - " involved in an interstellar voyage.\n", - "director_name: null\n", - "\n", - "movie_name: Grave of the Fireflies\n", - "genre: ''\n", - "description: In the final months of World War II, 14-year-old Seita and his sister\n", - " Setsuko are orphaned when their mother is killed during an air raid in Kobe, Japan.\n", - " After a falling out with their aunt, they move into an abandoned bomb shelter. With\n", - " no surviving relatives and their emergency rations depleted, Seita and Setsuko struggle\n", - " to survive.\n", - "director_name: null\n", - "\n", - "movie_name: Life Is Beautiful\n", - "genre: ''\n", - "description: A touching story of an Italian book seller of Jewish ancestry who lives\n", - " in his own little fairy tale. His creative and happy life would come to an abrupt\n", - " halt when his entire family is deported to a concentration camp during World War\n", - " II. While locked up he tries to convince his son that the whole thing is just a\n", - " game.\n", - "director_name: null\n", - "\n", - "movie_name: Superman\n", - "genre: null\n", - "description: null\n", - "director_name: null\n", - "\n", - "\n" - ] - }, - { - "data": { - "text/plain": [ - "'Atype : \\nmovie_name: The Shawshank Redemption\\ngenre: Drama, Crime\\ndescription: Imprisoned in the 1940s for the double murder of his wife and her lover,\\n upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where\\n he puts his accounting skills to work for an amoral warden. During his long stretch\\n in prison, Dufresne comes to be admired by the other inmates -- including an older\\n prisoner named Red -- for his integrity and unquenchable sense of hope.\\ndirector_name: Fellini\\n\\nmovie_name: The Godfather\\ngenre: Drama, Crime\\ndescription: Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American\\n Corleone crime family. When organized crime family patriarch, Vito Corleone barely\\n survives an attempt on his life, his youngest son, Michael steps in to take care\\n of the would-be killers, launching a campaign of bloody revenge.\\ndirector_name: Donner\\n\\nmovie_name: The Godfather Part II\\ngenre: Drama, Crime\\ndescription: In the continuing saga of the Corleone crime family, a young Vito Corleone\\n grows up in Sicily and in 1910s New York. In the 1950s, Michael Corleone attempts\\n to expand the family business into Las Vegas, Hollywood and Cuba.\\ndirector_name: null\\n\\nmovie_name: Schindler\\'s List\\ngenre: Drama, History, War\\ndescription: The true story of how businessman Oskar Schindler saved over a thousand\\n Jewish lives from the Nazis while they worked as slaves in his factory during World\\n War II.\\ndirector_name: null\\n\\nmovie_name: 12 Angry Men\\ngenre: Drama\\ndescription: The defense and the prosecution have rested and the jury is filing into\\n the jury room to decide if a young Spanish-American is guilty or innocent of murdering\\n his father. What begins as an open and shut case soon becomes a mini-drama of each\\n of the jurors\\' prejudices and preconceptions about the trial, the accused, and each\\n other.\\ndirector_name: null\\n\\nmovie_name: Spirited Away\\ngenre: Animation, Family, Fantasy\\ndescription: A young girl, Chihiro, becomes trapped in a strange new world of spirits.\\n When her parents undergo a mysterious transformation, she must call upon the courage\\n she never knew she had to free her family.\\ndirector_name: null\\n\\nmovie_name: The Dark Knight\\ngenre: Drama, Action, Crime, Thriller\\ndescription: Batman raises the stakes in his war on crime. With the help of Lt. Jim\\n Gordon and District Attorney Harvey Dent, Batman sets out to dismantle the remaining\\n criminal organizations that plague the streets. The partnership proves to be effective,\\n but they soon find themselves prey to a reign of chaos unleashed by a rising criminal\\n mastermind known to the terrified citizens of Gotham as the Joker.\\ndirector_name: null\\n\\nmovie_name: Dilwale Dulhania Le Jayenge\\ngenre: Comedy, Drama, Romance\\ndescription: \"Raj is a rich, carefree, happy-go-lucky second generation NRI. Simran\\\\\\n \\\\ is the daughter of Chaudhary Baldev Singh, who in spite of being an NRI is very\\\\\\n \\\\ strict about adherence to Indian values. Simran has left for India to be married\\\\\\n \\\\ to her childhood fianc\\\\xE9. Raj leaves for India with a mission at his hands,\\\\\\n \\\\ to claim his lady love under the noses of her whole family. Thus begins a saga.\"\\ndirector_name: null\\n\\nmovie_name: The Green Mile\\ngenre: Fantasy, Drama, Crime\\ndescription: A supernatural tale set on death row in a Southern prison, where gentle\\n giant John Coffey possesses the mysterious power to heal people\\'s ailments. When\\n the cell block\\'s head guard, Paul Edgecomb, recognizes Coffey\\'s miraculous gift,\\n he tries desperately to help stave off the condemned man\\'s execution.\\ndirector_name: null\\n\\nmovie_name: Parasite\\ngenre: \\'\\'\\ndescription: All unemployed, Ki-taek\\'s family takes peculiar interest in the wealthy\\n and glamorous Parks for their livelihood until they get entangled in an unexpected\\n incident.\\ndirector_name: null\\n\\nmovie_name: Pulp Fiction\\ngenre: \\'\\'\\ndescription: A burger-loving hit man, his philosophical partner, a drug-addled gangster\\'s\\n moll and a washed-up boxer converge in this sprawling, comedic crime caper. Their\\n adventures unfurl in three stories that ingeniously trip back and forth in time.\\ndirector_name: null\\n\\nmovie_name: Your Name.\\ngenre: \\'\\'\\ndescription: \"High schoolers Mitsuha and Taki are complete strangers living separate\\\\\\n \\\\ lives. But one night, they suddenly switch places. Mitsuha wakes up in Taki\\\\u2019\\\\\\n s body, and he in hers. This bizarre occurrence continues to happen randomly, and\\\\\\n \\\\ the two must adjust their lives around each other.\"\\ndirector_name: null\\n\\nmovie_name: \\'The Lord of the Rings: The Return of the King\\'\\ngenre: \\'\\'\\ndescription: \"As armies mass for a final battle that will decide the fate of the world--and\\\\\\n \\\\ powerful, ancient forces of Light and Dark compete to determine the outcome--one\\\\\\n \\\\ member of the Fellowship of the Ring is revealed as the noble heir to the throne\\\\\\n \\\\ of the Kings of Men. Yet, the sole hope for triumph over evil lies with a brave\\\\\\n \\\\ hobbit, Frodo, who, accompanied by his loyal friend Sam and the hideous, wretched\\\\\\n \\\\ Gollum, ventures deep into the very dark heart of Mordor on his seemingly impossible\\\\\\n \\\\ quest to destroy the Ring of Power.\\\\u200B\"\\ndirector_name: null\\n\\nmovie_name: Forrest Gump\\ngenre: \\'\\'\\ndescription: \"A man with a low IQ has accomplished great things in his life and been\\\\\\n \\\\ present during significant historic events\\\\u2014in each case, far exceeding what\\\\\\n \\\\ anyone imagined he could do. But despite all he has achieved, his one true love\\\\\\n \\\\ eludes him.\"\\ndirector_name: null\\n\\nmovie_name: The Good, the Bad and the Ugly\\ngenre: \\'\\'\\ndescription: \"While the Civil War rages on between the Union and the Confederacy,\\\\\\n \\\\ three men \\\\u2013 a quiet loner, a ruthless hitman, and a Mexican bandit \\\\u2013\\\\\\n \\\\ comb the American Southwest in search of a strongbox containing $200,000 in stolen\\\\\\n \\\\ gold.\"\\ndirector_name: null\\n\\nmovie_name: Seven Samurai\\ngenre: \\'\\'\\ndescription: A samurai answers a village\\'s request for protection after he falls on\\n hard times. The town needs protection from bandits, so the samurai gathers six others\\n to help him teach the people how to defend themselves, and the villagers provide\\n the soldiers with food.\\ndirector_name: null\\n\\nmovie_name: GoodFellas\\ngenre: \\'\\'\\ndescription: The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid\\n who is adopted by neighbourhood gangsters at an early age and climbs the ranks of\\n a Mafia family under the guidance of Jimmy Conway.\\ndirector_name: null\\n\\nmovie_name: Interstellar\\ngenre: \\'\\'\\ndescription: The adventures of a group of explorers who make use of a newly discovered\\n wormhole to surpass the limitations on human space travel and conquer the vast distances\\n involved in an interstellar voyage.\\ndirector_name: null\\n\\nmovie_name: Grave of the Fireflies\\ngenre: \\'\\'\\ndescription: In the final months of World War II, 14-year-old Seita and his sister\\n Setsuko are orphaned when their mother is killed during an air raid in Kobe, Japan.\\n After a falling out with their aunt, they move into an abandoned bomb shelter. With\\n no surviving relatives and their emergency rations depleted, Seita and Setsuko struggle\\n to survive.\\ndirector_name: null\\n\\nmovie_name: Life Is Beautiful\\ngenre: \\'\\'\\ndescription: A touching story of an Italian book seller of Jewish ancestry who lives\\n in his own little fairy tale. His creative and happy life would come to an abrupt\\n halt when his entire family is deported to a concentration camp during World War\\n II. While locked up he tries to convince his son that the whole thing is just a\\n game.\\ndirector_name: null\\n\\nmovie_name: Superman\\ngenre: null\\ndescription: null\\ndirector_name: null\\n\\n'" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# Define a new Pydantic type for directors\n", - "class Director(BaseModel):\n", - " director_name: Optional[str] = None\n", - "\n", - "# Merge movies (Movie type) with directors (Director type)\n", - "# The result AG will have fields from both Movie and Director\n", - "prod_movies = movies.merge(\n", - " AG(atype=Director, states=[Director(director_name=\"Fellini\")])\n", - ")\n", - "\n", - "# Add another movie to the original AG\n", - "movies.append(Movie(movie_name=\"Superman\"))\n", - "\n", - "print(\"Merging AGs will combine states:\")\n", - "\n", - "# Merge with one director state; the single director is aligned with each movie\n", - "movies.merge(\n", - " AG(atype=Director, states=[Director(director_name=\"Fellini\")])\n", - ").pretty_print()\n", - "\n", - "# Merge with two director states; directors are aligned by index with movies\n", - "# If the AGs are different lengths, extra states are still included\n", - "movies.merge(\n", - " AG(atype=Director, states=[\n", - " Director(director_name=\"Fellini\"),\n", - " Director(director_name=\"Donner\")\n", - " ])\n", - ").pretty_print()" - ] - }, - { - "cell_type": "markdown", - "id": "aee180d8", - "metadata": {}, - "source": [ - "## Import Agentics for Json and CSV \n", - "\n", - "Agentics AG objects can be easily imported from and exported to CSV and JSONL formats. This enables seamless integration with tabular and structured data workflows.\n", - "\n", - "- **CSV Import/Export:** \n", - " Use `AG.from_csv(\"path/to/file.csv\")` to create an AG from a CSV file. The schema (`atype`) can be inferred automatically or provided explicitly.\n", - "- **JSONL Import/Export:** \n", - " Use `AG.to_jsonl(\"path/to/file.jsonl\")` to export, and `AG.from_jsonl(\"path/to/file.jsonl\")` to import AG objects in JSON Lines format.\n", - "\n", - "This functionality allows you to move data between Agentics and other tools with minimal effort." - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "id": "10c0450a", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2025-09-29 09:19:50.667 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n", - "2025-09-29 09:19:50.669 | DEBUG | agentics.core.agentics:from_csv:303 - Importing Agentics of type Movie from CSV data/movies.csv\n", - "2025-09-29 09:19:50.671 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n", - "2025-09-29 09:19:50.671 | DEBUG | agentics.core.agentics:to_jsonl:409 - Exporting 100 states or atype to data/movies.jsonl\n", - "2025-09-29 09:19:50.678 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Atype : \n", - "movie_name: The Shawshank Redemption\n", - "genre: Drama, Crime\n", - "description: Imprisoned in the 1940s for the double murder of his wife and her lover,\n", - " upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where\n", - " he puts his accounting skills to work for an amoral warden. During his long stretch\n", - " in prison, Dufresne comes to be admired by the other inmates -- including an older\n", - " prisoner named Red -- for his integrity and unquenchable sense of hope.\n", - "\n", - "movie_name: The Godfather\n", - "genre: Drama, Crime\n", - "description: Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American\n", - " Corleone crime family. When organized crime family patriarch, Vito Corleone barely\n", - " survives an attempt on his life, his youngest son, Michael steps in to take care\n", - " of the would-be killers, launching a campaign of bloody revenge.\n", - "\n", - "movie_name: The Godfather Part II\n", - "genre: Drama, Crime\n", - "description: In the continuing saga of the Corleone crime family, a young Vito Corleone\n", - " grows up in Sicily and in 1910s New York. In the 1950s, Michael Corleone attempts\n", - " to expand the family business into Las Vegas, Hollywood and Cuba.\n", - "\n", - "\n", - "Imported Type \n", - "Provided Type \n", - "Imported atype from jsonl: \n" - ] - } - ], - "source": [ - "# Create a new AG object from the provided csv file\n", - "movies = AG.from_csv(base / \"data/movies.csv\", max_rows=3)\n", - "movies.pretty_print()\n", - "\n", - "# Note that the atype has been automatically inffered\n", - "print(\"Imported Type\", movies.atype)\n", - "\n", - "# Reloading same file by providing atype\n", - "movies = AG.from_csv(base /\"data/movies.csv\", atype=Movie)\n", - "\n", - "# Note that just a subset of the attributes have been imported\n", - "print(\"Provided Type\" , movies.atype)\n", - "\n", - "# agentics can be exported and imported from jsonl objects\n", - "movies.to_jsonl(base /\"data/movies.jsonl\")\n", - "movies= AG.from_jsonl(base / \"data/movies.jsonl\")\n", - "\n", - "# note this type is different from what imported from csv\n", - "print(\"Imported atype from jsonl: \", movies.atype)" - ] - }, - { - "cell_type": "markdown", - "id": "e103fc4e", - "metadata": {}, - "source": [ - "## Logical Transduction\n", - "\n", - "Once an AG is initialized with an atype, Agentics can **transduce** any string of text and/or pydantic object into that type. If a list of strings is provided, they are processed asynchronously." - ] - }, - { - "cell_type": "markdown", - "id": "49d199ab", - "metadata": {}, - "source": [ - "## Untyped transduction\n", - "\n", - "If no target atype is provided, transduction works as a regular llm call, where the input text or pydantic object is given to the LLM and the output is the LLM response. In this use case, agentics provides an off the shelp **async scale-out framework for LLM calls**. \n", - "\n", - "Note that no AType is specified, the output of transduction is alist of strings. So it is not recommended to use this notation for transduction algebra. In addition, Unconstrained trnasduction tends to me less efficient as it requires the LLM to guess the type of output required, often resulting in verbose and unecessary information . " - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "id": "926e741f", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2025-09-29 09:21:09.617 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n", - "2025-09-29 09:21:09.617 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "9cb5f5059d134d50854ec2c72df12307", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Output()" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
\n"
-      ],
-      "text/plain": []
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Question: What are the benefits of using Agentic AI for data workflows?\n",
-      "Answer## Why Agentic AI Is a Game‑Changer for Data Workflows\n",
-      "\n",
-      "| Benefit | What It Means for Your Data Pipeline | Real‑World Impact |\n",
-      "|---------|--------------------------------------|-------------------|\n",
-      "| **End‑to‑end automation** | Agents can **orchestrate** every step—from data ingestion, cleaning, and transformation to model training, validation, and deployment—without manual hand‑offs. | A retail analytics team cuts the nightly ETL window from 6 hours to <30 minutes. |\n",
-      "| **Dynamic decision‑making** | Agents continuously **monitor** data quality, resource usage, and model performance, then **re‑route** or **re‑configure** tasks on the fly (e.g., switch to a backup data source when the primary API throttles). | A fraud‑detection pipeline automatically falls back to a lighter‑weight model during traffic spikes, keeping latency <200 ms. |\n",
-      "| **Self‑learning & adaptation** | Using reinforcement‑learning or meta‑learning loops, agents **learn optimal hyper‑parameters, scheduling policies, and resource allocations** over time. | An ML ops team sees a 15 % boost in model accuracy after the agent discovers a better feature‑engineering recipe. |\n",
-      "| **Human‑in‑the‑loop collaboration** | Agents can **surface uncertainties** (e.g., ambiguous schema changes) and request clarification, turning a fully automated run into a **guided workflow** that still respects governance. | Data stewards approve schema updates in seconds rather than days, keeping downstream dashboards up‑to‑date. |\n",
-      "| **Scalability across environments** | Because agents are **declarative** (they describe *what* to do, not *how*), the same workflow can run on‑prem, in the cloud, or at the edge with minimal re‑engineering. | A biotech firm runs the same preprocessing pipeline on a local HPC cluster for R&D and on AWS for production analytics. |\n",
-      "| **Robust error handling & recovery** | Agents embed **retry logic, fallback strategies, and state checkpointing**, so a single failure rarely brings the whole pipeline down. | A nightly data sync recovers from a temporary network outage automatically, eliminating missed reporting windows. |\n",
-      "| **Explainability & auditability** | Every action an agent takes is logged as a **structured provenance record** (who, what, when, why), satisfying compliance (GDPR, HIPAA, SOX) and making root‑cause analysis trivial. | Auditors can trace a data‑drift alert back to the exact transformation step that triggered it. |\n",
-      "| **Cost optimization** | Agents can **right‑size resources** (e.g., spin up a spot‑instance only when needed) and **shut down idle services**, reducing cloud spend. | A data engineering team saves ~20 % on monthly compute bills by letting agents pause idle Spark clusters. |\n",
-      "| **Rapid prototyping & iteration** | With a library of reusable agents (ingest‑agent, cleanse‑agent, model‑train‑agent, etc.), data scientists can **compose new pipelines in minutes** rather than weeks. | A marketing analyst builds a new churn‑prediction workflow in a single afternoon, then hands it off to ops for production. |\n",
-      "| **Cross‑domain knowledge reuse** | Agents can **share learned policies** (e.g., optimal data‑partitioning strategies) across projects, turning siloed expertise into organization‑wide intelligence. | The finance team benefits from the same data‑skew detection logic that the supply‑chain team refined. |\n",
-      "\n",
-      "---\n",
-      "\n",
-      "### How It Works (High‑Level)\n",
-      "\n",
-      "1. **Goal Definition** – You specify the desired outcome (e.g., “produce a clean, feature‑engineered dataset every morning”).  \n",
-      "2. **Agent Composition** – A meta‑agent assembles specialized sub‑agents (ingest, validate, transform, model‑train, monitor).  \n",
-      "3. **Execution Loop** – Each sub‑agent runs, reports status, and can request resources or clarification.  \n",
-      "4. **Feedback & Learning** – Metrics (latency, accuracy, cost) feed back into a reinforcement‑learning controller that updates policies for the next run.  \n",
-      "5. **Governance Layer** – All actions are logged, versioned, and can be reviewed or overridden by humans.\n",
-      "\n",
-      "---\n",
-      "\n",
-      "### Quick Checklist: Is Agentic AI Right for Your Workflow?\n",
-      "\n",
-      "| ✅ | Question |\n",
-      "|---|----------|\n",
-      "| 1 | Do you have **repetitive, multi‑step pipelines** that involve data movement, transformation, and model training? |\n",
-      "| 2 | Are **latency, cost, or error‑rate\n",
-      "\n",
-      "Question: Will AI improve working conditions for the middle class?\n",
-      "Answer**Short answer:** Yes, AI has the potential to improve working conditions for many middle‑class workers, but whether that potential is realized will depend on how businesses, governments, and societies shape the technology’s deployment.\n",
-      "\n",
-      "---\n",
-      "\n",
-      "## 1. How AI can make work better for the middle class\n",
-      "\n",
-      "| Area | What AI can do | Why it matters for middle‑class workers |\n",
-      "|------|----------------|----------------------------------------|\n",
-      "| **Automation of repetitive tasks** | AI‑driven software (e.g., document‑processing bots, scheduling assistants, code‑completion tools) can take over routine, time‑consuming work. | Frees employees to focus on higher‑value, more creative or strategic activities, reducing monotony and burnout. |\n",
-      "| **Decision‑support & analytics** | Real‑time dashboards, predictive models, and natural‑language query tools help workers interpret data quickly. | Cuts down on long “dig‑through” research phases, speeds up problem‑solving, and improves confidence in decisions. |\n",
-      "| **Skill‑upgrading & personalized learning** | Adaptive learning platforms use AI to recommend micro‑courses that match an individual’s gaps and career goals. | Makes continuous upskilling more affordable and relevant, helping workers stay competitive without taking long leaves of absence. |\n",
-      "| **Remote‑work enablement** | AI‑powered transcription, translation, and virtual‑assistant tools improve collaboration across time zones. | Expands access to flexible work arrangements, which can improve work‑life balance and reduce commuting stress. |\n",
-      "| **Health & safety monitoring** | Wearables and computer‑vision systems can flag ergonomic risks, fatigue, or unsafe conditions. | Directly reduces physical strain and injury rates, especially in occupations that blend desk work with occasional field tasks. |\n",
-      "| **Better matching of talent to roles** | AI‑enhanced internal job‑matching platforms can surface openings that fit a worker’s skill set and preferences. | Helps employees find roles that better align with their strengths and career aspirations, potentially raising job satisfaction. |\n",
-      "\n",
-      "---\n",
-      "\n",
-      "## 2. Where the promise can fall short\n",
-      "\n",
-      "| Risk / Challenge | How it could affect middle‑class workers | Mitigation strategies |\n",
-      "|------------------|------------------------------------------|-----------------------|\n",
-      "| **Job displacement in “middle‑skill” roles** | Some positions (e.g., routine accounting, basic legal research, certain sales functions) may be partially or fully automated. | • Reskilling programs focused on AI‑augmented roles.
• Policies that encourage “human‑in‑the‑loop” designs.
• Transition assistance (e.g., wage subsidies during retraining). |\n", - "| **Increased performance pressure** | AI metrics can create “always‑on” monitoring, leading to stress or a culture of surveillance. | • Transparent KPI design.
• Legal safeguards on employee data use.
• Organizational norms that prioritize well‑being over raw productivity numbers. |\n", - "| **Skill polarization** | Workers who quickly adopt AI tools may surge ahead, widening gaps with those who lack digital literacy. | • Employer‑funded digital‑literacy bootcamps.
• Public‑sector initiatives for lifelong learning. |\n", - "| **Unequal access to AI tools** | Smaller firms or under‑resourced departments may lag, leaving their staff at a disadvantage. | • Cloud‑based AI services with tiered pricing.
• Government or industry consortiums that provide shared AI platforms. |\n", - "| **Bias and fairness issues** | AI systems trained on biased data can perpetuate discrimination in hiring, promotions, or task allocation. | • Auditing AI models for bias.
• Involving diverse stakeholder groups in model development. |\n", - "\n", - "---\n", - "\n", - "## 3. What determines whether AI will be a net positive?\n", - "\n", - "1. **Design philosophy** – Tools built to *augment* rather than replace humans tend to improve job quality. \n", - "2. **Organizational culture** – Companies that embed well‑being metrics, give employees control over AI outputs, and encourage experimentation see higher satisfaction. \n", - "3. **Policy environment** – Labor laws, data‑privacy regulations, and public‑investment in training shape the broader impact. \n", - "4. **Economic incentives** – When cost savings from AI are reinvested in wages, benefits, or reduced work hours, workers reap direct gains. \n", - "5. **Education & upskilling infrastructure** – Accessible, affordable pathways to acquire AI‑related competencies are crucial.\n", - "\n", - "---\n", - "\n", - "## 4. Practical steps for different stakeholders\n", - "\n", - "### For Employers\n", - "- **Pilot with a “human‑first” lens:** Start with AI assistants that handle low‑value tasks and measure employee satisfaction, not just efficiency.\n", - "- **Create a reskilling\n", - "\n", - "Question: How can Agentic AI enhance decision-making in finance?\n", - "Answer## Agentic AI — What It Is\n", - "\n", - "**Agentic AI** refers to autonomous, goal‑driven software agents that can perceive data, reason, act, and learn from feedback without constant human supervision. In finance, these agents can:\n", - "\n", - "* **Ingest** massive, heterogeneous data streams (market data, news, social media, macro‑economic indicators, client transactions, etc.).\n", - "* **Analyze** and **model** the data in real time.\n", - "* **Make** or **recommend** decisions (trade execution, credit approval, risk mitigation, etc.).\n", - "* **Adapt** their behavior as markets, regulations, or client preferences evolve.\n", - "\n", - "Below is a roadmap of how agentic AI can lift decision‑making across the major finance domains.\n", - "\n", - "---\n", - "\n", - "## 1. Investment & Portfolio Management \n", - "\n", - "| Agentic AI Capability | Concrete Benefits |\n", - "|-----------------------|--------------------|\n", - "| **Dynamic factor discovery** – agents continuously run feature‑engineering pipelines on price, fundamentals, alternative data (satellite imagery, ESG scores). | Detect emerging alpha sources faster than static factor models. |\n", - "| **Real‑time portfolio rebalancing** – agents monitor risk metrics (VaR, CVaR, drawdown) and market micro‑structure signals, then execute optimal trades via low‑latency APIs. | Reduce slippage, keep exposure aligned with risk limits, and capture intraday opportunities. |\n", - "| **Scenario‑based stress testing** – agents generate thousands of macro‑economic or market‑shock scenarios, re‑price portfolios, and flag tail‑risk breaches. | Proactive capital allocation and regulatory compliance (e.g., CCAR, Basel III). |\n", - "| **Personalized advisory** – agents model each client’s utility function, tax situation, and ESG preferences, then propose tailored asset mixes. | Higher client satisfaction, better retention, and upsell opportunities. |\n", - "\n", - "**Example:** A hedge‑fund agent monitors satellite‑derived oil‑tank inventory, combines it with futures order‑flow data, and automatically adjusts a crude‑oil position when inventory trends diverge from market expectations, achieving a 15 % Sharpe improvement over a six‑month back‑test.\n", - "\n", - "---\n", - "\n", - "## 2. Credit & Lending \n", - "\n", - "| Agentic AI Capability | Concrete Benefits |\n", - "|-----------------------|--------------------|\n", - "| **Alternative credit scoring** – agents ingest transaction histories, utility payments, mobile‑phone usage, and social‑media sentiment to build a multidimensional credit profile. | Expand credit access to under‑banked populations while maintaining low default rates. |\n", - "| **Dynamic underwriting rules** – agents continuously re‑train models as macro‑economic conditions shift, automatically tightening or loosening approval thresholds. | Keep loss‑given‑default (LGD) in line with real‑time risk. |\n", - "| **Early‑warning systems** – agents monitor borrower behavior (payment patterns, cash‑flow anomalies) and trigger proactive interventions (re‑structuring offers, fraud alerts). | Reduce delinquency and collection costs. |\n", - "| **Regulatory explainability** – agents generate human‑readable decision trees or counterfactual explanations for each credit decision, satisfying GDPR, ECOA, and local fairness mandates. | Faster audit cycles and lower compliance risk. |\n", - "\n", - "**Example:** A fintech lender deployed an agentic AI that combined bank‑statement cash‑flow analysis with real‑time employment‑verification APIs. The agent cut average approval time from 48 h to 5 min while keeping the default rate under 1 %—well below the industry benchmark.\n", - "\n", - "---\n", - "\n", - "## 3. Risk Management & Compliance \n", - "\n", - "| Agentic AI Capability | Concrete Benefits |\n", - "|-----------------------|--------------------|\n", - "| **Continuous market‑risk monitoring** – agents ingest price feeds, volatility surfaces, and cross‑asset correlations, updating VaR/CVaR in seconds. | Immediate detection of risk spikes and automated margin calls. |\n", - "| **Liquidity‑stress detection** – agents model order‑book depth, funding‑rate dynamics, and market‑maker behavior to forecast liquidity squeezes. | Pre‑emptive position scaling or hedging. |\n", - "| **Anti‑money‑laundering (AML) & fraud detection** – agents run graph‑based transaction networks, flagging anomalous patterns and automatically filing SARs (Suspicious Activity Reports). | Higher detection rates with fewer false positives. |\n", - "| **Regulatory change adaptation** – agents parse new regulator publications (e.g., SEC releases) using LLM‑based legal‑text understanding, then auto‑update internal policy engines. | Reduce manual rule‑coding effort and avoid compliance gaps. |\n", - "\n", - "**Example\n", - "\n", - "Uncostrained transduction done in 21.88448977470398 seconds\n" - ] - } - ], - "source": [ - "import time\n", - "\n", - "questions = [\n", - " \"What are the benefits of using Agentic AI for data workflows?\",\n", - " \"Will AI improve working conditions for the middle class?\",\n", - " \"How can Agentic AI enhance decision-making in finance?\",\n", - " # \"What risks should companies consider when adopting AI agents?\",\n", - " # \"Can AG objects integrate with existing data pipelines?\",\n", - " # \"Who won the latest FIFA worldcup\",\n", - "]\n", - "start = time.time()\n", - "answers = await (AG() << questions)\n", - "end = time.time()\n", - "\n", - "for question, answer in zip(questions, answers):\n", - " print(f\"Question: {question}\\nAnswer{answer}\\n\")\n", - "print(f\"Uncostrained transduction done in {end-start} seconds\")\n" - ] - }, - { - "cell_type": "markdown", - "id": "2758bd63", - "metadata": {}, - "source": [ - "### Transduction into Atype\n", - "\n", - "You can define a target schema with Pydantic (e.g., `Answer`) and transduce text into it. \n", - "The LLM output is parsed and validated into the fields `answer`, `justification`, and `confidence`. \n", - "Note that the output is more clean and organized, and the time required to execute the transduction is one order of magnitude lower. " - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "id": "e223405c", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2025-09-29 09:22:04.021 | DEBUG | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "87fb67d1eb394a88b300c99187a13160", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Output()" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
\n"
-      ],
-      "text/plain": []
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Typed transduction done in 2.947697162628174 seconds\n",
-      "Atype : \n",
-      "answer: 'Agentic AI brings several key benefits to data workflows: it automates repetitive\n",
-      "  tasks, adapts dynamically to changing data conditions, scales efficiently with growing\n",
-      "  data volumes, reduces manual effort and human error, accelerates insight generation,\n",
-      "  enables continuous learning and improvement, and facilitates seamless integration\n",
-      "  across heterogeneous data sources and tools.'\n",
-      "justification: \"Automation frees analysts from routine processing, while the agentic\\\n",
-      "  \\ nature allows the AI to make context\\u2011aware decisions (e.g., selecting appropriate\\\n",
-      "  \\ models or cleaning strategies) as data evolves. Scalability is achieved through\\\n",
-      "  \\ autonomous resource management, and the reduction of manual steps lowers the risk\\\n",
-      "  \\ of mistakes. Faster, self\\u2011optimizing pipelines deliver insights more quickly,\\\n",
-      "  \\ and the built\\u2011in learning loops let the system improve over time, ensuring\\\n",
-      "  \\ the workflow remains aligned with business objectives and integrates smoothly\\\n",
-      "  \\ with existing infrastructure.\"\n",
-      "confidence: 0.96\n",
-      "\n",
-      "answer: AI has the potential to improve working conditions for the middle class, but\n",
-      "  outcomes will depend on policy, implementation, and societal choices.\n",
-      "justification: \"AI can automate repetitive tasks, enable flexible work arrangements,\\\n",
-      "  \\ and increase productivity, which could lead to better work\\u2011life balance and\\\n",
-      "  \\ higher wages for middle\\u2011class jobs. However, without appropriate regulation\\\n",
-      "  \\ and investment in reskilling, AI may also displace workers or concentrate benefits\\\n",
-      "  \\ among higher\\u2011income groups, limiting its positive impact.\"\n",
-      "confidence: 0.68\n",
-      "\n",
-      "answer: \"Agentic AI brings several key benefits to data workflows:\\n1. **Automation\\\n",
-      "  \\ of repetitive tasks** \\u2013 It can autonomously extract, clean, transform, and\\\n",
-      "  \\ load data without constant human oversight.\\n2. **Dynamic decision\\u2011making**\\\n",
-      "  \\ \\u2013 The agent can choose the most appropriate processing steps based on data\\\n",
-      "  \\ characteristics, leading to more efficient pipelines.\\n3. **Self\\u2011optimization**\\\n",
-      "  \\ \\u2013 By monitoring performance metrics, the agent can iteratively refine its\\\n",
-      "  \\ own methods (e.g., selecting better models or tuning parameters) to improve speed\\\n",
-      "  \\ and accuracy.\\n4. **Scalability** \\u2013 Agentic systems can orchestrate distributed\\\n",
-      "  \\ resources, handling larger volumes of data as demand grows.\\n5. **Reduced human\\\n",
-      "  \\ error** \\u2013 Automated reasoning and validation steps lower the risk of manual\\\n",
-      "  \\ mistakes.\\n6. **Faster time\\u2011to\\u2011insight** \\u2013 Continuous, autonomous\\\n",
-      "  \\ processing accelerates the delivery of actionable analytics.\\n7. **Adaptability\\\n",
-      "  \\ to changing data** \\u2013 The agent can detect schema shifts or anomalies and\\\n",
-      "  \\ adjust the workflow on\\u2011the\\u2011fly, maintaining robustness.\\n8. **Resource\\\n",
-      "  \\ efficiency** \\u2013 By intelligently allocating compute and storage, the agent\\\n",
-      "  \\ minimizes waste and cost.\\nOverall, Agentic AI transforms data pipelines from\\\n",
-      "  \\ static, manually\\u2011managed sequences into intelligent, self\\u2011governing\\\n",
-      "  \\ systems that improve productivity, reliability, and insight generation.\"\n",
-      "justification: \"These benefits stem from the core capabilities of Agentic AI: autonomous\\\n",
-      "  \\ reasoning, goal\\u2011directed planning, and the ability to monitor and adjust\\\n",
-      "  \\ its own actions. When applied to data workflows, these capabilities translate\\\n",
-      "  \\ directly into automation, optimization, and adaptability, which are the primary\\\n",
-      "  \\ drivers of efficiency and quality in modern data engineering.\"\n",
-      "confidence: 0.96\n",
-      "\n",
-      "\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "'Atype : \\nanswer: \\'Agentic AI brings several key benefits to data workflows: it automates repetitive\\n  tasks, adapts dynamically to changing data conditions, scales efficiently with growing\\n  data volumes, reduces manual effort and human error, accelerates insight generation,\\n  enables continuous learning and improvement, and facilitates seamless integration\\n  across heterogeneous data sources and tools.\\'\\njustification: \"Automation frees analysts from routine processing, while the agentic\\\\\\n  \\\\ nature allows the AI to make context\\\\u2011aware decisions (e.g., selecting appropriate\\\\\\n  \\\\ models or cleaning strategies) as data evolves. Scalability is achieved through\\\\\\n  \\\\ autonomous resource management, and the reduction of manual steps lowers the risk\\\\\\n  \\\\ of mistakes. Faster, self\\\\u2011optimizing pipelines deliver insights more quickly,\\\\\\n  \\\\ and the built\\\\u2011in learning loops let the system improve over time, ensuring\\\\\\n  \\\\ the workflow remains aligned with business objectives and integrates smoothly\\\\\\n  \\\\ with existing infrastructure.\"\\nconfidence: 0.96\\n\\nanswer: AI has the potential to improve working conditions for the middle class, but\\n  outcomes will depend on policy, implementation, and societal choices.\\njustification: \"AI can automate repetitive tasks, enable flexible work arrangements,\\\\\\n  \\\\ and increase productivity, which could lead to better work\\\\u2011life balance and\\\\\\n  \\\\ higher wages for middle\\\\u2011class jobs. However, without appropriate regulation\\\\\\n  \\\\ and investment in reskilling, AI may also displace workers or concentrate benefits\\\\\\n  \\\\ among higher\\\\u2011income groups, limiting its positive impact.\"\\nconfidence: 0.68\\n\\nanswer: \"Agentic AI brings several key benefits to data workflows:\\\\n1. **Automation\\\\\\n  \\\\ of repetitive tasks** \\\\u2013 It can autonomously extract, clean, transform, and\\\\\\n  \\\\ load data without constant human oversight.\\\\n2. **Dynamic decision\\\\u2011making**\\\\\\n  \\\\ \\\\u2013 The agent can choose the most appropriate processing steps based on data\\\\\\n  \\\\ characteristics, leading to more efficient pipelines.\\\\n3. **Self\\\\u2011optimization**\\\\\\n  \\\\ \\\\u2013 By monitoring performance metrics, the agent can iteratively refine its\\\\\\n  \\\\ own methods (e.g., selecting better models or tuning parameters) to improve speed\\\\\\n  \\\\ and accuracy.\\\\n4. **Scalability** \\\\u2013 Agentic systems can orchestrate distributed\\\\\\n  \\\\ resources, handling larger volumes of data as demand grows.\\\\n5. **Reduced human\\\\\\n  \\\\ error** \\\\u2013 Automated reasoning and validation steps lower the risk of manual\\\\\\n  \\\\ mistakes.\\\\n6. **Faster time\\\\u2011to\\\\u2011insight** \\\\u2013 Continuous, autonomous\\\\\\n  \\\\ processing accelerates the delivery of actionable analytics.\\\\n7. **Adaptability\\\\\\n  \\\\ to changing data** \\\\u2013 The agent can detect schema shifts or anomalies and\\\\\\n  \\\\ adjust the workflow on\\\\u2011the\\\\u2011fly, maintaining robustness.\\\\n8. **Resource\\\\\\n  \\\\ efficiency** \\\\u2013 By intelligently allocating compute and storage, the agent\\\\\\n  \\\\ minimizes waste and cost.\\\\nOverall, Agentic AI transforms data pipelines from\\\\\\n  \\\\ static, manually\\\\u2011managed sequences into intelligent, self\\\\u2011governing\\\\\\n  \\\\ systems that improve productivity, reliability, and insight generation.\"\\njustification: \"These benefits stem from the core capabilities of Agentic AI: autonomous\\\\\\n  \\\\ reasoning, goal\\\\u2011directed planning, and the ability to monitor and adjust\\\\\\n  \\\\ its own actions. When applied to data workflows, these capabilities translate\\\\\\n  \\\\ directly into automation, optimization, and adaptability, which are the primary\\\\\\n  \\\\ drivers of efficiency and quality in modern data engineering.\"\\nconfidence: 0.96\\n\\n'"
-      ]
-     },
-     "execution_count": 24,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "# Define a Pydantic model for a structured answer\n",
-    "class Answer(BaseModel):\n",
-    "    # The main response text\n",
-    "    answer: Optional[str] = None\n",
-    "    # An explanation or reasoning behind the answer\n",
-    "    justification: Optional[str] = None\n",
-    "    # A numeric confidence score (e.g. from 0.0 to 1.0)\n",
-    "    confidence: Optional[float] = None\n",
-    "\n",
-    "# Transduce a natural language question into the structured Answer schema\n",
-    "start= time.time()\n",
-    "answers = await (AG(atype=Answer) << questions)\n",
-    "end= time.time()\n",
-    "print(f\"Typed transduction done in {end-start} seconds\")\n",
-    "answers.pretty_print()"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "12651794",
-   "metadata": {},
-   "source": [
-    "### Transduction Between AGs\n",
-    "\n",
-    "You can control transduction more precisely by converting **from one AG to another**:\n",
-    "- The **source AG** provides the input states (rendered via the prompt).\n",
-    "- The **target AG** defines the output schema and validation.\n",
-    "- Agentics renders each source state → sends it to the LLM → parses into the target type.\n",
-    "\n",
-    "This pattern is ideal when you want consistent, structured outputs from heterogeneous inputs while keeping prompts and schema separate."
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "db533ce4",
-   "metadata": {},
-   "source": [
-    "### Transduction Between AGs  \n",
-    "Here we convert product reviews (`ProductReview`) into sentiment summaries (`SentimentSummary`).  \n",
-    "The source AG provides the reviews, and the target AG enforces structured outputs (positive/neutral/negative with a reason).  "
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 25,
-   "id": "ddc0261e",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "2025-09-29 09:23:38.900 | DEBUG    | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n",
-      "2025-09-29 09:23:38.901 | DEBUG    | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n"
-     ]
-    },
-    {
-     "data": {
-      "application/vnd.jupyter.widget-view+json": {
-       "model_id": "acd16274808b49ae8144d883507a66ed",
-       "version_major": 2,
-       "version_minor": 0
-      },
-      "text/plain": [
-       "Output()"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/html": [
-       "
\n"
-      ],
-      "text/plain": []
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Atype : \n",
-      "customer_sentiment: positive\n",
-      "reason: The review praises excellent quality and fast delivery.\n",
-      "\n",
-      "customer_sentiment: negative\n",
-      "reason: packaging was damaged\n",
-      "\n",
-      "customer_sentiment: negative\n",
-      "reason: Product broke after one use\n",
-      "\n",
-      "\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "\"Atype : \\ncustomer_sentiment: positive\\nreason: The review praises excellent quality and fast delivery.\\n\\ncustomer_sentiment: negative\\nreason: packaging was damaged\\n\\ncustomer_sentiment: negative\\nreason: Product broke after one use\\n\\n\""
-      ]
-     },
-     "execution_count": 25,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "from typing import Optional, Literal\n",
-    "from pydantic import BaseModel\n",
-    "from agentics import AG\n",
-    "\n",
-    "# Source schema: product reviews\n",
-    "class ProductReview(BaseModel):\n",
-    "    reviewer: Optional[str] = None\n",
-    "    text: Optional[str] = None\n",
-    "    stars: Optional[int] = None\n",
-    "\n",
-    "# Target schema: summarized sentiment\n",
-    "class SentimentSummary(BaseModel):\n",
-    "    customer_sentiment: Optional[Literal[\"positive\", \"neutral\", \"negative\"]] = None\n",
-    "    reason: Optional[str] = None\n",
-    "\n",
-    "# Example reviews\n",
-    "reviews = [\n",
-    "    ProductReview(reviewer=\"Alice\", text=\"Excellent quality and fast delivery!\", stars=5),\n",
-    "    ProductReview(reviewer=\"Bob\", text=\"Okay, but packaging was damaged\", stars=3),\n",
-    "    ProductReview(reviewer=\"Carol\", text=\"Terrible, broke after one use\", stars=1),\n",
-    "]\n",
-    "\n",
-    "# Create source and target AGs\n",
-    "source = AG(atype=ProductReview, states=reviews)\n",
-    "target = AG(atype=SentimentSummary)\n",
-    "\n",
-    "# Transduce reviews into sentiment summaries\n",
-    "sentiments = await (target << source)\n",
-    "sentiments.pretty_print()"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "4c9bd197",
-   "metadata": {},
-   "source": [
-    "### Self-Transduction  \n",
-    "\n",
-    "You can transduce within the same AG type by selecting different subsets of fields.  \n",
-    "This is useful for projecting, comparing, or enriching dataframes and state graphs without changing the original AG.  "
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 27,
-   "id": "26539ef1",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "2025-09-29 09:25:26.573 | DEBUG    | agentics.core.agentics:from_csv:303 - Importing Agentics of type Movie from CSV data/movies.csv\n",
-      "2025-09-29 09:25:26.574 | DEBUG    | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n"
-     ]
-    },
-    {
-     "data": {
-      "application/vnd.jupyter.widget-view+json": {
-       "model_id": "96b3534f93164185a0e944c862591f74",
-       "version_major": 2,
-       "version_minor": 0
-      },
-      "text/plain": [
-       "Output()"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/html": [
-       "
\n"
-      ],
-      "text/plain": []
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Atype : \n",
-      "movie_name: Pulp Fiction\n",
-      "genre: Science Fiction\n",
-      "description: A burger-loving hit man, his philosophical partner, a drug-addled gangster's\n",
-      "  moll and a washed-up boxer converge in this sprawling, comedic crime caper. Their\n",
-      "  adventures unfurl in three stories that ingeniously trip back and forth in time.\n",
-      "\n",
-      "movie_name: Your Name.\n",
-      "genre: Science Fiction\n",
-      "description: \"High schoolers Mitsuha and Taki are complete strangers living separate\\\n",
-      "  \\ lives. But one night, they suddenly switch places. Mitsuha wakes up in Taki\\u2019\\\n",
-      "  s body, and he in hers. This bizarre occurrence continues to happen randomly, and\\\n",
-      "  \\ the two must adjust their lives around each other.\"\n",
-      "\n",
-      "movie_name: 'The Lord of the Rings: The Return of the King'\n",
-      "genre: War drama\n",
-      "description: \"As armies mass for a final battle that will decide the fate of the world--and\\\n",
-      "  \\ powerful, ancient forces of Light and Dark compete to determine the outcome--one\\\n",
-      "  \\ member of the Fellowship of the Ring is revealed as the noble heir to the throne\\\n",
-      "  \\ of the Kings of Men. Yet, the sole hope for triumph over evil lies with a brave\\\n",
-      "  \\ hobbit, Frodo, who, accompanied by his loyal friend Sam and the hideous, wretched\\\n",
-      "  \\ Gollum, ventures deep into the very dark heart of Mordor on his seemingly impossible\\\n",
-      "  \\ quest to destroy the Ring of Power.\\u200B\"\n",
-      "\n",
-      "movie_name: Forrest Gump\n",
-      "genre: Drama\n",
-      "description: \"A man with a low IQ has accomplished great things in his life and been\\\n",
-      "  \\ present during significant historic events\\u2014in each case, far exceeding what\\\n",
-      "  \\ anyone imagined he could do. But despite all he has achieved, his one true love\\\n",
-      "  \\ eludes him.\"\n",
-      "\n",
-      "movie_name: The Good, the Bad and the Ugly\n",
-      "genre: Western\n",
-      "description: \"While the Civil War rages on between the Union and the Confederacy,\\\n",
-      "  \\ three men \\u2013 a quiet loner, a ruthless hitman, and a Mexican bandit \\u2013\\\n",
-      "  \\ comb the American Southwest in search of a strongbox containing $200,000 in stolen\\\n",
-      "  \\ gold.\"\n",
-      "\n",
-      "movie_name: Seven Samurai\n",
-      "genre: Adventure drama\n",
-      "description: A samurai answers a village's request for protection after he falls on\n",
-      "  hard times. The town needs protection from bandits, so the samurai gathers six others\n",
-      "  to help him teach the people how to defend themselves, and the villagers provide\n",
-      "  the soldiers with food.\n",
-      "\n",
-      "movie_name: GoodFellas\n",
-      "genre: Crime, Drama\n",
-      "description: The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid\n",
-      "  who is adopted by neighbourhood gangsters at an early age and climbs the ranks of\n",
-      "  a Mafia family under the guidance of Jimmy Conway.\n",
-      "\n",
-      "movie_name: Interstellar\n",
-      "genre: War drama\n",
-      "description: The adventures of a group of explorers who make use of a newly discovered\n",
-      "  wormhole to surpass the limitations on human space travel and conquer the vast distances\n",
-      "  involved in an interstellar voyage.\n",
-      "\n",
-      "movie_name: Grave of the Fireflies\n",
-      "genre: Drama\n",
-      "description: In the final months of World War II, 14-year-old Seita and his sister\n",
-      "  Setsuko are orphaned when their mother is killed during an air raid in Kobe, Japan.\n",
-      "  After a falling out with their aunt, they move into an abandoned bomb shelter. With\n",
-      "  no surviving relatives and their emergency rations depleted, Seita and Setsuko struggle\n",
-      "  to survive.\n",
-      "\n",
-      "movie_name: Life Is Beautiful\n",
-      "genre: Comedy-drama\n",
-      "description: A touching story of an Italian book seller of Jewish ancestry who lives\n",
-      "  in his own little fairy tale. His creative and happy life would come to an abrupt\n",
-      "  halt when his entire family is deported to a concentration camp during World War\n",
-      "  II. While locked up he tries to convince his son that the whole thing is just a\n",
-      "  game.\n",
-      "\n",
-      "\n",
-      "Atype : \n",
-      "movie_name: Pulp Fiction\n",
-      "genre: Science Fiction\n",
-      "description: A burger-loving hit man, his philosophical partner, a drug-addled gangster's\n",
-      "  moll and a washed-up boxer converge in this sprawling, comedic crime caper. Their\n",
-      "  adventures unfurl in three stories that ingeniously trip back and forth in time.\n",
-      "\n",
-      "movie_name: Your Name.\n",
-      "genre: Science Fiction\n",
-      "description: \"High schoolers Mitsuha and Taki are complete strangers living separate\\\n",
-      "  \\ lives. But one night, they suddenly switch places. Mitsuha wakes up in Taki\\u2019\\\n",
-      "  s body, and he in hers. This bizarre occurrence continues to happen randomly, and\\\n",
-      "  \\ the two must adjust their lives around each other.\"\n",
-      "\n",
-      "movie_name: 'The Lord of the Rings: The Return of the King'\n",
-      "genre: War drama\n",
-      "description: \"As armies mass for a final battle that will decide the fate of the world--and\\\n",
-      "  \\ powerful, ancient forces of Light and Dark compete to determine the outcome--one\\\n",
-      "  \\ member of the Fellowship of the Ring is revealed as the noble heir to the throne\\\n",
-      "  \\ of the Kings of Men. Yet, the sole hope for triumph over evil lies with a brave\\\n",
-      "  \\ hobbit, Frodo, who, accompanied by his loyal friend Sam and the hideous, wretched\\\n",
-      "  \\ Gollum, ventures deep into the very dark heart of Mordor on his seemingly impossible\\\n",
-      "  \\ quest to destroy the Ring of Power.\\u200B\"\n",
-      "\n",
-      "movie_name: Forrest Gump\n",
-      "genre: Drama\n",
-      "description: \"A man with a low IQ has accomplished great things in his life and been\\\n",
-      "  \\ present during significant historic events\\u2014in each case, far exceeding what\\\n",
-      "  \\ anyone imagined he could do. But despite all he has achieved, his one true love\\\n",
-      "  \\ eludes him.\"\n",
-      "\n",
-      "movie_name: The Good, the Bad and the Ugly\n",
-      "genre: Western\n",
-      "description: \"While the Civil War rages on between the Union and the Confederacy,\\\n",
-      "  \\ three men \\u2013 a quiet loner, a ruthless hitman, and a Mexican bandit \\u2013\\\n",
-      "  \\ comb the American Southwest in search of a strongbox containing $200,000 in stolen\\\n",
-      "  \\ gold.\"\n",
-      "\n",
-      "movie_name: Seven Samurai\n",
-      "genre: Adventure drama\n",
-      "description: A samurai answers a village's request for protection after he falls on\n",
-      "  hard times. The town needs protection from bandits, so the samurai gathers six others\n",
-      "  to help him teach the people how to defend themselves, and the villagers provide\n",
-      "  the soldiers with food.\n",
-      "\n",
-      "movie_name: GoodFellas\n",
-      "genre: Crime, Drama\n",
-      "description: The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid\n",
-      "  who is adopted by neighbourhood gangsters at an early age and climbs the ranks of\n",
-      "  a Mafia family under the guidance of Jimmy Conway.\n",
-      "\n",
-      "movie_name: Interstellar\n",
-      "genre: War drama\n",
-      "description: The adventures of a group of explorers who make use of a newly discovered\n",
-      "  wormhole to surpass the limitations on human space travel and conquer the vast distances\n",
-      "  involved in an interstellar voyage.\n",
-      "\n",
-      "movie_name: Grave of the Fireflies\n",
-      "genre: Drama\n",
-      "description: In the final months of World War II, 14-year-old Seita and his sister\n",
-      "  Setsuko are orphaned when their mother is killed during an air raid in Kobe, Japan.\n",
-      "  After a falling out with their aunt, they move into an abandoned bomb shelter. With\n",
-      "  no surviving relatives and their emergency rations depleted, Seita and Setsuko struggle\n",
-      "  to survive.\n",
-      "\n",
-      "movie_name: Life Is Beautiful\n",
-      "genre: Comedy-drama\n",
-      "description: A touching story of an Italian book seller of Jewish ancestry who lives\n",
-      "  in his own little fairy tale. His creative and happy life would come to an abrupt\n",
-      "  halt when his entire family is deported to a concentration camp during World War\n",
-      "  II. While locked up he tries to convince his son that the whole thing is just a\n",
-      "  game.\n",
-      "\n",
-      "\n"
-     ]
-    }
-   ],
-   "source": [
-    "movies = AG.from_csv(base / \"data/movies.csv\",atype=Movie)\n",
-    "movies.filter_states(start =10, end =20)\n",
-    "\n",
-    "self_transductions = await movies.self_transduction([\"movie_name\",\"description\"],[\"genre\"])\n",
-    "print(self_transductions.pretty_print())"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "24dacd95",
-   "metadata": {},
-   "source": [
-    "### Customizing Transduction  \n",
-    "\n",
-    "You can fine-tune how logical transduction works by configuring:  \n",
-    "\n",
-    "- **LLMs** – choose the underlying language model to run the transduction.  \n",
-    "- **Instructions** – add task-specific guidance for the LLM.  \n",
-    "- **Prompt Templates** – control how inputs are rendered into prompts.  \n",
-    "- **Few-Shot Examples** – provide examples to steer the model’s behavior.  \n",
-    "- **Verbose Options** – enable detailed logging and debug outputs.  "
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "35f475de",
-   "metadata": {},
-   "source": [
-    "#### Task instructions\n",
-    "The example below illustrate how to provide a llm and task specific instructions to transduction"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 12,
-   "id": "e1b354b2",
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "application/vnd.jupyter.widget-view+json": {
-       "model_id": "8764c79429644514a78cf83e889f63e1",
-       "version_major": 2,
-       "version_minor": 0
-      },
-      "text/plain": [
-       "Output()"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/html": [
-       "
\n"
-      ],
-      "text/plain": []
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Atype : \n",
-      "answer: \"Le aziende devono considerare diversi rischi quando adottano agenti IA, tra\\\n",
-      "  \\ cui:\\n1. **Bias e discriminazione**: gli algoritmi possono riflettere pregiudizi\\\n",
-      "  \\ presenti nei dati di addestramento, portando a decisioni ingiuste.\\n2. **Privacy\\\n",
-      "  \\ e protezione dei dati**: gli agenti IA spesso elaborano grandi quantit\\xE0 di\\\n",
-      "  \\ informazioni sensibili, aumentando il rischio di violazioni o uso improprio.\\n\\\n",
-      "  3. **Sicurezza e vulnerabilit\\xE0**: gli agenti possono essere bersaglio di attacchi\\\n",
-      "  \\ informatici o manipolazioni (ad es. avvelenamento dei dati), compromettendo l\\u2019\\\n",
-      "  integrit\\xE0 dei sistemi.\\n4. **Responsabilit\\xE0 legale**: \\xE8 difficile attribuire\\\n",
-      "  \\ la responsabilit\\xE0 per errori o danni causati da decisioni automatizzate.\\n\\\n",
-      "  5. **Trasparenza e spiegabilit\\xE0**: la \\u201Cblack box\\u201D degli algoritmi pu\\xF2\\\n",
-      "  \\ ostacolare la comprensione delle decisioni, creando sfiducia tra stakeholder e\\\n",
-      "  \\ autorit\\xE0 di regolamentazione.\\n6. **Impatto occupazionale**: l\\u2019automazione\\\n",
-      "  \\ pu\\xF2 portare a riduzioni di personale o a necessit\\xE0 di riqualificazione,\\\n",
-      "  \\ con conseguenze sociali.\\n7. **Conformit\\xE0 normativa**: le normative in evoluzione\\\n",
-      "  \\ (es. GDPR, AI Act) richiedono adeguamenti continui per evitare sanzioni.\\n8. **Dipendenza\\\n",
-      "  \\ tecnologica**: affidarsi eccessivamente a soluzioni IA pu\\xF2 ridurre la resilienza\\\n",
-      "  \\ operativa in caso di guasti o interruzioni.\\n9. **Etica e reputazione**: decisioni\\\n",
-      "  \\ non etiche o percepite come tali possono danneggiare la reputazione aziendale.\\n\\\n",
-      "  10. **Costi di implementazione e manutenzione**: investimenti iniziali elevati e\\\n",
-      "  \\ costi continui per aggiornamenti, monitoraggio e governance.\\nConsiderare questi\\\n",
-      "  \\ rischi permette di pianificare strategie di mitigazione, governance e controllo\\\n",
-      "  \\ adeguate prima di integrare gli agenti IA nei processi aziendali.\"\n",
-      "justification: \"Ho elencato i rischi pi\\xF9 rilevanti basandomi su studi di settore,\\\n",
-      "  \\ linee guida etiche e normative vigenti, nonch\\xE9 sulle preoccupazioni comuni\\\n",
-      "  \\ espresse da esperti di IA e responsabili della compliance. Ogni punto \\xE8 accompagnato\\\n",
-      "  \\ da una breve spiegazione per evidenziare la sua importanza pratica per le aziende.\"\n",
-      "confidence: 0.98\n",
-      "\n",
-      "answer: \"S\\xEC, l'IA ha il potenziale di migliorare le condizioni di lavoro per la\\\n",
-      "  \\ classe media, ma il risultato dipender\\xE0 da come verranno gestite le politiche,\\\n",
-      "  \\ la formazione e la distribuzione dei benefici.\"\n",
-      "justification: \"L'automazione pu\\xF2 sollevare i lavoratori da compiti ripetitivi\\\n",
-      "  \\ e pericolosi, aumentando la produttivit\\xE0 e consentendo una maggiore flessibilit\\xE0\\\n",
-      "  \\ oraria. Tuttavia, se i guadagni di produttivit\\xE0 non vengono redistribuiti equamente\\\n",
-      "  \\ o se la formazione non \\xE8 adeguata, i vantaggi potrebbero non raggiungere la\\\n",
-      "  \\ classe media. Pertanto, l'impatto positivo \\xE8 possibile ma non garantito.\"\n",
-      "confidence: 0.78\n",
-      "\n",
-      "answer: \"Le aziende devono considerare diversi rischi quando adottano agenti IA, tra\\\n",
-      "  \\ cui: \\n1. **Bias e discriminazione** \\u2013 gli algoritmi possono riprodurre o\\\n",
-      "  \\ amplificare pregiudizi presenti nei dati di addestramento.\\n2. **Privacy e protezione\\\n",
-      "  \\ dei dati** \\u2013 l'uso di dati sensibili pu\\xF2 violare normative come GDPR se\\\n",
-      "  \\ non gestito correttamente.\\n3. **Sicurezza e vulnerabilit\\xE0** \\u2013 gli agenti\\\n",
-      "  \\ IA possono essere bersaglio di attacchi adversariali o manipolazioni.\\n4. **Responsabilit\\xE0\\\n",
-      "  \\ legale** \\u2013 \\xE8 difficile attribuire la responsabilit\\xE0 per decisioni errate\\\n",
-      "  \\ o dannose prese dall'IA.\\n5. **Trasparenza e spiegabilit\\xE0** \\u2013 la mancanza\\\n",
-      "  \\ di spiegazioni comprensibili pu\\xF2 ostacolare la fiducia degli utenti e la conformit\\xE0\\\n",
-      "  \\ normativa.\\n6. **Impatto occupazionale** \\u2013 l'automazione pu\\xF2 portare a\\\n",
-      "  \\ riduzioni di posti di lavoro o a necessit\\xE0 di riqualificazione del personale.\\n\\\n",
-      "  7. **Costi di implementazione e manutenzione** \\u2013 l'integrazione, l'addestramento\\\n",
-      "  \\ continuo e il monitoraggio richiedono risorse significative.\\n8. **Allineamento\\\n",
-      "  \\ con gli obiettivi aziendali** \\u2013 gli agenti potrebbero perseguire obiettivi\\\n",
-      "  \\ diversi da quelli strategici dell'impresa se non adeguatamente configurati.\"\n",
-      "justification: \"Questi rischi sono stati identificati da studi accademici, linee guida\\\n",
-      "  \\ di autorit\\xE0 di regolamentazione (es. EU AI Act) e da esperienze pratiche di\\\n",
-      "  \\ aziende che hanno implementato soluzioni IA. Il bias pu\\xF2 portare a decisioni\\\n",
-      "  \\ ingiuste, la privacy \\xE8 regolamentata da leggi stringenti, la sicurezza \\xE8\\\n",
-      "  \\ cruciale per evitare manipolazioni, e la responsabilit\\xE0 legale \\xE8 ancora\\\n",
-      "  \\ in evoluzione. La trasparenza \\xE8 richiesta per la fiducia e la conformit\\xE0\\\n",
-      "  , mentre gli impatti occupazionali e i costi influenzano la sostenibilit\\xE0 economica\\\n",
-      "  \\ del progetto. L'allineamento strategico garantisce che l'IA supporti, non ostacoli,\\\n",
-      "  \\ gli obiettivi di business.\"\n",
-      "confidence: 0.98\n",
-      "\n",
-      "answer: \"Le aziende devono considerare diversi rischi quando adottano agenti IA, tra\\\n",
-      "  \\ cui:\\n1. **Bias e discriminazione**: gli algoritmi possono riflettere pregiudizi\\\n",
-      "  \\ presenti nei dati di addestramento, portando a decisioni ingiuste.\\n2. **Privacy\\\n",
-      "  \\ e protezione dei dati**: l'uso di IA pu\\xF2 comportare la raccolta e l'elaborazione\\\n",
-      "  \\ di grandi quantit\\xE0 di dati sensibili, con il rischio di violazioni.\\n3. **Sicurezza\\\n",
-      "  \\ e vulnerabilit\\xE0**: gli agenti IA possono essere bersaglio di attacchi informatici\\\n",
-      "  \\ o manipolazioni (ad es. avvelenamento dei dati).\\n4. **Responsabilit\\xE0 legale**:\\\n",
-      "  \\ \\xE8 spesso difficile attribuire la responsabilit\\xE0 per errori o danni causati\\\n",
-      "  \\ da decisioni automatizzate.\\n5. **Trasparenza e spiegabilit\\xE0**: la \\u201Cblack\\\n",
-      "  \\ box\\u201D degli algoritmi pu\\xF2 ostacolare la comprensione delle decisioni e\\\n",
-      "  \\ la fiducia degli stakeholder.\\n6. **Impatto occupazionale**: l\\u2019automazione\\\n",
-      "  \\ pu\\xF2 portare a riduzioni di posti di lavoro o a necessit\\xE0 di riqualificazione\\\n",
-      "  \\ del personale.\\n7. **Conformit\\xE0 normativa**: le normative in evoluzione (es.\\\n",
-      "  \\ GDPR, AI Act) richiedono adeguamenti continui.\\n8. **Dipendenza tecnologica**:\\\n",
-      "  \\ affidarsi eccessivamente a soluzioni IA pu\\xF2 ridurre la resilienza operativa\\\n",
-      "  \\ in caso di guasti.\\n9. **Etica e reputazione**: decisioni non etiche o percepite\\\n",
-      "  \\ come tali possono danneggiare la reputazione aziendale.\\n10. **Costi di implementazione\\\n",
-      "  \\ e manutenzione**: investimenti iniziali e costi continui per aggiornamenti, monitoraggio\\\n",
-      "  \\ e governance possono superare le aspettative.\"\n",
-      "justification: \"Questi rischi sono stati identificati da studi accademici, linee guida\\\n",
-      "  \\ di autorit\\xE0 di regolamentazione e best practice del settore. Il bias e la privacy\\\n",
-      "  \\ sono tra i pi\\xF9 citati perch\\xE9 derivano direttamente dalla natura dei dati\\\n",
-      "  \\ su cui gli agenti IA sono addestrati. La sicurezza, la responsabilit\\xE0 legale\\\n",
-      "  \\ e la trasparenza sono fondamentali per garantire che le decisioni automatizzate\\\n",
-      "  \\ siano affidabili e conformi alle leggi. Inoltre, gli aspetti etici, occupazionali\\\n",
-      "  \\ e di reputazione influenzano direttamente la sostenibilit\\xE0 a lungo termine\\\n",
-      "  \\ dell'adozione dell'IA nelle imprese.\"\n",
-      "confidence: 0.97\n",
-      "\n",
-      "answer: \"Le aziende devono valutare diversi rischi quando adottano agenti IA, tra\\\n",
-      "  \\ cui:\\n1. **Bias e discriminazione**: gli algoritmi possono riprodurre o amplificare\\\n",
-      "  \\ pregiudizi presenti nei dati di addestramento, portando a decisioni ingiuste.\\n\\\n",
-      "  2. **Privacy e sicurezza dei dati**: gli agenti IA trattano grandi quantit\\xE0 di\\\n",
-      "  \\ informazioni sensibili; una gestione inadeguata pu\\xF2 provocare violazioni della\\\n",
-      "  \\ privacy o fughe di dati.\\n3. **Mancanza di trasparenza (black\\u2011box)**: la\\\n",
-      "  \\ difficolt\\xE0 di spiegare come l'IA arriva a una determinata conclusione ostacola\\\n",
-      "  \\ la fiducia e la responsabilit\\xE0.\\n4. **Conformit\\xE0 normativa**: le normative\\\n",
-      "  \\ emergenti sull'IA (es. GDPR, AI Act) impongono requisiti di trasparenza, audit\\\n",
-      "  \\ e gestione del rischio.\\n5. **Affidabilit\\xE0 operativa**: errori o malfunzionamenti\\\n",
-      "  \\ dell'agente possono interrompere processi critici o generare risultati errati.\\n\\\n",
-      "  6. **Dipendenza eccessiva**: affidarsi troppo all'IA pu\\xF2 ridurre le competenze\\\n",
-      "  \\ umane e rendere l'organizzazione vulnerabile a guasti dell'IA.\\n7. **Impatto etico\\\n",
-      "  \\ e reputazionale**: decisioni automatizzate controverse possono danneggiare la\\\n",
-      "  \\ reputazione aziendale.\\n8. **Sicurezza contro attacchi avversari**: gli agenti\\\n",
-      "  \\ IA possono essere manipolati tramite input avversari (adversarial attacks) per\\\n",
-      "  \\ produrre output dannosi.\\n9. **Evoluzione del modello (model drift)**: i modelli\\\n",
-      "  \\ possono degradarsi nel tempo se i dati di produzione cambiano, richiedendo monitoraggio\\\n",
-      "  \\ continuo.\\n10. **Costi e complessit\\xE0 di integrazione**: l'implementazione pu\\xF2\\\n",
-      "  \\ richiedere investimenti significativi e integrazioni complesse con i sistemi legacy.\\n\\\n",
-      "  11. **Responsabilit\\xE0 legale**: determinare chi \\xE8 responsabile per decisioni\\\n",
-      "  \\ errate dell'IA pu\\xF2 essere complesso.\\nConsiderare questi rischi permette di\\\n",
-      "  \\ pianificare mitigazioni, governance adeguata e un'adozione responsabile dell'IA.\"\n",
-      "justification: \"Questi rischi sono stati identificati da studi accademici, linee guida\\\n",
-      "  \\ di autorit\\xE0 di regolamentazione (es. EU AI Act) e pratiche di settore. Ogni\\\n",
-      "  \\ punto evidenzia una vulnerabilit\\xE0 concreta che pu\\xF2 avere impatti legali,\\\n",
-      "  \\ finanziari, operativi o reputazionali per le aziende, rendendo necessario un'analisi\\\n",
-      "  \\ preventiva e misure di mitigazione.\"\n",
-      "confidence: 0.96\n",
-      "\n",
-      "answer: L'Argentina ha vinto l'ultima Coppa del Mondo FIFA (2022).\n",
-      "justification: L'Argentina ha battuto la Francia nella finale del 2022, vincendo ai\n",
-      "  rigori 4-2 dopo un pareggio 3-3 nei tempi regolamentari e supplementari.\n",
-      "confidence: 0.99\n",
-      "\n",
-      "\n",
-      "Atype : \n",
-      "answer: \"Le aziende devono considerare diversi rischi quando adottano agenti IA, tra\\\n",
-      "  \\ cui:\\n1. **Bias e discriminazione**: gli algoritmi possono riflettere pregiudizi\\\n",
-      "  \\ presenti nei dati di addestramento, portando a decisioni ingiuste.\\n2. **Privacy\\\n",
-      "  \\ e protezione dei dati**: gli agenti IA spesso elaborano grandi quantit\\xE0 di\\\n",
-      "  \\ informazioni sensibili, aumentando il rischio di violazioni o uso improprio.\\n\\\n",
-      "  3. **Sicurezza e vulnerabilit\\xE0**: gli agenti possono essere bersaglio di attacchi\\\n",
-      "  \\ informatici o manipolazioni (ad es. avvelenamento dei dati), compromettendo l\\u2019\\\n",
-      "  integrit\\xE0 dei sistemi.\\n4. **Responsabilit\\xE0 legale**: \\xE8 difficile attribuire\\\n",
-      "  \\ la responsabilit\\xE0 per errori o danni causati da decisioni automatizzate.\\n\\\n",
-      "  5. **Trasparenza e spiegabilit\\xE0**: la \\u201Cblack box\\u201D degli algoritmi pu\\xF2\\\n",
-      "  \\ ostacolare la comprensione delle decisioni, creando sfiducia tra stakeholder e\\\n",
-      "  \\ autorit\\xE0 di regolamentazione.\\n6. **Impatto occupazionale**: l\\u2019automazione\\\n",
-      "  \\ pu\\xF2 portare a riduzioni di personale o a necessit\\xE0 di riqualificazione,\\\n",
-      "  \\ con conseguenze sociali.\\n7. **Conformit\\xE0 normativa**: le normative in evoluzione\\\n",
-      "  \\ (es. GDPR, AI Act) richiedono adeguamenti continui per evitare sanzioni.\\n8. **Dipendenza\\\n",
-      "  \\ tecnologica**: affidarsi eccessivamente a soluzioni IA pu\\xF2 ridurre la resilienza\\\n",
-      "  \\ operativa in caso di guasti o interruzioni.\\n9. **Etica e reputazione**: decisioni\\\n",
-      "  \\ non etiche o percepite come tali possono danneggiare la reputazione aziendale.\\n\\\n",
-      "  10. **Costi di implementazione e manutenzione**: investimenti iniziali elevati e\\\n",
-      "  \\ costi continui per aggiornamenti, monitoraggio e governance.\\nConsiderare questi\\\n",
-      "  \\ rischi permette di pianificare strategie di mitigazione, governance e controllo\\\n",
-      "  \\ adeguate prima di integrare gli agenti IA nei processi aziendali.\"\n",
-      "justification: \"Ho elencato i rischi pi\\xF9 rilevanti basandomi su studi di settore,\\\n",
-      "  \\ linee guida etiche e normative vigenti, nonch\\xE9 sulle preoccupazioni comuni\\\n",
-      "  \\ espresse da esperti di IA e responsabili della compliance. Ogni punto \\xE8 accompagnato\\\n",
-      "  \\ da una breve spiegazione per evidenziare la sua importanza pratica per le aziende.\"\n",
-      "confidence: 0.98\n",
-      "\n",
-      "answer: \"S\\xEC, l'IA ha il potenziale di migliorare le condizioni di lavoro per la\\\n",
-      "  \\ classe media, ma il risultato dipender\\xE0 da come verranno gestite le politiche,\\\n",
-      "  \\ la formazione e la distribuzione dei benefici.\"\n",
-      "justification: \"L'automazione pu\\xF2 sollevare i lavoratori da compiti ripetitivi\\\n",
-      "  \\ e pericolosi, aumentando la produttivit\\xE0 e consentendo una maggiore flessibilit\\xE0\\\n",
-      "  \\ oraria. Tuttavia, se i guadagni di produttivit\\xE0 non vengono redistribuiti equamente\\\n",
-      "  \\ o se la formazione non \\xE8 adeguata, i vantaggi potrebbero non raggiungere la\\\n",
-      "  \\ classe media. Pertanto, l'impatto positivo \\xE8 possibile ma non garantito.\"\n",
-      "confidence: 0.78\n",
-      "\n",
-      "answer: \"Le aziende devono considerare diversi rischi quando adottano agenti IA, tra\\\n",
-      "  \\ cui: \\n1. **Bias e discriminazione** \\u2013 gli algoritmi possono riprodurre o\\\n",
-      "  \\ amplificare pregiudizi presenti nei dati di addestramento.\\n2. **Privacy e protezione\\\n",
-      "  \\ dei dati** \\u2013 l'uso di dati sensibili pu\\xF2 violare normative come GDPR se\\\n",
-      "  \\ non gestito correttamente.\\n3. **Sicurezza e vulnerabilit\\xE0** \\u2013 gli agenti\\\n",
-      "  \\ IA possono essere bersaglio di attacchi adversariali o manipolazioni.\\n4. **Responsabilit\\xE0\\\n",
-      "  \\ legale** \\u2013 \\xE8 difficile attribuire la responsabilit\\xE0 per decisioni errate\\\n",
-      "  \\ o dannose prese dall'IA.\\n5. **Trasparenza e spiegabilit\\xE0** \\u2013 la mancanza\\\n",
-      "  \\ di spiegazioni comprensibili pu\\xF2 ostacolare la fiducia degli utenti e la conformit\\xE0\\\n",
-      "  \\ normativa.\\n6. **Impatto occupazionale** \\u2013 l'automazione pu\\xF2 portare a\\\n",
-      "  \\ riduzioni di posti di lavoro o a necessit\\xE0 di riqualificazione del personale.\\n\\\n",
-      "  7. **Costi di implementazione e manutenzione** \\u2013 l'integrazione, l'addestramento\\\n",
-      "  \\ continuo e il monitoraggio richiedono risorse significative.\\n8. **Allineamento\\\n",
-      "  \\ con gli obiettivi aziendali** \\u2013 gli agenti potrebbero perseguire obiettivi\\\n",
-      "  \\ diversi da quelli strategici dell'impresa se non adeguatamente configurati.\"\n",
-      "justification: \"Questi rischi sono stati identificati da studi accademici, linee guida\\\n",
-      "  \\ di autorit\\xE0 di regolamentazione (es. EU AI Act) e da esperienze pratiche di\\\n",
-      "  \\ aziende che hanno implementato soluzioni IA. Il bias pu\\xF2 portare a decisioni\\\n",
-      "  \\ ingiuste, la privacy \\xE8 regolamentata da leggi stringenti, la sicurezza \\xE8\\\n",
-      "  \\ cruciale per evitare manipolazioni, e la responsabilit\\xE0 legale \\xE8 ancora\\\n",
-      "  \\ in evoluzione. La trasparenza \\xE8 richiesta per la fiducia e la conformit\\xE0\\\n",
-      "  , mentre gli impatti occupazionali e i costi influenzano la sostenibilit\\xE0 economica\\\n",
-      "  \\ del progetto. L'allineamento strategico garantisce che l'IA supporti, non ostacoli,\\\n",
-      "  \\ gli obiettivi di business.\"\n",
-      "confidence: 0.98\n",
-      "\n",
-      "answer: \"Le aziende devono considerare diversi rischi quando adottano agenti IA, tra\\\n",
-      "  \\ cui:\\n1. **Bias e discriminazione**: gli algoritmi possono riflettere pregiudizi\\\n",
-      "  \\ presenti nei dati di addestramento, portando a decisioni ingiuste.\\n2. **Privacy\\\n",
-      "  \\ e protezione dei dati**: l'uso di IA pu\\xF2 comportare la raccolta e l'elaborazione\\\n",
-      "  \\ di grandi quantit\\xE0 di dati sensibili, con il rischio di violazioni.\\n3. **Sicurezza\\\n",
-      "  \\ e vulnerabilit\\xE0**: gli agenti IA possono essere bersaglio di attacchi informatici\\\n",
-      "  \\ o manipolazioni (ad es. avvelenamento dei dati).\\n4. **Responsabilit\\xE0 legale**:\\\n",
-      "  \\ \\xE8 spesso difficile attribuire la responsabilit\\xE0 per errori o danni causati\\\n",
-      "  \\ da decisioni automatizzate.\\n5. **Trasparenza e spiegabilit\\xE0**: la \\u201Cblack\\\n",
-      "  \\ box\\u201D degli algoritmi pu\\xF2 ostacolare la comprensione delle decisioni e\\\n",
-      "  \\ la fiducia degli stakeholder.\\n6. **Impatto occupazionale**: l\\u2019automazione\\\n",
-      "  \\ pu\\xF2 portare a riduzioni di posti di lavoro o a necessit\\xE0 di riqualificazione\\\n",
-      "  \\ del personale.\\n7. **Conformit\\xE0 normativa**: le normative in evoluzione (es.\\\n",
-      "  \\ GDPR, AI Act) richiedono adeguamenti continui.\\n8. **Dipendenza tecnologica**:\\\n",
-      "  \\ affidarsi eccessivamente a soluzioni IA pu\\xF2 ridurre la resilienza operativa\\\n",
-      "  \\ in caso di guasti.\\n9. **Etica e reputazione**: decisioni non etiche o percepite\\\n",
-      "  \\ come tali possono danneggiare la reputazione aziendale.\\n10. **Costi di implementazione\\\n",
-      "  \\ e manutenzione**: investimenti iniziali e costi continui per aggiornamenti, monitoraggio\\\n",
-      "  \\ e governance possono superare le aspettative.\"\n",
-      "justification: \"Questi rischi sono stati identificati da studi accademici, linee guida\\\n",
-      "  \\ di autorit\\xE0 di regolamentazione e best practice del settore. Il bias e la privacy\\\n",
-      "  \\ sono tra i pi\\xF9 citati perch\\xE9 derivano direttamente dalla natura dei dati\\\n",
-      "  \\ su cui gli agenti IA sono addestrati. La sicurezza, la responsabilit\\xE0 legale\\\n",
-      "  \\ e la trasparenza sono fondamentali per garantire che le decisioni automatizzate\\\n",
-      "  \\ siano affidabili e conformi alle leggi. Inoltre, gli aspetti etici, occupazionali\\\n",
-      "  \\ e di reputazione influenzano direttamente la sostenibilit\\xE0 a lungo termine\\\n",
-      "  \\ dell'adozione dell'IA nelle imprese.\"\n",
-      "confidence: 0.97\n",
-      "\n",
-      "answer: \"Le aziende devono valutare diversi rischi quando adottano agenti IA, tra\\\n",
-      "  \\ cui:\\n1. **Bias e discriminazione**: gli algoritmi possono riprodurre o amplificare\\\n",
-      "  \\ pregiudizi presenti nei dati di addestramento, portando a decisioni ingiuste.\\n\\\n",
-      "  2. **Privacy e sicurezza dei dati**: gli agenti IA trattano grandi quantit\\xE0 di\\\n",
-      "  \\ informazioni sensibili; una gestione inadeguata pu\\xF2 provocare violazioni della\\\n",
-      "  \\ privacy o fughe di dati.\\n3. **Mancanza di trasparenza (black\\u2011box)**: la\\\n",
-      "  \\ difficolt\\xE0 di spiegare come l'IA arriva a una determinata conclusione ostacola\\\n",
-      "  \\ la fiducia e la responsabilit\\xE0.\\n4. **Conformit\\xE0 normativa**: le normative\\\n",
-      "  \\ emergenti sull'IA (es. GDPR, AI Act) impongono requisiti di trasparenza, audit\\\n",
-      "  \\ e gestione del rischio.\\n5. **Affidabilit\\xE0 operativa**: errori o malfunzionamenti\\\n",
-      "  \\ dell'agente possono interrompere processi critici o generare risultati errati.\\n\\\n",
-      "  6. **Dipendenza eccessiva**: affidarsi troppo all'IA pu\\xF2 ridurre le competenze\\\n",
-      "  \\ umane e rendere l'organizzazione vulnerabile a guasti dell'IA.\\n7. **Impatto etico\\\n",
-      "  \\ e reputazionale**: decisioni automatizzate controverse possono danneggiare la\\\n",
-      "  \\ reputazione aziendale.\\n8. **Sicurezza contro attacchi avversari**: gli agenti\\\n",
-      "  \\ IA possono essere manipolati tramite input avversari (adversarial attacks) per\\\n",
-      "  \\ produrre output dannosi.\\n9. **Evoluzione del modello (model drift)**: i modelli\\\n",
-      "  \\ possono degradarsi nel tempo se i dati di produzione cambiano, richiedendo monitoraggio\\\n",
-      "  \\ continuo.\\n10. **Costi e complessit\\xE0 di integrazione**: l'implementazione pu\\xF2\\\n",
-      "  \\ richiedere investimenti significativi e integrazioni complesse con i sistemi legacy.\\n\\\n",
-      "  11. **Responsabilit\\xE0 legale**: determinare chi \\xE8 responsabile per decisioni\\\n",
-      "  \\ errate dell'IA pu\\xF2 essere complesso.\\nConsiderare questi rischi permette di\\\n",
-      "  \\ pianificare mitigazioni, governance adeguata e un'adozione responsabile dell'IA.\"\n",
-      "justification: \"Questi rischi sono stati identificati da studi accademici, linee guida\\\n",
-      "  \\ di autorit\\xE0 di regolamentazione (es. EU AI Act) e pratiche di settore. Ogni\\\n",
-      "  \\ punto evidenzia una vulnerabilit\\xE0 concreta che pu\\xF2 avere impatti legali,\\\n",
-      "  \\ finanziari, operativi o reputazionali per le aziende, rendendo necessario un'analisi\\\n",
-      "  \\ preventiva e misure di mitigazione.\"\n",
-      "confidence: 0.96\n",
-      "\n",
-      "answer: L'Argentina ha vinto l'ultima Coppa del Mondo FIFA (2022).\n",
-      "justification: L'Argentina ha battuto la Francia nella finale del 2022, vincendo ai\n",
-      "  rigori 4-2 dopo un pareggio 3-3 nei tempi regolamentari e supplementari.\n",
-      "confidence: 0.99\n",
-      "\n",
-      "\n"
-     ]
-    }
-   ],
-   "source": [
-    "questions_answering_ag=AG(atype=Answer,\n",
-    "                          llm=AG.get_llm_provider(\"watsonx\"),\n",
-    "                          instructions= \"Answer in italian\")\n",
-    "\n",
-    "print((await (questions_answering_ag << questions)).pretty_print())\n"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "4279f5e4",
-   "metadata": {},
-   "source": [
-    "#### Prompt templates\n",
-    "\n",
-    "Prompt templates enable greater customization of your transductions by providing a langchain style abstraction to render pydantic objects into input prompts for the agent. \n",
-    "\n"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 13,
-   "id": "1dd88de5",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "2025-09-29 07:00:58.241 | DEBUG    | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n",
-      "2025-09-29 07:00:58.256 | DEBUG    | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n"
-     ]
-    },
-    {
-     "data": {
-      "application/vnd.jupyter.widget-view+json": {
-       "model_id": "8ea814a1c7c345cebeacde6c75a2c373",
-       "version_major": 2,
-       "version_minor": 0
-      },
-      "text/plain": [
-       "Output()"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/html": [
-       "
 Received None or empty response from LLM call.\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[91m Received None or empty response from LLM call.\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
 An unknown error occurred. Please check the details below.\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[91m An unknown error occurred. Please check the details below.\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
 Error details: Invalid response from LLM call - None or empty.\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[91m Error details: Invalid response from LLM call - None or empty.\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
 An unknown error occurred. Please check the details below.\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[91m An unknown error occurred. Please check the details below.\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
 Error details: Invalid response from LLM call - None or empty.\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[91m Error details: Invalid response from LLM call - None or empty.\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
\n"
-      ],
-      "text/plain": []
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "2025-09-29 07:01:14.168 | DEBUG    | agentics.core.async_executor:execute:65 - retrying 1 state(s), attempt 1\n",
-      "2025-09-29 07:01:21.302 | DEBUG    | agentics.core.async_executor:execute:65 - retrying 1 state(s), attempt 2\n",
-      "2025-09-29 07:01:27.529 | DEBUG    | agentics.core.agentics:__lshift__:575 - ⚠️  1 states have not been transduced\n"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Atype : \n",
-      "answer: \"On June 11, 2010, major U.S. equity markets posted modest gains. The Dow\\\n",
-      "  \\ Jones Industrial Average rose about 0.5% to roughly 11,500 points, the S&P 500\\\n",
-      "  \\ increased about 0.6% to around 1,155, and the Nasdaq Composite climbed about 0.7%\\\n",
-      "  \\ to near 2,500. The rally was driven by easing fears over the European sovereign\\u2011\\\n",
-      "  debt crisis after Greece\\u2019s first bailout and by expectations that the Federal\\\n",
-      "  \\ Reserve would keep interest rates low.\"\n",
-      "justification: \"Historical market data for June\\u202F11\\u202F2010 show the Dow up\\\n",
-      "  \\ ~57 points (\\u22480.5%), the S&P\\u202F500 up ~7 points (\\u22480.6%), and the Nasdaq\\\n",
-      "  \\ up ~18 points (\\u22480.7%). Contemporary news reports (e.g., Reuters, Bloomberg)\\\n",
-      "  \\ highlighted that the gains were linked to reduced anxiety about the European debt\\\n",
-      "  \\ situation following Greece\\u2019s bailout and to the Fed\\u2019s accommodative\\\n",
-      "  \\ stance, which supported risk assets.\"\n",
-      "confidence: 0.78\n",
-      "\n",
-      "answer: \"On July 21, 2011, global financial markets experienced a sharp sell\\u2011\\\n",
-      "  off. In the United States, the Dow Jones Industrial Average fell about 300 points\\\n",
-      "  \\ (roughly 2\\u202F%), the S&P\\u202F500 dropped around 1.5\\u202F%, and the Nasdaq\\\n",
-      "  \\ Composite slipped about 2\\u202F%. European equity markets also declined, with\\\n",
-      "  \\ the Euro Stoxx 50 losing roughly 2\\u202F% amid heightened concerns over the sovereign\\u2011\\\n",
-      "  debt crisis in Greece and other euro\\u2011zone countries. The market weakness was\\\n",
-      "  \\ driven by fears that the debt\\u2011crisis could spread and by uncertainty about\\\n",
-      "  \\ fiscal policy in the United States.\"\n",
-      "justification: \"The decline on July\\u202F21\\u202F2011 is documented in contemporary\\\n",
-      "  \\ financial news reports (e.g., Reuters, Bloomberg) that highlighted the market\\\n",
-      "  \\ reaction to escalating European debt worries and U.S. fiscal uncertainty. The\\\n",
-      "  \\ specific index moves are taken from the daily closing data reported for that date.\"\n",
-      "confidence: 0.78\n",
-      "\n",
-      "answer: null\n",
-      "justification: null\n",
-      "confidence: null\n",
-      "\n",
-      "\n",
-      "Atype : \n",
-      "answer: \"On June 11, 2010, major U.S. equity markets posted modest gains. The Dow\\\n",
-      "  \\ Jones Industrial Average rose about 0.5% to roughly 11,500 points, the S&P 500\\\n",
-      "  \\ increased about 0.6% to around 1,155, and the Nasdaq Composite climbed about 0.7%\\\n",
-      "  \\ to near 2,500. The rally was driven by easing fears over the European sovereign\\u2011\\\n",
-      "  debt crisis after Greece\\u2019s first bailout and by expectations that the Federal\\\n",
-      "  \\ Reserve would keep interest rates low.\"\n",
-      "justification: \"Historical market data for June\\u202F11\\u202F2010 show the Dow up\\\n",
-      "  \\ ~57 points (\\u22480.5%), the S&P\\u202F500 up ~7 points (\\u22480.6%), and the Nasdaq\\\n",
-      "  \\ up ~18 points (\\u22480.7%). Contemporary news reports (e.g., Reuters, Bloomberg)\\\n",
-      "  \\ highlighted that the gains were linked to reduced anxiety about the European debt\\\n",
-      "  \\ situation following Greece\\u2019s bailout and to the Fed\\u2019s accommodative\\\n",
-      "  \\ stance, which supported risk assets.\"\n",
-      "confidence: 0.78\n",
-      "\n",
-      "answer: \"On July 21, 2011, global financial markets experienced a sharp sell\\u2011\\\n",
-      "  off. In the United States, the Dow Jones Industrial Average fell about 300 points\\\n",
-      "  \\ (roughly 2\\u202F%), the S&P\\u202F500 dropped around 1.5\\u202F%, and the Nasdaq\\\n",
-      "  \\ Composite slipped about 2\\u202F%. European equity markets also declined, with\\\n",
-      "  \\ the Euro Stoxx 50 losing roughly 2\\u202F% amid heightened concerns over the sovereign\\u2011\\\n",
-      "  debt crisis in Greece and other euro\\u2011zone countries. The market weakness was\\\n",
-      "  \\ driven by fears that the debt\\u2011crisis could spread and by uncertainty about\\\n",
-      "  \\ fiscal policy in the United States.\"\n",
-      "justification: \"The decline on July\\u202F21\\u202F2011 is documented in contemporary\\\n",
-      "  \\ financial news reports (e.g., Reuters, Bloomberg) that highlighted the market\\\n",
-      "  \\ reaction to escalating European debt worries and U.S. fiscal uncertainty. The\\\n",
-      "  \\ specific index moves are taken from the daily closing data reported for that date.\"\n",
-      "confidence: 0.78\n",
-      "\n",
-      "answer: null\n",
-      "justification: null\n",
-      "confidence: null\n",
-      "\n",
-      "\n"
-     ]
-    }
-   ],
-   "source": [
-    "questions_answering_ag=AG(atype=Answer)\n",
-    "\n",
-    "dow_jones_data=AG.from_csv(\"data/dow_jones.csv\")\n",
-    "dow_jones_data =dow_jones_data.get_random_sample(0.002)\n",
-    "dow_jones_data.prompt_template=\"what happened to the financial markets in {date}?\"\n",
-    "answers = await (questions_answering_ag << dow_jones_data)\n",
-    "print(answers.pretty_print())\n",
-    "\n"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "911cd683",
-   "metadata": {},
-   "source": [
-    "### Few-Shot Learning\n",
-    "\n",
-    "Agentics natively supports **few-shot examples**: you can preload the **target AG** with\n",
-    "gold states (examples of the desired output). During transduction, these examples steer\n",
-    "the LLM toward consistent labels/structures.\n",
-    "\n",
-    "Below, we load movies from CSV, manually seed the first 10 labels as few-shots, and then\n",
-    "transduce the rest."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "52caa598",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "2025-09-29 09:29:48.180 | DEBUG    | agentics.core.agentics:from_csv:303 - Importing Agentics of type Movie from CSV data/movies.csv\n",
-      "2025-09-29 09:29:48.181 | DEBUG    | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n"
-     ]
-    },
-    {
-     "data": {
-      "application/vnd.jupyter.widget-view+json": {
-       "model_id": "3636f90394ae471c8cfe5622e22d6b12",
-       "version_major": 2,
-       "version_minor": 0
-      },
-      "text/plain": [
-       "Output()"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/html": [
-       "
\n"
-      ],
-      "text/plain": []
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "2025-09-29 09:30:39.717 | DEBUG    | agentics.core.agentics:from_csv:303 - Importing Agentics of type Movie from CSV data/movies.csv\n",
-      "2025-09-29 09:30:39.718 | DEBUG    | agentics.core.llm_connections:get_llm_provider:30 - Available LLM providers: ['watsonx', 'gemini', 'openai']. None specified, defaulting to 'watsonx'\n"
-     ]
-    },
-    {
-     "data": {
-      "application/vnd.jupyter.widget-view+json": {
-       "model_id": "7700d063cdae4c108aec9dc3d5f65d6a",
-       "version_major": 2,
-       "version_minor": 0
-      },
-      "text/plain": [
-       "Output()"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "this is zero shot\n",
-      "Atype : \n",
-      "movie_name: Pulp Fiction\n",
-      "genre: Crime\n",
-      "description: A burger-loving hit man, his philosophical partner, a drug-addled gangster's\n",
-      "  moll and a washed-up boxer converge in this sprawling, comedic crime caper. Their\n",
-      "  adventures unfurl in three stories that ingeniously trip back and forth in time.\n",
-      "\n",
-      "movie_name: Your Name.\n",
-      "genre: Western\n",
-      "description: \"High schoolers Mitsuha and Taki are complete strangers living separate\\\n",
-      "  \\ lives. But one night, they suddenly switch places. Mitsuha wakes up in Taki\\u2019\\\n",
-      "  s body, and he in hers. This bizarre occurrence continues to happen randomly, and\\\n",
-      "  \\ the two must adjust their lives around each other.\"\n",
-      "\n",
-      "movie_name: 'The Lord of the Rings: The Return of the King'\n",
-      "genre: Fantasy\n",
-      "description: \"As armies mass for a final battle that will decide the fate of the world--and\\\n",
-      "  \\ powerful, ancient forces of Light and Dark compete to determine the outcome--one\\\n",
-      "  \\ member of the Fellowship of the Ring is revealed as the noble heir to the throne\\\n",
-      "  \\ of the Kings of Men. Yet, the sole hope for triumph over evil lies with a brave\\\n",
-      "  \\ hobbit, Frodo, who, accompanied by his loyal friend Sam and the hideous, wretched\\\n",
-      "  \\ Gollum, ventures deep into the very dark heart of Mordor on his seemingly impossible\\\n",
-      "  \\ quest to destroy the Ring of Power.\\u200B\"\n",
-      "\n",
-      "movie_name: Forrest Gump\n",
-      "genre: Science Fiction\n",
-      "description: \"A man with a low IQ has accomplished great things in his life and been\\\n",
-      "  \\ present during significant historic events\\u2014in each case, far exceeding what\\\n",
-      "  \\ anyone imagined he could do. But despite all he has achieved, his one true love\\\n",
-      "  \\ eludes him.\"\n",
-      "\n",
-      "movie_name: The Good, the Bad and the Ugly\n",
-      "genre: Western\n",
-      "description: \"While the Civil War rages on between the Union and the Confederacy,\\\n",
-      "  \\ three men \\u2013 a quiet loner, a ruthless hitman, and a Mexican bandit \\u2013\\\n",
-      "  \\ comb the American Southwest in search of a strongbox containing $200,000 in stolen\\\n",
-      "  \\ gold.\"\n",
-      "\n",
-      "movie_name: Seven Samurai\n",
-      "genre: Adventure drama\n",
-      "description: A samurai answers a village's request for protection after he falls on\n",
-      "  hard times. The town needs protection from bandits, so the samurai gathers six others\n",
-      "  to help him teach the people how to defend themselves, and the villagers provide\n",
-      "  the soldiers with food.\n",
-      "\n",
-      "movie_name: GoodFellas\n",
-      "genre: War drama\n",
-      "description: The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid\n",
-      "  who is adopted by neighbourhood gangsters at an early age and climbs the ranks of\n",
-      "  a Mafia family under the guidance of Jimmy Conway.\n",
-      "\n",
-      "movie_name: Interstellar\n",
-      "genre: Science Fiction\n",
-      "description: The adventures of a group of explorers who make use of a newly discovered\n",
-      "  wormhole to surpass the limitations on human space travel and conquer the vast distances\n",
-      "  involved in an interstellar voyage.\n",
-      "\n",
-      "movie_name: Grave of the Fireflies\n",
-      "genre: War drama\n",
-      "description: In the final months of World War II, 14-year-old Seita and his sister\n",
-      "  Setsuko are orphaned when their mother is killed during an air raid in Kobe, Japan.\n",
-      "  After a falling out with their aunt, they move into an abandoned bomb shelter. With\n",
-      "  no surviving relatives and their emergency rations depleted, Seita and Setsuko struggle\n",
-      "  to survive.\n",
-      "\n",
-      "movie_name: Life Is Beautiful\n",
-      "genre: Comedy-drama\n",
-      "description: A touching story of an Italian book seller of Jewish ancestry who lives\n",
-      "  in his own little fairy tale. His creative and happy life would come to an abrupt\n",
-      "  halt when his entire family is deported to a concentration camp during World War\n",
-      "  II. While locked up he tries to convince his son that the whole thing is just a\n",
-      "  game.\n",
-      "\n",
-      "\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "
\n"
-      ],
-      "text/plain": []
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "this is the output with 10 shots\n",
-      "Atype : \n",
-      "movie_name: The Shawshank Redemption\n",
-      "genre: Drama, Action, Crime, Thriller\n",
-      "description: Imprisoned in the 1940s for the double murder of his wife and her lover,\n",
-      "  upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where\n",
-      "  he puts his accounting skills to work for an amoral warden. During his long stretch\n",
-      "  in prison, Dufresne comes to be admired by the other inmates -- including an older\n",
-      "  prisoner named Red -- for his integrity and unquenchable sense of hope.\n",
-      "\n",
-      "movie_name: The Godfather\n",
-      "genre: Drama, Adventure, Fantasy, Action\n",
-      "description: Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American\n",
-      "  Corleone crime family. When organized crime family patriarch, Vito Corleone barely\n",
-      "  survives an attempt on his life, his youngest son, Michael steps in to take care\n",
-      "  of the would-be killers, launching a campaign of bloody revenge.\n",
-      "\n",
-      "movie_name: The Godfather Part II\n",
-      "genre: Western, Drama, Action\n",
-      "description: In the continuing saga of the Corleone crime family, a young Vito Corleone\n",
-      "  grows up in Sicily and in 1910s New York. In the 1950s, Michael Corleone attempts\n",
-      "  to expand the family business into Las Vegas, Hollywood and Cuba.\n",
-      "\n",
-      "movie_name: Schindler's List\n",
-      "genre: Drama, Crime\n",
-      "description: The true story of how businessman Oskar Schindler saved over a thousand\n",
-      "  Jewish lives from the Nazis while they worked as slaves in his factory during World\n",
-      "  War II.\n",
-      "\n",
-      "movie_name: 12 Angry Men\n",
-      "genre: Drama, Action, Crime, Thriller\n",
-      "description: The defense and the prosecution have rested and the jury is filing into\n",
-      "  the jury room to decide if a young Spanish-American is guilty or innocent of murdering\n",
-      "  his father. What begins as an open and shut case soon becomes a mini-drama of each\n",
-      "  of the jurors' prejudices and preconceptions about the trial, the accused, and each\n",
-      "  other.\n",
-      "\n",
-      "movie_name: Spirited Away\n",
-      "genre: Western, Adventure, Drama\n",
-      "description: A young girl, Chihiro, becomes trapped in a strange new world of spirits.\n",
-      "  When her parents undergo a mysterious transformation, she must call upon the courage\n",
-      "  she never knew she had to free her family.\n",
-      "\n",
-      "movie_name: The Dark Knight\n",
-      "genre: Drama, Crime\n",
-      "description: Batman raises the stakes in his war on crime. With the help of Lt. Jim\n",
-      "  Gordon and District Attorney Harvey Dent, Batman sets out to dismantle the remaining\n",
-      "  criminal organizations that plague the streets. The partnership proves to be effective,\n",
-      "  but they soon find themselves prey to a reign of chaos unleashed by a rising criminal\n",
-      "  mastermind known to the terrified citizens of Gotham as the Joker.\n",
-      "\n",
-      "movie_name: Dilwale Dulhania Le Jayenge\n",
-      "genre: Comedy, Drama, Romance\n",
-      "description: \"Raj is a rich, carefree, happy-go-lucky second generation NRI. Simran\\\n",
-      "  \\ is the daughter of Chaudhary Baldev Singh, who in spite of being an NRI is very\\\n",
-      "  \\ strict about adherence to Indian values. Simran has left for India to be married\\\n",
-      "  \\ to her childhood fianc\\xE9. Raj leaves for India with a mission at his hands,\\\n",
-      "  \\ to claim his lady love under the noses of her whole family. Thus begins a saga.\"\n",
-      "\n",
-      "movie_name: The Green Mile\n",
-      "genre: Adventure, Drama, Fantasy\n",
-      "description: A supernatural tale set on death row in a Southern prison, where gentle\n",
-      "  giant John Coffey possesses the mysterious power to heal people's ailments. When\n",
-      "  the cell block's head guard, Paul Edgecomb, recognizes Coffey's miraculous gift,\n",
-      "  he tries desperately to help stave off the condemned man's execution.\n",
-      "\n",
-      "movie_name: Parasite\n",
-      "genre: Drama, Crime\n",
-      "description: All unemployed, Ki-taek's family takes peculiar interest in the wealthy\n",
-      "  and glamorous Parks for their livelihood until they get entangled in an unexpected\n",
-      "  incident.\n",
-      "\n",
-      "movie_name: Pulp Fiction\n",
-      "genre: Drama, Crime\n",
-      "description: A burger-loving hit man, his philosophical partner, a drug-addled gangster's\n",
-      "  moll and a washed-up boxer converge in this sprawling, comedic crime caper. Their\n",
-      "  adventures unfurl in three stories that ingeniously trip back and forth in time.\n",
-      "\n",
-      "movie_name: Your Name.\n",
-      "genre: Drama, Crime\n",
-      "description: \"High schoolers Mitsuha and Taki are complete strangers living separate\\\n",
-      "  \\ lives. But one night, they suddenly switch places. Mitsuha wakes up in Taki\\u2019\\\n",
-      "  s body, and he in hers. This bizarre occurrence continues to happen randomly, and\\\n",
-      "  \\ the two must adjust their lives around each other.\"\n",
-      "\n",
-      "movie_name: 'The Lord of the Rings: The Return of the King'\n",
-      "genre: Drama\n",
-      "description: \"As armies mass for a final battle that will decide the fate of the world--and\\\n",
-      "  \\ powerful, ancient forces of Light and Dark compete to determine the outcome--one\\\n",
-      "  \\ member of the Fellowship of the Ring is revealed as the noble heir to the throne\\\n",
-      "  \\ of the Kings of Men. Yet, the sole hope for triumph over evil lies with a brave\\\n",
-      "  \\ hobbit, Frodo, who, accompanied by his loyal friend Sam and the hideous, wretched\\\n",
-      "  \\ Gollum, ventures deep into the very dark heart of Mordor on his seemingly impossible\\\n",
-      "  \\ quest to destroy the Ring of Power.\\u200B\"\n",
-      "\n",
-      "movie_name: Forrest Gump\n",
-      "genre: Comedy, Drama, Thriller\n",
-      "description: \"A man with a low IQ has accomplished great things in his life and been\\\n",
-      "  \\ present during significant historic events\\u2014in each case, far exceeding what\\\n",
-      "  \\ anyone imagined he could do. But despite all he has achieved, his one true love\\\n",
-      "  \\ eludes him.\"\n",
-      "\n",
-      "movie_name: The Good, the Bad and the Ugly\n",
-      "genre: Drama, Action, Crime, Thriller\n",
-      "description: \"While the Civil War rages on between the Union and the Confederacy,\\\n",
-      "  \\ three men \\u2013 a quiet loner, a ruthless hitman, and a Mexican bandit \\u2013\\\n",
-      "  \\ comb the American Southwest in search of a strongbox containing $200,000 in stolen\\\n",
-      "  \\ gold.\"\n",
-      "\n",
-      "movie_name: Seven Samurai\n",
-      "genre: Drama\n",
-      "description: A samurai answers a village's request for protection after he falls on\n",
-      "  hard times. The town needs protection from bandits, so the samurai gathers six others\n",
-      "  to help him teach the people how to defend themselves, and the villagers provide\n",
-      "  the soldiers with food.\n",
-      "\n",
-      "movie_name: GoodFellas\n",
-      "genre: Drama, Crime\n",
-      "description: The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid\n",
-      "  who is adopted by neighbourhood gangsters at an early age and climbs the ranks of\n",
-      "  a Mafia family under the guidance of Jimmy Conway.\n",
-      "\n",
-      "movie_name: Interstellar\n",
-      "genre: Drama\n",
-      "description: The adventures of a group of explorers who make use of a newly discovered\n",
-      "  wormhole to surpass the limitations on human space travel and conquer the vast distances\n",
-      "  involved in an interstellar voyage.\n",
-      "\n",
-      "movie_name: Grave of the Fireflies\n",
-      "genre: Drama, Crime\n",
-      "description: In the final months of World War II, 14-year-old Seita and his sister\n",
-      "  Setsuko are orphaned when their mother is killed during an air raid in Kobe, Japan.\n",
-      "  After a falling out with their aunt, they move into an abandoned bomb shelter. With\n",
-      "  no surviving relatives and their emergency rations depleted, Seita and Setsuko struggle\n",
-      "  to survive.\n",
-      "\n",
-      "movie_name: Life Is Beautiful\n",
-      "genre: Drama, Crime\n",
-      "description: A touching story of an Italian book seller of Jewish ancestry who lives\n",
-      "  in his own little fairy tale. His creative and happy life would come to an abrupt\n",
-      "  halt when his entire family is deported to a concentration camp during World War\n",
-      "  II. While locked up he tries to convince his son that the whole thing is just a\n",
-      "  game.\n",
-      "\n",
-      "\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "'Atype : \\nmovie_name: The Shawshank Redemption\\ngenre: Drama, Action, Crime, Thriller\\ndescription: Imprisoned in the 1940s for the double murder of his wife and her lover,\\n  upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where\\n  he puts his accounting skills to work for an amoral warden. During his long stretch\\n  in prison, Dufresne comes to be admired by the other inmates -- including an older\\n  prisoner named Red -- for his integrity and unquenchable sense of hope.\\n\\nmovie_name: The Godfather\\ngenre: Drama, Adventure, Fantasy, Action\\ndescription: Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American\\n  Corleone crime family. When organized crime family patriarch, Vito Corleone barely\\n  survives an attempt on his life, his youngest son, Michael steps in to take care\\n  of the would-be killers, launching a campaign of bloody revenge.\\n\\nmovie_name: The Godfather Part II\\ngenre: Western, Drama, Action\\ndescription: In the continuing saga of the Corleone crime family, a young Vito Corleone\\n  grows up in Sicily and in 1910s New York. In the 1950s, Michael Corleone attempts\\n  to expand the family business into Las Vegas, Hollywood and Cuba.\\n\\nmovie_name: Schindler\\'s List\\ngenre: Drama, Crime\\ndescription: The true story of how businessman Oskar Schindler saved over a thousand\\n  Jewish lives from the Nazis while they worked as slaves in his factory during World\\n  War II.\\n\\nmovie_name: 12 Angry Men\\ngenre: Drama, Action, Crime, Thriller\\ndescription: The defense and the prosecution have rested and the jury is filing into\\n  the jury room to decide if a young Spanish-American is guilty or innocent of murdering\\n  his father. What begins as an open and shut case soon becomes a mini-drama of each\\n  of the jurors\\' prejudices and preconceptions about the trial, the accused, and each\\n  other.\\n\\nmovie_name: Spirited Away\\ngenre: Western, Adventure, Drama\\ndescription: A young girl, Chihiro, becomes trapped in a strange new world of spirits.\\n  When her parents undergo a mysterious transformation, she must call upon the courage\\n  she never knew she had to free her family.\\n\\nmovie_name: The Dark Knight\\ngenre: Drama, Crime\\ndescription: Batman raises the stakes in his war on crime. With the help of Lt. Jim\\n  Gordon and District Attorney Harvey Dent, Batman sets out to dismantle the remaining\\n  criminal organizations that plague the streets. The partnership proves to be effective,\\n  but they soon find themselves prey to a reign of chaos unleashed by a rising criminal\\n  mastermind known to the terrified citizens of Gotham as the Joker.\\n\\nmovie_name: Dilwale Dulhania Le Jayenge\\ngenre: Comedy, Drama, Romance\\ndescription: \"Raj is a rich, carefree, happy-go-lucky second generation NRI. Simran\\\\\\n  \\\\ is the daughter of Chaudhary Baldev Singh, who in spite of being an NRI is very\\\\\\n  \\\\ strict about adherence to Indian values. Simran has left for India to be married\\\\\\n  \\\\ to her childhood fianc\\\\xE9. Raj leaves for India with a mission at his hands,\\\\\\n  \\\\ to claim his lady love under the noses of her whole family. Thus begins a saga.\"\\n\\nmovie_name: The Green Mile\\ngenre: Adventure, Drama, Fantasy\\ndescription: A supernatural tale set on death row in a Southern prison, where gentle\\n  giant John Coffey possesses the mysterious power to heal people\\'s ailments. When\\n  the cell block\\'s head guard, Paul Edgecomb, recognizes Coffey\\'s miraculous gift,\\n  he tries desperately to help stave off the condemned man\\'s execution.\\n\\nmovie_name: Parasite\\ngenre: Drama, Crime\\ndescription: All unemployed, Ki-taek\\'s family takes peculiar interest in the wealthy\\n  and glamorous Parks for their livelihood until they get entangled in an unexpected\\n  incident.\\n\\nmovie_name: Pulp Fiction\\ngenre: Drama, Crime\\ndescription: A burger-loving hit man, his philosophical partner, a drug-addled gangster\\'s\\n  moll and a washed-up boxer converge in this sprawling, comedic crime caper. Their\\n  adventures unfurl in three stories that ingeniously trip back and forth in time.\\n\\nmovie_name: Your Name.\\ngenre: Drama, Crime\\ndescription: \"High schoolers Mitsuha and Taki are complete strangers living separate\\\\\\n  \\\\ lives. But one night, they suddenly switch places. Mitsuha wakes up in Taki\\\\u2019\\\\\\n  s body, and he in hers. This bizarre occurrence continues to happen randomly, and\\\\\\n  \\\\ the two must adjust their lives around each other.\"\\n\\nmovie_name: \\'The Lord of the Rings: The Return of the King\\'\\ngenre: Drama\\ndescription: \"As armies mass for a final battle that will decide the fate of the world--and\\\\\\n  \\\\ powerful, ancient forces of Light and Dark compete to determine the outcome--one\\\\\\n  \\\\ member of the Fellowship of the Ring is revealed as the noble heir to the throne\\\\\\n  \\\\ of the Kings of Men. Yet, the sole hope for triumph over evil lies with a brave\\\\\\n  \\\\ hobbit, Frodo, who, accompanied by his loyal friend Sam and the hideous, wretched\\\\\\n  \\\\ Gollum, ventures deep into the very dark heart of Mordor on his seemingly impossible\\\\\\n  \\\\ quest to destroy the Ring of Power.\\\\u200B\"\\n\\nmovie_name: Forrest Gump\\ngenre: Comedy, Drama, Thriller\\ndescription: \"A man with a low IQ has accomplished great things in his life and been\\\\\\n  \\\\ present during significant historic events\\\\u2014in each case, far exceeding what\\\\\\n  \\\\ anyone imagined he could do. But despite all he has achieved, his one true love\\\\\\n  \\\\ eludes him.\"\\n\\nmovie_name: The Good, the Bad and the Ugly\\ngenre: Drama, Action, Crime, Thriller\\ndescription: \"While the Civil War rages on between the Union and the Confederacy,\\\\\\n  \\\\ three men \\\\u2013 a quiet loner, a ruthless hitman, and a Mexican bandit \\\\u2013\\\\\\n  \\\\ comb the American Southwest in search of a strongbox containing $200,000 in stolen\\\\\\n  \\\\ gold.\"\\n\\nmovie_name: Seven Samurai\\ngenre: Drama\\ndescription: A samurai answers a village\\'s request for protection after he falls on\\n  hard times. The town needs protection from bandits, so the samurai gathers six others\\n  to help him teach the people how to defend themselves, and the villagers provide\\n  the soldiers with food.\\n\\nmovie_name: GoodFellas\\ngenre: Drama, Crime\\ndescription: The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid\\n  who is adopted by neighbourhood gangsters at an early age and climbs the ranks of\\n  a Mafia family under the guidance of Jimmy Conway.\\n\\nmovie_name: Interstellar\\ngenre: Drama\\ndescription: The adventures of a group of explorers who make use of a newly discovered\\n  wormhole to surpass the limitations on human space travel and conquer the vast distances\\n  involved in an interstellar voyage.\\n\\nmovie_name: Grave of the Fireflies\\ngenre: Drama, Crime\\ndescription: In the final months of World War II, 14-year-old Seita and his sister\\n  Setsuko are orphaned when their mother is killed during an air raid in Kobe, Japan.\\n  After a falling out with their aunt, they move into an abandoned bomb shelter. With\\n  no surviving relatives and their emergency rations depleted, Seita and Setsuko struggle\\n  to survive.\\n\\nmovie_name: Life Is Beautiful\\ngenre: Drama, Crime\\ndescription: A touching story of an Italian book seller of Jewish ancestry who lives\\n  in his own little fairy tale. His creative and happy life would come to an abrupt\\n  halt when his entire family is deported to a concentration camp during World War\\n  II. While locked up he tries to convince his son that the whole thing is just a\\n  game.\\n\\n'"
-      ]
-     },
-     "execution_count": 28,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "# Zero Shots= all output states are blank\n",
-    "movies = AG.from_csv(base / \"data/movies.csv\",atype=Movie)\n",
-    "movies.filter_states(start =10, end =20)\n",
-    "self_transductions = await movies.self_transduction([\"movie_name\",\"description\"],[\"genre\"])\n",
-    "print(\"this is zero shot\")\n",
-    "self_transductions.pretty_print()\n",
-    "\n",
-    "# Few shots = the first 10 states are used as examples\n",
-    "movies = AG.from_csv(base / \"data/movies.csv\",atype=Movie)\n",
-    "movies.filter_states(start =0, end =20)\n",
-    "self_transductions = await movies.self_transduction([\"movie_name\",\"description\"],[\"genre\"])\n",
-    "\n",
-    "# printing only transduced states\n",
-    "movies.filter_states(start =10, end =20)\n",
-    "print(\"this is the output with 10 shots\")\n",
-    "self_transductions.pretty_print()"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "a6eb0ebd",
-   "metadata": {},
-   "source": [
-    "## Tool Usage  \n",
-    "\n",
-    "Agentics integrates seamlessly with the **MCP ecosystem**, allowing AGs to call external tools during transduction.  In addition to that, they also allows the use of CrewAI tools, as the underlying transduction framework is currently based on crewAI agents. \n",
-    "\n",
-    "This makes it easy to fetch, process, or enrich data dynamically while keeping results structured. \n",
-    "\n",
-    "In the following example we illustrate the use of Duck Duck Go search to improve the information gathering of historical market data. "
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 15,
-   "id": "78356292",
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/html": [
-       "
╭──────────────────────────────────────────── Crew Execution Started ─────────────────────────────────────────────╮\n",
-       "                                                                                                                 \n",
-       "  Crew Execution Started                                                                                         \n",
-       "  Name: crew                                                                                                     \n",
-       "  ID: 1e3a6fc8-6383-43cc-834d-cd00aafdb164                                                                       \n",
-       "  Tool Args:                                                                                                     \n",
-       "                                                                                                                 \n",
-       "                                                                                                                 \n",
-       "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[36m╭─\u001b[0m\u001b[36m───────────────────────────────────────────\u001b[0m\u001b[36m Crew Execution Started \u001b[0m\u001b[36m────────────────────────────────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n", - "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m \u001b[1;36mCrew Execution Started\u001b[0m \u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m \u001b[37mName: \u001b[0m\u001b[36mcrew\u001b[0m \u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m \u001b[37mID: \u001b[0m\u001b[36m1e3a6fc8-6383-43cc-834d-cd00aafdb164\u001b[0m \u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m \u001b[37mTool Args: \u001b[0m \u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", - "\u001b[36m│\u001b[0m \u001b[36m│\u001b[0m\n", - "\u001b[36m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
\n",
-       "
\n" - ], - "text/plain": [ - "\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
\n"
-      ],
-      "text/plain": []
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/html": [
-       "
╭─────────────────────────────────────────────── 🤖 Agent Started ────────────────────────────────────────────────╮\n",
-       "                                                                                                                 \n",
-       "  Agent: Task Executor                                                                                           \n",
-       "                                                                                                                 \n",
-       "  Task:                                                                                                          \n",
-       "  Your task is to transduce a source Pydantic Object into the specified Output type. Generate only slots that    \n",
-       "  are logically deduced from the input information, otherwise live then null.                                    \n",
-       "                                                                                                                 \n",
-       "  Read carefully the following instructions for executing your task:                                             \n",
-       "  Generate an object of the specified type from the following input. SOURCE:                                     \n",
-       "  what happened to the financial markets in 2010-06-11?                                                          \n",
-       "                                                                                                                 \n",
-       "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[35m╭─\u001b[0m\u001b[35m──────────────────────────────────────────────\u001b[0m\u001b[35m 🤖 Agent Started \u001b[0m\u001b[35m───────────────────────────────────────────────\u001b[0m\u001b[35m─╮\u001b[0m\n", - "\u001b[35m│\u001b[0m \u001b[35m│\u001b[0m\n", - "\u001b[35m│\u001b[0m \u001b[37mAgent: \u001b[0m\u001b[1;92mTask Executor\u001b[0m \u001b[35m│\u001b[0m\n", - "\u001b[35m│\u001b[0m \u001b[35m│\u001b[0m\n", - "\u001b[35m│\u001b[0m \u001b[37mTask: \u001b[0m \u001b[35m│\u001b[0m\n", - "\u001b[35m│\u001b[0m \u001b[92mYour task is to transduce a source Pydantic Object into the specified Output type. Generate only slots that \u001b[0m \u001b[35m│\u001b[0m\n", - "\u001b[35m│\u001b[0m \u001b[92mare logically deduced from the input information, otherwise live then null.\u001b[0m \u001b[35m│\u001b[0m\n", - "\u001b[35m│\u001b[0m \u001b[35m│\u001b[0m\n", - "\u001b[35m│\u001b[0m \u001b[92mRead carefully the following instructions for executing your task:\u001b[0m \u001b[35m│\u001b[0m\n", - "\u001b[35m│\u001b[0m \u001b[92mGenerate an object of the specified type from the following input. SOURCE:\u001b[0m \u001b[35m│\u001b[0m\n", - "\u001b[35m│\u001b[0m \u001b[92mwhat happened to the financial markets in 2010-06-11?\u001b[0m \u001b[35m│\u001b[0m\n", - "\u001b[35m│\u001b[0m \u001b[35m│\u001b[0m\n", - "\u001b[35m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
\n",
-       "
\n" - ], - "text/plain": [ - "\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "b694e25c3f97442abb635c738ef6a40f", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Output()" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
\n"
-      ],
-      "text/plain": []
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/html": [
-       "
╭───────────────────────────────────────────── ✅ Agent Final Answer ─────────────────────────────────────────────╮\n",
-       "                                                                                                                 \n",
-       "  Agent: Task Executor                                                                                           \n",
-       "                                                                                                                 \n",
-       "  Final Answer:                                                                                                  \n",
-       "  {                                                                                                              \n",
-       "    \"answer\": \"On June 11, 2010 the U.S. equity markets posted modest gains. The Dow Jones Industrial Average    \n",
-       "  closed at 11,332.70, up about 0.1% (≈+12 points). The S&P 500 finished at 1,155.5, up roughly 0.2% (≈+2.3      \n",
-       "  points), and the Nasdaq Composite rose about 0.3% to 2,511.5. The day was relatively calm after the May 6      \n",
-       "  flash‑crash, with investors focusing on earnings reports and the ongoing European sovereign‑debt concerns.     \n",
-       "  Commodity prices slipped (crude oil fell around 1%), while Treasury yields edged higher, reflecting a slight   \n",
-       "  risk‑off tilt.\",                                                                                               \n",
-       "    \"justification\": \"These figures are reported by multiple market‑data sources for the date June 11, 2010,     \n",
-       "  including Yahoo Finance historical quotes (Dow 11,332.70; S&P 1,155.5; Nasdaq 2,511.5) and MarketWatch daily   \n",
-       "  summary, which note the modest gains and the broader market context following the May flash‑crash and          \n",
-       "  European debt worries.\",                                                                                       \n",
-       "    \"confidence\": 0.86                                                                                           \n",
-       "  }                                                                                                              \n",
-       "                                                                                                                 \n",
-       "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[32m╭─\u001b[0m\u001b[32m────────────────────────────────────────────\u001b[0m\u001b[32m ✅ Agent Final Answer \u001b[0m\u001b[32m────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mAgent: \u001b[0m\u001b[1;92mTask Executor\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mFinal Answer:\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[92m{\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[92m \"answer\": \"On June 11, 2010 the U.S. equity markets posted modest gains. The Dow Jones Industrial Average \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[92mclosed at 11,332.70, up about 0.1% (≈+12 points). The S&P 500 finished at 1,155.5, up roughly 0.2% (≈+2.3 \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[92mpoints), and the Nasdaq Composite rose about 0.3% to 2,511.5. The day was relatively calm after the May 6 \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[92mflash‑crash, with investors focusing on earnings reports and the ongoing European sovereign‑debt concerns. \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[92mCommodity prices slipped (crude oil fell around 1%), while Treasury yields edged higher, reflecting a slight \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[92mrisk‑off tilt.\",\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[92m \"justification\": \"These figures are reported by multiple market‑data sources for the date June 11, 2010, \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[92mincluding Yahoo Finance historical quotes (Dow 11,332.70; S&P 1,155.5; Nasdaq 2,511.5) and MarketWatch daily \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[92msummary, which note the modest gains and the broader market context following the May flash‑crash and \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[92mEuropean debt worries.\",\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[92m \"confidence\": 0.86\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[92m}\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
\n",
-       "
\n" - ], - "text/plain": [ - "\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
\n"
-      ],
-      "text/plain": []
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/html": [
-       "
╭──────────────────────────────────────────────── Task Completion ────────────────────────────────────────────────╮\n",
-       "                                                                                                                 \n",
-       "  Task Completed                                                                                                 \n",
-       "  Name: fdb81d87-ca17-4efb-a883-78070b7f0667                                                                     \n",
-       "  Agent: Task Executor                                                                                           \n",
-       "  Tool Args:                                                                                                     \n",
-       "                                                                                                                 \n",
-       "                                                                                                                 \n",
-       "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[32m╭─\u001b[0m\u001b[32m───────────────────────────────────────────────\u001b[0m\u001b[32m Task Completion \u001b[0m\u001b[32m───────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[1;32mTask Completed\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mName: \u001b[0m\u001b[32mfdb81d87-ca17-4efb-a883-78070b7f0667\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mAgent: \u001b[0m\u001b[32mTask Executor\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mTool Args: \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
\n",
-       "
\n" - ], - "text/plain": [ - "\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
╭──────────────────────────────────────────────── Crew Completion ────────────────────────────────────────────────╮\n",
-       "                                                                                                                 \n",
-       "  Crew Execution Completed                                                                                       \n",
-       "  Name: crew                                                                                                     \n",
-       "  ID: 1e3a6fc8-6383-43cc-834d-cd00aafdb164                                                                       \n",
-       "  Tool Args:                                                                                                     \n",
-       "  Final Output: {                                                                                                \n",
-       "    \"answer\": \"On June 11, 2010 the U.S. equity markets posted modest gains. The Dow Jones Industrial Average    \n",
-       "  closed at 11,332.70, up about 0.1% (≈+12 points). The S&P 500 finished at 1,155.5, up roughly 0.2% (≈+2.3      \n",
-       "  points), and the Nasdaq Composite rose about 0.3% to 2,511.5. The day was relatively calm after the May 6      \n",
-       "  flash‑crash, with investors focusing on earnings reports and the ongoing European sovereign‑debt concerns.     \n",
-       "  Commodity prices slipped (crude oil fell around 1%), while Treasury yields edged higher, reflecting a slight   \n",
-       "  risk‑off tilt.\",                                                                                               \n",
-       "    \"justification\": \"These figures are reported by multiple market‑data sources for the date June 11, 2010,     \n",
-       "  including Yahoo Finance historical quotes (Dow 11,332.70; S&P 1,155.5; Nasdaq 2,511.5) and MarketWatch daily   \n",
-       "  summary, which note the modest gains and the broader market context following the May flash‑crash and          \n",
-       "  European debt worries.\",                                                                                       \n",
-       "    \"confidence\": 0.86                                                                                           \n",
-       "  }                                                                                                              \n",
-       "                                                                                                                 \n",
-       "                                                                                                                 \n",
-       "╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
-       "
\n" - ], - "text/plain": [ - "\u001b[32m╭─\u001b[0m\u001b[32m───────────────────────────────────────────────\u001b[0m\u001b[32m Crew Completion \u001b[0m\u001b[32m───────────────────────────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[1;32mCrew Execution Completed\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mName: \u001b[0m\u001b[32mcrew\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mID: \u001b[0m\u001b[32m1e3a6fc8-6383-43cc-834d-cd00aafdb164\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mTool Args: \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mFinal Output: {\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37m \"answer\": \"On June 11, 2010 the U.S. equity markets posted modest gains. The Dow Jones Industrial Average \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mclosed at 11,332.70, up about 0.1% (≈+12 points). The S&P 500 finished at 1,155.5, up roughly 0.2% (≈+2.3 \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mpoints), and the Nasdaq Composite rose about 0.3% to 2,511.5. The day was relatively calm after the May 6 \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mflash‑crash, with investors focusing on earnings reports and the ongoing European sovereign‑debt concerns. \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mCommodity prices slipped (crude oil fell around 1%), while Treasury yields edged higher, reflecting a slight \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mrisk‑off tilt.\",\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37m \"justification\": \"These figures are reported by multiple market‑data sources for the date June 11, 2010, \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mincluding Yahoo Finance historical quotes (Dow 11,332.70; S&P 1,155.5; Nasdaq 2,511.5) and MarketWatch daily \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37msummary, which note the modest gains and the broader market context following the May flash‑crash and \u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37mEuropean debt worries.\",\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37m \"confidence\": 0.86\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[37m}\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m│\u001b[0m \u001b[32m│\u001b[0m\n", - "\u001b[32m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
\n",
-       "
\n" - ], - "text/plain": [ - "\n" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Atype : \n", - "answer: \"On June 11, 2010 the U.S. equity markets posted modest gains. The Dow Jones\\\n", - " \\ Industrial Average closed at 11,332.70, up about 0.1% (\\u2248+12 points). The\\\n", - " \\ S&P 500 finished at 1,155.5, up roughly 0.2% (\\u2248+2.3 points), and the Nasdaq\\\n", - " \\ Composite rose about 0.3% to 2,511.5. The day was relatively calm after the May\\\n", - " \\ 6 flash\\u2011crash, with investors focusing on earnings reports and the ongoing\\\n", - " \\ European sovereign\\u2011debt concerns. Commodity prices slipped (crude oil fell\\\n", - " \\ around 1%), while Treasury yields edged higher, reflecting a slight risk\\u2011\\\n", - " off tilt.\"\n", - "justification: \"These figures are reported by multiple market\\u2011data sources for\\\n", - " \\ the date June 11, 2010, including Yahoo Finance historical quotes (Dow 11,332.70;\\\n", - " \\ S&P 1,155.5; Nasdaq 2,511.5) and MarketWatch daily summary, which note the modest\\\n", - " \\ gains and the broader market context following the May flash\\u2011crash and European\\\n", - " \\ debt worries.\"\n", - "confidence: 0.86\n", - "\n", - "\n", - "Atype : \n", - "answer: \"On June 11, 2010 the U.S. equity markets posted modest gains. The Dow Jones\\\n", - " \\ Industrial Average closed at 11,332.70, up about 0.1% (\\u2248+12 points). The\\\n", - " \\ S&P 500 finished at 1,155.5, up roughly 0.2% (\\u2248+2.3 points), and the Nasdaq\\\n", - " \\ Composite rose about 0.3% to 2,511.5. The day was relatively calm after the May\\\n", - " \\ 6 flash\\u2011crash, with investors focusing on earnings reports and the ongoing\\\n", - " \\ European sovereign\\u2011debt concerns. Commodity prices slipped (crude oil fell\\\n", - " \\ around 1%), while Treasury yields edged higher, reflecting a slight risk\\u2011\\\n", - " off tilt.\"\n", - "justification: \"These figures are reported by multiple market\\u2011data sources for\\\n", - " \\ the date June 11, 2010, including Yahoo Finance historical quotes (Dow 11,332.70;\\\n", - " \\ S&P 1,155.5; Nasdaq 2,511.5) and MarketWatch daily summary, which note the modest\\\n", - " \\ gains and the broader market context following the May flash\\u2011crash and European\\\n", - " \\ debt worries.\"\n", - "confidence: 0.86\n", - "\n", - "\n" - ] - } - ], - "source": [ - "from crewai.tools import tool\n", - "from ddgs import DDGS\n", - "\n", - "\n", - "## Define a Crew AI tool to get news for a given date using the DDGS search engine\n", - "@tool(\"web_search\")\n", - "def web_search(query: str) -> str:\n", - " \"\"\"Fetch web search results for the given query using DDGS.\"\"\"\n", - " return str(DDGS().text(query, max_results=10))\n", - "\n", - "\n", - "questions_answering_ag.verbose_agent = True\n", - "questions_answering_ag.tools=[web_search]\n", - "dow_jones_data.filter_states(end=1)\n", - "answers = await (questions_answering_ag << dow_jones_data)\n", - "print(answers.pretty_print())" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": ".venv", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.9" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/uv.lock b/uv.lock index a72ffc2a..da2fab25 100644 --- a/uv.lock +++ b/uv.lock @@ -43,6 +43,7 @@ dependencies = [ { name = "langchain-huggingface" }, { name = "loguru" }, { name = "mcp" }, + { name = "numerize" }, { name = "openai" }, { name = "openapi-python-client" }, { name = "pydantic" }, @@ -54,10 +55,13 @@ dependencies = [ dev = [ { name = "black", extra = ["jupyter"] }, { name = "invoke" }, + { name = "ipykernel" }, { name = "isort" }, + { name = "nbconvert" }, { name = "papermill" }, { name = "pdbpp" }, { name = "pre-commit" }, + { name = "pre-commit-uv" }, { name = "pytest" }, { name = "pytest-asyncio" }, { name = "pytest-html" }, @@ -89,6 +93,7 @@ requires-dist = [ { name = "langchain-huggingface", specifier = ">=0.2.0,<0.3.0" }, { name = "loguru", specifier = ">=0.7.3,<0.8.0" }, { name = "mcp", specifier = ">=1.13.1,<2.0.0" }, + { name = "numerize", specifier = ">=0.12" }, { name = "openai", specifier = ">=1.88.0,<2.0.0" }, { name = "openapi-python-client", specifier = ">=0.24.3,<0.25.0" }, { name = "pydantic" }, @@ -100,10 +105,13 @@ requires-dist = [ dev = [ { name = "black", extras = ["jupyter"], specifier = ">=25.1.0,<26" }, { name = "invoke", specifier = ">=2.2.0" }, + { name = "ipykernel", specifier = ">=6.30.1" }, { name = "isort", specifier = ">=6.0.1,<7" }, + { name = "nbconvert", specifier = ">=7.16.6" }, { name = "papermill", specifier = ">=2.6.0" }, { name = "pdbpp", specifier = ">=0.11.6,<1" }, { name = "pre-commit", specifier = ">=4.2.0,<5" }, + { name = "pre-commit-uv", specifier = ">=4.1.5" }, { name = "pytest", specifier = ">=8.4.0,<9" }, { name = "pytest-asyncio", specifier = ">=1.0.0,<2" }, { name = "pytest-html", specifier = ">=4.1.1,<5" }, @@ -281,6 +289,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/3b/00/2344469e2084fb287c2e0b57b72910309874c3245463acd6cf5e3db69324/appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128", size = 9566, upload-time = "2020-05-11T07:59:49.499Z" }, ] +[[package]] +name = "appnope" +version = "0.1.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/35/5d/752690df9ef5b76e169e68d6a129fa6d08a7100ca7f754c89495db3c6019/appnope-0.1.4.tar.gz", hash = "sha256:1de3860566df9caf38f01f86f65e0e13e379af54f9e4bee1e66b48f2efffd1ee", size = 4170, upload-time = "2024-02-06T09:43:11.258Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/81/29/5ecc3a15d5a33e31b26c11426c45c501e439cb865d0bff96315d86443b78/appnope-0.1.4-py2.py3-none-any.whl", hash = "sha256:502575ee11cd7a28c0205f379b525beefebab9d161b7c964670864014ed7213c", size = 4321, upload-time = "2024-02-06T09:43:09.663Z" }, +] + [[package]] name = "asttokens" version = "3.0.0" @@ -415,6 +432,23 @@ jupyter = [ { name = "tokenize-rt" }, ] +[[package]] +name = "bleach" +version = "6.2.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "webencodings" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/76/9a/0e33f5054c54d349ea62c277191c020c2d6ef1d65ab2cb1993f91ec846d1/bleach-6.2.0.tar.gz", hash = "sha256:123e894118b8a599fd80d3ec1a6d4cc7ce4e5882b1317a7e1ba69b56e95f991f", size = 203083, upload-time = "2024-10-29T18:30:40.477Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fc/55/96142937f66150805c25c4d0f31ee4132fd33497753400734f9dfdcbdc66/bleach-6.2.0-py3-none-any.whl", hash = "sha256:117d9c6097a7c3d22fd578fcd8d35ff1e125df6736f554da4e432fdd63f31e5e", size = 163406, upload-time = "2024-10-29T18:30:38.186Z" }, +] + +[package.optional-dependencies] +css = [ + { name = "tinycss2" }, +] + [[package]] name = "blinker" version = "1.9.0" @@ -788,6 +822,23 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ff/e2/8feccc47acfc1ada5e63d037aa5f345eb92503d851b0c5e461bf05fbdfa8/ddgs-9.5.2-py3-none-any.whl", hash = "sha256:3685246763426f6bca06db709dc4464db7940b8a418b56880f0ae41c3480e0c3", size = 36350, upload-time = "2025-08-05T21:11:50.177Z" }, ] +[[package]] +name = "debugpy" +version = "1.8.17" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/15/ad/71e708ff4ca377c4230530d6a7aa7992592648c122a2cd2b321cf8b35a76/debugpy-1.8.17.tar.gz", hash = "sha256:fd723b47a8c08892b1a16b2c6239a8b96637c62a59b94bb5dab4bac592a58a8e", size = 1644129, upload-time = "2025-09-17T16:33:20.633Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d8/53/3af72b5c159278c4a0cf4cffa518675a0e73bdb7d1cac0239b815502d2ce/debugpy-1.8.17-cp311-cp311-macosx_15_0_universal2.whl", hash = "sha256:d3fce3f0e3de262a3b67e69916d001f3e767661c6e1ee42553009d445d1cd840", size = 2207154, upload-time = "2025-09-17T16:33:29.457Z" }, + { url = "https://files.pythonhosted.org/packages/8f/6d/204f407df45600e2245b4a39860ed4ba32552330a0b3f5f160ae4cc30072/debugpy-1.8.17-cp311-cp311-manylinux_2_34_x86_64.whl", hash = "sha256:c6bdf134457ae0cac6fb68205776be635d31174eeac9541e1d0c062165c6461f", size = 3170322, upload-time = "2025-09-17T16:33:30.837Z" }, + { url = "https://files.pythonhosted.org/packages/f2/13/1b8f87d39cf83c6b713de2620c31205299e6065622e7dd37aff4808dd410/debugpy-1.8.17-cp311-cp311-win32.whl", hash = "sha256:e79a195f9e059edfe5d8bf6f3749b2599452d3e9380484cd261f6b7cd2c7c4da", size = 5155078, upload-time = "2025-09-17T16:33:33.331Z" }, + { url = "https://files.pythonhosted.org/packages/c2/c5/c012c60a2922cc91caa9675d0ddfbb14ba59e1e36228355f41cab6483469/debugpy-1.8.17-cp311-cp311-win_amd64.whl", hash = "sha256:b532282ad4eca958b1b2d7dbcb2b7218e02cb934165859b918e3b6ba7772d3f4", size = 5179011, upload-time = "2025-09-17T16:33:35.711Z" }, + { url = "https://files.pythonhosted.org/packages/08/2b/9d8e65beb2751876c82e1aceb32f328c43ec872711fa80257c7674f45650/debugpy-1.8.17-cp312-cp312-macosx_15_0_universal2.whl", hash = "sha256:f14467edef672195c6f6b8e27ce5005313cb5d03c9239059bc7182b60c176e2d", size = 2549522, upload-time = "2025-09-17T16:33:38.466Z" }, + { url = "https://files.pythonhosted.org/packages/b4/78/eb0d77f02971c05fca0eb7465b18058ba84bd957062f5eec82f941ac792a/debugpy-1.8.17-cp312-cp312-manylinux_2_34_x86_64.whl", hash = "sha256:24693179ef9dfa20dca8605905a42b392be56d410c333af82f1c5dff807a64cc", size = 4309417, upload-time = "2025-09-17T16:33:41.299Z" }, + { url = "https://files.pythonhosted.org/packages/37/42/c40f1d8cc1fed1e75ea54298a382395b8b937d923fcf41ab0797a554f555/debugpy-1.8.17-cp312-cp312-win32.whl", hash = "sha256:6a4e9dacf2cbb60d2514ff7b04b4534b0139facbf2abdffe0639ddb6088e59cf", size = 5277130, upload-time = "2025-09-17T16:33:43.554Z" }, + { url = "https://files.pythonhosted.org/packages/72/22/84263b205baad32b81b36eac076de0cdbe09fe2d0637f5b32243dc7c925b/debugpy-1.8.17-cp312-cp312-win_amd64.whl", hash = "sha256:e8f8f61c518952fb15f74a302e068b48d9c4691768ade433e4adeea961993464", size = 5319053, upload-time = "2025-09-17T16:33:53.033Z" }, + { url = "https://files.pythonhosted.org/packages/b0/d0/89247ec250369fc76db477720a26b2fce7ba079ff1380e4ab4529d2fe233/debugpy-1.8.17-py2.py3-none-any.whl", hash = "sha256:60c7dca6571efe660ccb7a9508d73ca14b8796c4ed484c2002abba714226cfef", size = 5283210, upload-time = "2025-09-17T16:34:25.835Z" }, +] + [[package]] name = "decorator" version = "5.2.1" @@ -1517,6 +1568,30 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/0a/66/7f8c48009c72d73bc6bbe6eb87ac838d6a526146f7dab14af671121eb379/invoke-2.2.0-py3-none-any.whl", hash = "sha256:6ea924cc53d4f78e3d98bc436b08069a03077e6f85ad1ddaa8a116d7dad15820", size = 160274, upload-time = "2023-07-12T18:05:16.294Z" }, ] +[[package]] +name = "ipykernel" +version = "6.30.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "appnope", marker = "sys_platform == 'darwin'" }, + { name = "comm" }, + { name = "debugpy" }, + { name = "ipython" }, + { name = "jupyter-client" }, + { name = "jupyter-core" }, + { name = "matplotlib-inline" }, + { name = "nest-asyncio" }, + { name = "packaging" }, + { name = "psutil" }, + { name = "pyzmq" }, + { name = "tornado" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/bb/76/11082e338e0daadc89c8ff866185de11daf67d181901038f9e139d109761/ipykernel-6.30.1.tar.gz", hash = "sha256:6abb270161896402e76b91394fcdce5d1be5d45f456671e5080572f8505be39b", size = 166260, upload-time = "2025-08-04T15:47:35.018Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fc/c7/b445faca8deb954fe536abebff4ece5b097b923de482b26e78448c89d1dd/ipykernel-6.30.1-py3-none-any.whl", hash = "sha256:aa6b9fb93dca949069d8b85b6c79b2518e32ac583ae9c7d37c51d119e18b3fb4", size = 117484, upload-time = "2025-08-04T15:47:32.622Z" }, +] + [[package]] name = "ipython" version = "9.5.0" @@ -1779,6 +1854,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/2f/57/6bffd4b20b88da3800c5d691e0337761576ee688eb01299eae865689d2df/jupyter_core-5.8.1-py3-none-any.whl", hash = "sha256:c28d268fc90fb53f1338ded2eb410704c5449a358406e8a948b75706e24863d0", size = 28880, upload-time = "2025-05-27T07:38:15.137Z" }, ] +[[package]] +name = "jupyterlab-pygments" +version = "0.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/90/51/9187be60d989df97f5f0aba133fa54e7300f17616e065d1ada7d7646b6d6/jupyterlab_pygments-0.3.0.tar.gz", hash = "sha256:721aca4d9029252b11cfa9d185e5b5af4d54772bb8072f9b7036f4170054d35d", size = 512900, upload-time = "2023-11-23T09:26:37.44Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b1/dd/ead9d8ea85bf202d90cc513b533f9c363121c7792674f78e0d8a854b63b4/jupyterlab_pygments-0.3.0-py3-none-any.whl", hash = "sha256:841a89020971da1d8693f1a99997aefc5dc424bb1b251fd6322462a1b8842780", size = 15884, upload-time = "2023-11-23T09:26:34.325Z" }, +] + [[package]] name = "jupyterlab-widgets" version = "3.0.15" @@ -2152,6 +2236,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/2c/19/04f9b178c2d8a15b076c8b5140708fa6ffc5601fb6f1e975537072df5b2a/mergedeep-1.3.4-py3-none-any.whl", hash = "sha256:70775750742b25c0d8f36c55aed03d24c3384d17c951b3175d898bd778ef0307", size = 6354, upload-time = "2021-02-05T18:55:29.583Z" }, ] +[[package]] +name = "mistune" +version = "3.1.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d7/02/a7fb8b21d4d55ac93cdcde9d3638da5dd0ebdd3a4fed76c7725e10b81cbe/mistune-3.1.4.tar.gz", hash = "sha256:b5a7f801d389f724ec702840c11d8fc48f2b33519102fc7ee739e8177b672164", size = 94588, upload-time = "2025-08-29T07:20:43.594Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7a/f0/8282d9641415e9e33df173516226b404d367a0fc55e1a60424a152913abc/mistune-3.1.4-py3-none-any.whl", hash = "sha256:93691da911e5d9d2e23bc54472892aff676df27a75274962ff9edc210364266d", size = 53481, upload-time = "2025-08-29T07:20:42.218Z" }, +] + [[package]] name = "mkdocs" version = "1.6.1" @@ -2415,6 +2508,31 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/34/6d/e7fa07f03a4a7b221d94b4d586edb754a9b0dc3c9e2c93353e9fa4e0d117/nbclient-0.10.2-py3-none-any.whl", hash = "sha256:4ffee11e788b4a27fabeb7955547e4318a5298f34342a4bfd01f2e1faaeadc3d", size = 25434, upload-time = "2024-12-19T10:32:24.139Z" }, ] +[[package]] +name = "nbconvert" +version = "7.16.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "beautifulsoup4" }, + { name = "bleach", extra = ["css"] }, + { name = "defusedxml" }, + { name = "jinja2" }, + { name = "jupyter-core" }, + { name = "jupyterlab-pygments" }, + { name = "markupsafe" }, + { name = "mistune" }, + { name = "nbclient" }, + { name = "nbformat" }, + { name = "packaging" }, + { name = "pandocfilters" }, + { name = "pygments" }, + { name = "traitlets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a3/59/f28e15fc47ffb73af68a8d9b47367a8630d76e97ae85ad18271b9db96fdf/nbconvert-7.16.6.tar.gz", hash = "sha256:576a7e37c6480da7b8465eefa66c17844243816ce1ccc372633c6b71c3c0f582", size = 857715, upload-time = "2025-01-28T09:29:14.724Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cc/9a/cd673b2f773a12c992f41309ef81b99da1690426bd2f96957a7ade0d3ed7/nbconvert-7.16.6-py3-none-any.whl", hash = "sha256:1375a7b67e0c2883678c48e506dc320febb57685e5ee67faa51b18a90f3a712b", size = 258525, upload-time = "2025-01-28T09:29:12.551Z" }, +] + [[package]] name = "nbformat" version = "5.10.4" @@ -2483,6 +2601,12 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d2/1d/1b658dbd2b9fa9c4c9f32accbfc0205d532c8c6194dc0f2a4c0428e7128a/nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9", size = 22314, upload-time = "2024-06-04T18:44:08.352Z" }, ] +[[package]] +name = "numerize" +version = "0.12" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6a/cf/c5dfa6ca5b6553f30860337020d76c582fd81b48da58982a6f2ff1f1fe40/numerize-0.12.tar.gz", hash = "sha256:5548fe72adceb2c7964998179697d80117bb117f57cd02f872cf5db40d615c04", size = 2721, upload-time = "2018-08-14T14:48:33.212Z" } + [[package]] name = "numpy" version = "2.3.3" @@ -2943,6 +3067,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/28/30/8114832daff7489f179971dbc1d854109b7f4365a546e3ea75b6516cea95/pandas-2.3.2-cp312-cp312-win_amd64.whl", hash = "sha256:8c13b81a9347eb8c7548f53fd9a4f08d4dfe996836543f805c987bafa03317ae", size = 10983326, upload-time = "2025-08-21T10:27:31.901Z" }, ] +[[package]] +name = "pandocfilters" +version = "1.5.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/70/6f/3dd4940bbe001c06a65f88e36bad298bc7a0de5036115639926b0c5c0458/pandocfilters-1.5.1.tar.gz", hash = "sha256:002b4a555ee4ebc03f8b66307e287fa492e4a77b4ea14d3f934328297bb4939e", size = 8454, upload-time = "2024-01-18T20:08:13.726Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ef/af/4fbc8cab944db5d21b7e2a5b8e9211a03a79852b1157e2c102fcc61ac440/pandocfilters-1.5.1-py2.py3-none-any.whl", hash = "sha256:93be382804a9cdb0a7267585f157e5d1731bbe5545a85b268d6f5fe6232de2bc", size = 8663, upload-time = "2024-01-18T20:08:11.28Z" }, +] + [[package]] name = "papermill" version = "2.6.0" @@ -3165,6 +3298,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/5b/a5/987a405322d78a73b66e39e4a90e4ef156fd7141bf71df987e50717c321b/pre_commit-4.3.0-py2.py3-none-any.whl", hash = "sha256:2b0747ad7e6e967169136edffee14c16e148a778a54e4f967921aa1ebf2308d8", size = 220965, upload-time = "2025-08-09T18:56:13.192Z" }, ] +[[package]] +name = "pre-commit-uv" +version = "4.1.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pre-commit" }, + { name = "uv" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/3d/0c/e6ab71e93d8e78ffa36a1f8b6ce12014679e2b83b401404c12bb2840078f/pre_commit_uv-4.1.5.tar.gz", hash = "sha256:3f40714152b4f4aa484703b8dbfeb9baa0aaedb17207e0012b3561da756d577d", size = 6920, upload-time = "2025-08-27T14:44:40.178Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f7/c6/747bc58da9f0665c607890c73b349b3934381e312272f584808182655898/pre_commit_uv-4.1.5-py3-none-any.whl", hash = "sha256:f4805e45615b898c4ca6ea37bdb60a05bb7830f986c303a06a378d6b50c3aa9e", size = 5653, upload-time = "2025-08-27T14:44:39.187Z" }, +] + [[package]] name = "primp" version = "0.15.0" @@ -4564,6 +4710,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/f5/6e/5b71578799b72e5bdcef206a214c3ce860d999d579a3b56e74a6c8989ee2/tiktoken-0.11.0-cp312-cp312-win_amd64.whl", hash = "sha256:45927a71ab6643dfd3ef57d515a5db3d199137adf551f66453be098502838b0f", size = 884282, upload-time = "2025-08-08T23:57:50.759Z" }, ] +[[package]] +name = "tinycss2" +version = "1.4.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "webencodings" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7a/fd/7a5ee21fd08ff70d3d33a5781c255cbe779659bd03278feb98b19ee550f4/tinycss2-1.4.0.tar.gz", hash = "sha256:10c0972f6fc0fbee87c3edb76549357415e94548c1ae10ebccdea16fb404a9b7", size = 87085, upload-time = "2024-10-24T14:58:29.895Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e6/34/ebdc18bae6aa14fbee1a08b63c015c72b64868ff7dae68808ab500c492e2/tinycss2-1.4.0-py3-none-any.whl", hash = "sha256:3a49cf47b7675da0b15d0c6e1df8df4ebd96e9394bb905a5775adb0d884c5289", size = 26610, upload-time = "2024-10-24T14:58:28.029Z" }, +] + [[package]] name = "tokenize-rt" version = "6.2.0" @@ -4989,6 +5147,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/af/b5/123f13c975e9f27ab9c0770f514345bd406d0e8d3b7a0723af9d43f710af/wcwidth-0.2.14-py2.py3-none-any.whl", hash = "sha256:a7bb560c8aee30f9957e5f9895805edd20602f2d7f720186dfd906e82b4982e1", size = 37286, upload-time = "2025-09-22T16:29:51.641Z" }, ] +[[package]] +name = "webencodings" +version = "0.5.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/0b/02/ae6ceac1baeda530866a85075641cec12989bd8d31af6d5ab4a3e8c92f47/webencodings-0.5.1.tar.gz", hash = "sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923", size = 9721, upload-time = "2017-04-05T20:21:34.189Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl", hash = "sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78", size = 11774, upload-time = "2017-04-05T20:21:32.581Z" }, +] + [[package]] name = "websocket-client" version = "1.8.0"