From 2b15183980b57e5c820c94ef5a7fb23b64e9e5a6 Mon Sep 17 00:00:00 2001 From: Bagatur <22008038+baskaryan@users.noreply.github.com> Date: Tue, 10 Sep 2024 20:31:25 -0700 Subject: [PATCH] docs: run tool, query analysis how tos (#26306) --- .../how_to/query_constructing_filters.ipynb | 94 ++++- docs/docs/how_to/query_few_shot.ipynb | 143 ++++++-- docs/docs/how_to/query_high_cardinality.ipynb | 330 +++++++++++++----- docs/docs/how_to/query_multiple_queries.ipynb | 160 ++++++--- .../how_to/query_multiple_retrievers.ipynb | 159 +++++++-- docs/docs/how_to/query_no_queries.ipynb | 150 ++++++-- docs/docs/how_to/tool_calling.ipynb | 63 +++- docs/docs/how_to/tool_runtime.ipynb | 299 +++++++++++----- docs/docs/how_to/tools_builtin.ipynb | 71 +++- docs/docs/how_to/tools_error.ipynb | 120 +++++-- 10 files changed, 1194 insertions(+), 395 deletions(-) diff --git a/docs/docs/how_to/query_constructing_filters.ipynb b/docs/docs/how_to/query_constructing_filters.ipynb index 33e798784b3..c445e983199 100644 --- a/docs/docs/how_to/query_constructing_filters.ipynb +++ b/docs/docs/how_to/query_constructing_filters.ipynb @@ -24,9 +24,16 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 1, "id": "8ca446a0", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:32:35.834087Z", + "iopub.status.busy": "2024-09-11T02:32:35.833763Z", + "iopub.status.idle": "2024-09-11T02:32:36.588973Z", + "shell.execute_reply": "2024-09-11T02:32:36.588677Z" + } + }, "outputs": [], "source": [ "from typing import Optional\n", @@ -53,9 +60,16 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 2, "id": "64055006", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:32:36.590665Z", + "iopub.status.busy": "2024-09-11T02:32:36.590527Z", + "iopub.status.idle": "2024-09-11T02:32:36.592985Z", + "shell.execute_reply": "2024-09-11T02:32:36.592763Z" + } + }, "outputs": [], "source": [ "class Search(BaseModel):\n", @@ -66,9 +80,16 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 3, "id": "44eb6d98", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:32:36.594147Z", + "iopub.status.busy": "2024-09-11T02:32:36.594072Z", + "iopub.status.idle": "2024-09-11T02:32:36.595777Z", + "shell.execute_reply": "2024-09-11T02:32:36.595563Z" + } + }, "outputs": [], "source": [ "search_query = Search(query=\"RAG\", start_year=2022, author=\"LangChain\")" @@ -76,9 +97,16 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 4, "id": "e8ba6705", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:32:36.596902Z", + "iopub.status.busy": "2024-09-11T02:32:36.596824Z", + "iopub.status.idle": "2024-09-11T02:32:36.598805Z", + "shell.execute_reply": "2024-09-11T02:32:36.598629Z" + } + }, "outputs": [], "source": [ "def construct_comparisons(query: Search):\n", @@ -104,9 +132,16 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 5, "id": "6a79c9da", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:32:36.599989Z", + "iopub.status.busy": "2024-09-11T02:32:36.599909Z", + "iopub.status.idle": "2024-09-11T02:32:36.601521Z", + "shell.execute_reply": "2024-09-11T02:32:36.601306Z" + } + }, "outputs": [], "source": [ "comparisons = construct_comparisons(search_query)" @@ -114,9 +149,16 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 6, "id": "2d0e9689", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:32:36.602688Z", + "iopub.status.busy": "2024-09-11T02:32:36.602603Z", + "iopub.status.idle": "2024-09-11T02:32:36.604171Z", + "shell.execute_reply": "2024-09-11T02:32:36.603981Z" + } + }, "outputs": [], "source": [ "_filter = Operation(operator=Operator.AND, arguments=comparisons)" @@ -124,9 +166,16 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 7, "id": "e4c0b2ce", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:32:36.605267Z", + "iopub.status.busy": "2024-09-11T02:32:36.605190Z", + "iopub.status.idle": "2024-09-11T02:32:36.607993Z", + "shell.execute_reply": "2024-09-11T02:32:36.607796Z" + } + }, "outputs": [ { "data": { @@ -135,7 +184,7 @@ " {'term': {'metadata.author.keyword': 'LangChain'}}]}}" ] }, - "execution_count": 18, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -146,9 +195,16 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 8, "id": "d75455ae", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:32:36.609091Z", + "iopub.status.busy": "2024-09-11T02:32:36.609012Z", + "iopub.status.idle": "2024-09-11T02:32:36.611075Z", + "shell.execute_reply": "2024-09-11T02:32:36.610869Z" + } + }, "outputs": [ { "data": { @@ -156,7 +212,7 @@ "{'$and': [{'start_year': {'$gt': 2022}}, {'author': {'$eq': 'LangChain'}}]}" ] }, - "execution_count": 19, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -182,7 +238,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.1" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/docs/docs/how_to/query_few_shot.ipynb b/docs/docs/how_to/query_few_shot.ipynb index 6ccfb79d088..2b087ae214c 100644 --- a/docs/docs/how_to/query_few_shot.ipynb +++ b/docs/docs/how_to/query_few_shot.ipynb @@ -35,7 +35,14 @@ "cell_type": "code", "execution_count": 1, "id": "e168ef5c-e54e-49a6-8552-5502854a6f01", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:33:48.329739Z", + "iopub.status.busy": "2024-09-11T02:33:48.329033Z", + "iopub.status.idle": "2024-09-11T02:33:48.334555Z", + "shell.execute_reply": "2024-09-11T02:33:48.334086Z" + } + }, "outputs": [], "source": [ "# %pip install -qU langchain-core langchain-openai" @@ -53,15 +60,23 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "id": "40e2979e-a818-4b96-ac25-039336f94319", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:33:48.337140Z", + "iopub.status.busy": "2024-09-11T02:33:48.336958Z", + "iopub.status.idle": "2024-09-11T02:33:48.342671Z", + "shell.execute_reply": "2024-09-11T02:33:48.342281Z" + } + }, "outputs": [], "source": [ "import getpass\n", "import os\n", "\n", - "os.environ[\"OPENAI_API_KEY\"] = getpass.getpass()\n", + "if \"OPENAI_API_KEY\" not in os.environ:\n", + " os.environ[\"OPENAI_API_KEY\"] = getpass.getpass()\n", "\n", "# Optional, uncomment to trace runs with LangSmith. Sign up here: https://smith.langchain.com.\n", "# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n", @@ -80,9 +95,16 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 3, "id": "0b51dd76-820d-41a4-98c8-893f6fe0d1ea", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:33:48.345004Z", + "iopub.status.busy": "2024-09-11T02:33:48.344838Z", + "iopub.status.idle": "2024-09-11T02:33:48.413166Z", + "shell.execute_reply": "2024-09-11T02:33:48.412908Z" + } + }, "outputs": [], "source": [ "from typing import List, Optional\n", @@ -121,9 +143,16 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 4, "id": "783c03c3-8c72-4f88-9cf4-5829ce6745d6", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:33:48.414805Z", + "iopub.status.busy": "2024-09-11T02:33:48.414700Z", + "iopub.status.idle": "2024-09-11T02:33:49.023858Z", + "shell.execute_reply": "2024-09-11T02:33:49.023547Z" + } + }, "outputs": [], "source": [ "from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder\n", @@ -158,17 +187,24 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 5, "id": "0bcfce06-6f0c-4f9d-a1fc-dc29342d2aae", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:33:49.025536Z", + "iopub.status.busy": "2024-09-11T02:33:49.025437Z", + "iopub.status.idle": "2024-09-11T02:33:50.170550Z", + "shell.execute_reply": "2024-09-11T02:33:50.169835Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "Search(query='web voyager vs reflection agents', sub_queries=['difference between web voyager and reflection agents', 'do web voyager and reflection agents use langgraph'], publish_year=None)" + "Search(query='difference between web voyager and reflection agents', sub_queries=['what is web voyager', 'what are reflection agents', 'do both web voyager and reflection agents use langgraph?'], publish_year=None)" ] }, - "execution_count": 65, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -193,9 +229,16 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 6, "id": "15b4923d-a08e-452d-8889-9a09a57d1095", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:33:50.180367Z", + "iopub.status.busy": "2024-09-11T02:33:50.173961Z", + "iopub.status.idle": "2024-09-11T02:33:50.186703Z", + "shell.execute_reply": "2024-09-11T02:33:50.186090Z" + } + }, "outputs": [], "source": [ "examples = []" @@ -203,9 +246,16 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 7, "id": "da5330e6-827a-40e5-982b-b23b6286b758", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:33:50.189822Z", + "iopub.status.busy": "2024-09-11T02:33:50.189617Z", + "iopub.status.idle": "2024-09-11T02:33:50.195116Z", + "shell.execute_reply": "2024-09-11T02:33:50.194617Z" + } + }, "outputs": [], "source": [ "question = \"What's chat langchain, is it a langchain template?\"\n", @@ -218,9 +268,16 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 8, "id": "580e857a-27df-4ecf-a19c-458dc9244ec8", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:33:50.198178Z", + "iopub.status.busy": "2024-09-11T02:33:50.198002Z", + "iopub.status.idle": "2024-09-11T02:33:50.204115Z", + "shell.execute_reply": "2024-09-11T02:33:50.202534Z" + } + }, "outputs": [], "source": [ "question = \"How to build multi-agent system and stream intermediate steps from it\"\n", @@ -238,9 +295,16 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 9, "id": "fa63310d-69e3-4701-825c-fbb01f8a5a16", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:33:50.207416Z", + "iopub.status.busy": "2024-09-11T02:33:50.207196Z", + "iopub.status.idle": "2024-09-11T02:33:50.212484Z", + "shell.execute_reply": "2024-09-11T02:33:50.211974Z" + } + }, "outputs": [], "source": [ "question = \"LangChain agents vs LangGraph?\"\n", @@ -266,9 +330,16 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 10, "id": "68b03709-9a60-4acf-b96c-cafe1056c6f3", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:33:50.215540Z", + "iopub.status.busy": "2024-09-11T02:33:50.215250Z", + "iopub.status.idle": "2024-09-11T02:33:50.224108Z", + "shell.execute_reply": "2024-09-11T02:33:50.223490Z" + } + }, "outputs": [], "source": [ "import uuid\n", @@ -313,9 +384,16 @@ }, { "cell_type": "code", - "execution_count": 58, + "execution_count": 11, "id": "d9bf9f87-3e6b-4fc2-957b-949b077fab54", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:33:50.227215Z", + "iopub.status.busy": "2024-09-11T02:33:50.226993Z", + "iopub.status.idle": "2024-09-11T02:33:50.231333Z", + "shell.execute_reply": "2024-09-11T02:33:50.230742Z" + } + }, "outputs": [], "source": [ "from langchain_core.prompts import MessagesPlaceholder\n", @@ -329,17 +407,24 @@ }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 12, "id": "e565ccb0-3530-4782-b56b-d1f6d0a8e559", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:33:50.233833Z", + "iopub.status.busy": "2024-09-11T02:33:50.233646Z", + "iopub.status.idle": "2024-09-11T02:33:51.318133Z", + "shell.execute_reply": "2024-09-11T02:33:51.317640Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "Search(query='Difference between web voyager and reflection agents, do they both use LangGraph?', sub_queries=['What is Web Voyager', 'What are Reflection agents', 'Do Web Voyager and Reflection agents use LangGraph'], publish_year=None)" + "Search(query=\"What's the difference between web voyager and reflection agents? Do both use langgraph?\", sub_queries=['What is web voyager', 'What are reflection agents', 'Do web voyager and reflection agents use langgraph?'], publish_year=None)" ] }, - "execution_count": 62, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -377,7 +462,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.1" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/docs/docs/how_to/query_high_cardinality.ipynb b/docs/docs/how_to/query_high_cardinality.ipynb index bc42bc022d7..63c6677659b 100644 --- a/docs/docs/how_to/query_high_cardinality.ipynb +++ b/docs/docs/how_to/query_high_cardinality.ipynb @@ -33,12 +33,20 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "e168ef5c-e54e-49a6-8552-5502854a6f01", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], "source": [ - "# %pip install -qU langchain langchain-community langchain-openai faker langchain-chroma" + "%pip install -qU langchain langchain-community langchain-openai faker langchain-chroma" ] }, { @@ -53,15 +61,23 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "id": "40e2979e-a818-4b96-ac25-039336f94319", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:34:54.036110Z", + "iopub.status.busy": "2024-09-11T02:34:54.035829Z", + "iopub.status.idle": "2024-09-11T02:34:54.038746Z", + "shell.execute_reply": "2024-09-11T02:34:54.038430Z" + } + }, "outputs": [], "source": [ "import getpass\n", "import os\n", "\n", - "os.environ[\"OPENAI_API_KEY\"] = getpass.getpass()\n", + "if \"OPENAI_API_KEY\" not in os.environ:\n", + " os.environ[\"OPENAI_API_KEY\"] = getpass.getpass()\n", "\n", "# Optional, uncomment to trace runs with LangSmith. Sign up here: https://smith.langchain.com.\n", "# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n", @@ -80,9 +96,16 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 3, "id": "e5ba65c2", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:34:54.040738Z", + "iopub.status.busy": "2024-09-11T02:34:54.040515Z", + "iopub.status.idle": "2024-09-11T02:34:54.622643Z", + "shell.execute_reply": "2024-09-11T02:34:54.622382Z" + } + }, "outputs": [], "source": [ "from faker import Faker\n", @@ -102,17 +125,24 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "id": "c901ea97", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:34:54.624195Z", + "iopub.status.busy": "2024-09-11T02:34:54.624106Z", + "iopub.status.idle": "2024-09-11T02:34:54.627231Z", + "shell.execute_reply": "2024-09-11T02:34:54.626971Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "'Hayley Gonzalez'" + "'Jacob Adams'" ] }, - "execution_count": 2, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -123,17 +153,24 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "id": "b0d42ae2", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:34:54.628545Z", + "iopub.status.busy": "2024-09-11T02:34:54.628460Z", + "iopub.status.idle": "2024-09-11T02:34:54.630474Z", + "shell.execute_reply": "2024-09-11T02:34:54.630282Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "'Jesse Knight'" + "'Eric Acevedo'" ] }, - "execution_count": 3, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -154,9 +191,16 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 6, "id": "0ae69afc", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:34:54.631758Z", + "iopub.status.busy": "2024-09-11T02:34:54.631678Z", + "iopub.status.idle": "2024-09-11T02:34:54.666448Z", + "shell.execute_reply": "2024-09-11T02:34:54.666216Z" + } + }, "outputs": [], "source": [ "from pydantic import BaseModel, Field, model_validator" @@ -164,9 +208,16 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "id": "6c9485ce", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:34:54.667852Z", + "iopub.status.busy": "2024-09-11T02:34:54.667733Z", + "iopub.status.idle": "2024-09-11T02:34:54.700224Z", + "shell.execute_reply": "2024-09-11T02:34:54.700004Z" + } + }, "outputs": [], "source": [ "class Search(BaseModel):\n", @@ -176,19 +227,17 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "id": "aebd704a", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/harrisonchase/workplace/langchain/libs/core/langchain_core/_api/beta_decorator.py:86: LangChainBetaWarning: The function `with_structured_output` is in beta. It is actively being worked on, so the API may change.\n", - " warn_beta(\n" - ] + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:34:54.701556Z", + "iopub.status.busy": "2024-09-11T02:34:54.701465Z", + "iopub.status.idle": "2024-09-11T02:34:55.179986Z", + "shell.execute_reply": "2024-09-11T02:34:55.179640Z" } - ], + }, + "outputs": [], "source": [ "from langchain_core.prompts import ChatPromptTemplate\n", "from langchain_core.runnables import RunnablePassthrough\n", @@ -216,17 +265,24 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 9, "id": "cc0d344b", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:34:55.181603Z", + "iopub.status.busy": "2024-09-11T02:34:55.181500Z", + "iopub.status.idle": "2024-09-11T02:34:55.778884Z", + "shell.execute_reply": "2024-09-11T02:34:55.778324Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "Search(query='books about aliens', author='Jesse Knight')" + "Search(query='aliens', author='Jesse Knight')" ] }, - "execution_count": 33, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -245,17 +301,24 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 10, "id": "82b6b2ad", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:34:55.784266Z", + "iopub.status.busy": "2024-09-11T02:34:55.782603Z", + "iopub.status.idle": "2024-09-11T02:34:56.206779Z", + "shell.execute_reply": "2024-09-11T02:34:56.206068Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "Search(query='books about aliens', author='Jess Knight')" + "Search(query='aliens', author='Jess Knight')" ] }, - "execution_count": 34, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -276,9 +339,16 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 11, "id": "98788a94", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:34:56.210043Z", + "iopub.status.busy": "2024-09-11T02:34:56.209657Z", + "iopub.status.idle": "2024-09-11T02:34:56.213962Z", + "shell.execute_reply": "2024-09-11T02:34:56.213413Z" + } + }, "outputs": [], "source": [ "system = \"\"\"Generate a relevant search query for a library system.\n", @@ -299,9 +369,16 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 12, "id": "e65412f5", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:34:56.216144Z", + "iopub.status.busy": "2024-09-11T02:34:56.216005Z", + "iopub.status.idle": "2024-09-11T02:34:56.218754Z", + "shell.execute_reply": "2024-09-11T02:34:56.218416Z" + } + }, "outputs": [], "source": [ "query_analyzer_all = {\"question\": RunnablePassthrough()} | prompt | structured_llm" @@ -317,18 +394,17 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 13, "id": "696b000f", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Error code: 400 - {'error': {'message': \"This model's maximum context length is 16385 tokens. However, your messages resulted in 33885 tokens (33855 in the messages, 30 in the functions). Please reduce the length of the messages or functions.\", 'type': 'invalid_request_error', 'param': 'messages', 'code': 'context_length_exceeded'}}\n" - ] + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:34:56.220827Z", + "iopub.status.busy": "2024-09-11T02:34:56.220680Z", + "iopub.status.idle": "2024-09-11T02:34:58.846872Z", + "shell.execute_reply": "2024-09-11T02:34:58.846273Z" } - ], + }, + "outputs": [], "source": [ "try:\n", " res = query_analyzer_all.invoke(\"what are books about aliens by jess knight\")\n", @@ -346,9 +422,16 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 14, "id": "0f0d0757", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:34:58.850318Z", + "iopub.status.busy": "2024-09-11T02:34:58.850100Z", + "iopub.status.idle": "2024-09-11T02:34:58.873883Z", + "shell.execute_reply": "2024-09-11T02:34:58.873525Z" + } + }, "outputs": [], "source": [ "llm_long = ChatOpenAI(model=\"gpt-4-turbo-preview\", temperature=0)\n", @@ -358,17 +441,24 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 15, "id": "03e5b7b2", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:34:58.875940Z", + "iopub.status.busy": "2024-09-11T02:34:58.875811Z", + "iopub.status.idle": "2024-09-11T02:35:02.947273Z", + "shell.execute_reply": "2024-09-11T02:35:02.946220Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "Search(query='aliens', author='Kevin Knight')" + "Search(query='aliens', author='jess knight')" ] }, - "execution_count": 39, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -389,9 +479,16 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 16, "id": "32b19e07", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:35:02.951939Z", + "iopub.status.busy": "2024-09-11T02:35:02.951583Z", + "iopub.status.idle": "2024-09-11T02:35:41.777839Z", + "shell.execute_reply": "2024-09-11T02:35:41.777392Z" + } + }, "outputs": [], "source": [ "from langchain_chroma import Chroma\n", @@ -403,9 +500,16 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 17, "id": "774cb7b0", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:35:41.780883Z", + "iopub.status.busy": "2024-09-11T02:35:41.780774Z", + "iopub.status.idle": "2024-09-11T02:35:41.782739Z", + "shell.execute_reply": "2024-09-11T02:35:41.782498Z" + } + }, "outputs": [], "source": [ "def select_names(question):\n", @@ -416,9 +520,16 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 18, "id": "1173159c", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:35:41.783992Z", + "iopub.status.busy": "2024-09-11T02:35:41.783913Z", + "iopub.status.idle": "2024-09-11T02:35:41.785911Z", + "shell.execute_reply": "2024-09-11T02:35:41.785632Z" + } + }, "outputs": [], "source": [ "create_prompt = {\n", @@ -429,9 +540,16 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 19, "id": "0a892607", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:35:41.787082Z", + "iopub.status.busy": "2024-09-11T02:35:41.787008Z", + "iopub.status.idle": "2024-09-11T02:35:41.788543Z", + "shell.execute_reply": "2024-09-11T02:35:41.788362Z" + } + }, "outputs": [], "source": [ "query_analyzer_select = create_prompt | structured_llm" @@ -439,17 +557,24 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 20, "id": "8195d7cd", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:35:41.789624Z", + "iopub.status.busy": "2024-09-11T02:35:41.789551Z", + "iopub.status.idle": "2024-09-11T02:35:42.099839Z", + "shell.execute_reply": "2024-09-11T02:35:42.099042Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "ChatPromptValue(messages=[SystemMessage(content='Generate a relevant search query for a library system.\\n\\n`author` attribute MUST be one of:\\n\\nJesse Knight, Kelly Knight, Scott Knight, Richard Knight, Andrew Knight, Katherine Knight, Erica Knight, Ashley Knight, Becky Knight, Kevin Knight\\n\\nDo NOT hallucinate author name!'), HumanMessage(content='what are books by jess knight')])" + "ChatPromptValue(messages=[SystemMessage(content='Generate a relevant search query for a library system.\\n\\n`author` attribute MUST be one of:\\n\\nJennifer Knight, Jill Knight, John Knight, Dr. Jeffrey Knight, Christopher Knight, Andrea Knight, Brandy Knight, Jennifer Keller, Becky Chambers, Sarah Knapp\\n\\nDo NOT hallucinate author name!'), HumanMessage(content='what are books by jess knight')])" ] }, - "execution_count": 54, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -460,17 +585,24 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 21, "id": "d3228b4e", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:35:42.106571Z", + "iopub.status.busy": "2024-09-11T02:35:42.105861Z", + "iopub.status.idle": "2024-09-11T02:35:42.909738Z", + "shell.execute_reply": "2024-09-11T02:35:42.908875Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "Search(query='books about aliens', author='Jesse Knight')" + "Search(query='books about aliens', author='Jennifer Knight')" ] }, - "execution_count": 55, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } @@ -492,9 +624,16 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 22, "id": "a2e8b434", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:35:42.915376Z", + "iopub.status.busy": "2024-09-11T02:35:42.914923Z", + "iopub.status.idle": "2024-09-11T02:35:42.923958Z", + "shell.execute_reply": "2024-09-11T02:35:42.922391Z" + } + }, "outputs": [], "source": [ "class Search(BaseModel):\n", @@ -514,9 +653,16 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 23, "id": "919c0601", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:35:42.927718Z", + "iopub.status.busy": "2024-09-11T02:35:42.927428Z", + "iopub.status.idle": "2024-09-11T02:35:42.933784Z", + "shell.execute_reply": "2024-09-11T02:35:42.933344Z" + } + }, "outputs": [], "source": [ "system = \"\"\"Generate a relevant search query for a library system\"\"\"\n", @@ -534,17 +680,24 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 24, "id": "6c4f3e9a", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:35:42.936506Z", + "iopub.status.busy": "2024-09-11T02:35:42.936186Z", + "iopub.status.idle": "2024-09-11T02:35:43.711754Z", + "shell.execute_reply": "2024-09-11T02:35:43.710695Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "Search(query='books about aliens', author='Jesse Knight')" + "Search(query='aliens', author='John Knight')" ] }, - "execution_count": 50, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -555,9 +708,16 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "id": "a309cb11", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:35:43.717567Z", + "iopub.status.busy": "2024-09-11T02:35:43.717189Z", + "iopub.status.idle": "2024-09-11T02:35:43.722339Z", + "shell.execute_reply": "2024-09-11T02:35:43.720537Z" + } + }, "outputs": [], "source": [ "# TODO: show trigram similarity" diff --git a/docs/docs/how_to/query_multiple_queries.ipynb b/docs/docs/how_to/query_multiple_queries.ipynb index 9fc0e3dea28..79bf9be63a2 100644 --- a/docs/docs/how_to/query_multiple_queries.ipynb +++ b/docs/docs/how_to/query_multiple_queries.ipynb @@ -33,10 +33,25 @@ "cell_type": "code", "execution_count": 1, "id": "e168ef5c-e54e-49a6-8552-5502854a6f01", - "metadata": {}, - "outputs": [], + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:41:53.160868Z", + "iopub.status.busy": "2024-09-11T02:41:53.160512Z", + "iopub.status.idle": "2024-09-11T02:41:57.605370Z", + "shell.execute_reply": "2024-09-11T02:41:57.604888Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], "source": [ - "# %pip install -qU langchain langchain-community langchain-openai langchain-chroma" + "%pip install -qU langchain langchain-community langchain-openai langchain-chroma" ] }, { @@ -51,15 +66,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "40e2979e-a818-4b96-ac25-039336f94319", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:41:57.607874Z", + "iopub.status.busy": "2024-09-11T02:41:57.607697Z", + "iopub.status.idle": "2024-09-11T02:41:57.610422Z", + "shell.execute_reply": "2024-09-11T02:41:57.610012Z" + } + }, "outputs": [], "source": [ "import getpass\n", "import os\n", "\n", - "os.environ[\"OPENAI_API_KEY\"] = getpass.getpass()\n", + "if \"OPENAI_API_KEY\" not in os.environ:\n", + " os.environ[\"OPENAI_API_KEY\"] = getpass.getpass()\n", "\n", "# Optional, uncomment to trace runs with LangSmith. Sign up here: https://smith.langchain.com.\n", "# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n", @@ -78,9 +101,16 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 3, "id": "1f621694", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:41:57.612276Z", + "iopub.status.busy": "2024-09-11T02:41:57.612146Z", + "iopub.status.idle": "2024-09-11T02:41:59.074590Z", + "shell.execute_reply": "2024-09-11T02:41:59.074052Z" + } + }, "outputs": [], "source": [ "from langchain_chroma import Chroma\n", @@ -108,9 +138,16 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "id": "0b51dd76-820d-41a4-98c8-893f6fe0d1ea", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:41:59.077712Z", + "iopub.status.busy": "2024-09-11T02:41:59.077514Z", + "iopub.status.idle": "2024-09-11T02:41:59.081509Z", + "shell.execute_reply": "2024-09-11T02:41:59.081112Z" + } + }, "outputs": [], "source": [ "from typing import List, Optional\n", @@ -129,19 +166,17 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "id": "783c03c3-8c72-4f88-9cf4-5829ce6745d6", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/harrisonchase/workplace/langchain/libs/core/langchain_core/_api/beta_decorator.py:86: LangChainBetaWarning: The function `with_structured_output` is in beta. It is actively being worked on, so the API may change.\n", - " warn_beta(\n" - ] + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:41:59.083613Z", + "iopub.status.busy": "2024-09-11T02:41:59.083492Z", + "iopub.status.idle": "2024-09-11T02:41:59.204636Z", + "shell.execute_reply": "2024-09-11T02:41:59.204377Z" } - ], + }, + "outputs": [], "source": [ "from langchain_core.output_parsers.openai_tools import PydanticToolsParser\n", "from langchain_core.prompts import ChatPromptTemplate\n", @@ -174,17 +209,24 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "id": "bc1d3863", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:41:59.206178Z", + "iopub.status.busy": "2024-09-11T02:41:59.206101Z", + "iopub.status.idle": "2024-09-11T02:41:59.817758Z", + "shell.execute_reply": "2024-09-11T02:41:59.817310Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "Search(queries=['Harrison work location'])" + "Search(queries=['Harrison Work', 'Harrison employment history'])" ] }, - "execution_count": 4, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -195,17 +237,24 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "id": "af62af17-4f90-4dbd-a8b4-dfff51f1db95", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:41:59.820168Z", + "iopub.status.busy": "2024-09-11T02:41:59.819990Z", + "iopub.status.idle": "2024-09-11T02:42:00.309034Z", + "shell.execute_reply": "2024-09-11T02:42:00.308578Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "Search(queries=['Harrison work place', 'Ankush work place'])" + "Search(queries=['Harrison work history', 'Ankush work history'])" ] }, - "execution_count": 5, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -226,9 +275,16 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "id": "1e047d87", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:00.311131Z", + "iopub.status.busy": "2024-09-11T02:42:00.310972Z", + "iopub.status.idle": "2024-09-11T02:42:00.313365Z", + "shell.execute_reply": "2024-09-11T02:42:00.313025Z" + } + }, "outputs": [], "source": [ "from langchain_core.runnables import chain" @@ -236,9 +292,16 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 9, "id": "8dac7866", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:00.315138Z", + "iopub.status.busy": "2024-09-11T02:42:00.315016Z", + "iopub.status.idle": "2024-09-11T02:42:00.317427Z", + "shell.execute_reply": "2024-09-11T02:42:00.317088Z" + } + }, "outputs": [], "source": [ "@chain\n", @@ -255,17 +318,25 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 10, "id": "232ad8a7-7990-4066-9228-d35a555f7293", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:00.318951Z", + "iopub.status.busy": "2024-09-11T02:42:00.318829Z", + "iopub.status.idle": "2024-09-11T02:42:01.512855Z", + "shell.execute_reply": "2024-09-11T02:42:01.512321Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "[Document(page_content='Harrison worked at Kensho')]" + "[Document(page_content='Harrison worked at Kensho'),\n", + " Document(page_content='Harrison worked at Kensho')]" ] }, - "execution_count": 33, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -276,9 +347,16 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 11, "id": "28e14ba5", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:01.515743Z", + "iopub.status.busy": "2024-09-11T02:42:01.515400Z", + "iopub.status.idle": "2024-09-11T02:42:02.349930Z", + "shell.execute_reply": "2024-09-11T02:42:02.349382Z" + } + }, "outputs": [ { "data": { @@ -287,7 +365,7 @@ " Document(page_content='Ankush worked at Facebook')]" ] }, - "execution_count": 34, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -321,7 +399,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.1" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/docs/docs/how_to/query_multiple_retrievers.ipynb b/docs/docs/how_to/query_multiple_retrievers.ipynb index 276a849b99c..9e6d7861dca 100644 --- a/docs/docs/how_to/query_multiple_retrievers.ipynb +++ b/docs/docs/how_to/query_multiple_retrievers.ipynb @@ -33,10 +33,25 @@ "cell_type": "code", "execution_count": 1, "id": "e168ef5c-e54e-49a6-8552-5502854a6f01", - "metadata": {}, - "outputs": [], + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:13.105266Z", + "iopub.status.busy": "2024-09-11T02:42:13.104556Z", + "iopub.status.idle": "2024-09-11T02:42:17.936922Z", + "shell.execute_reply": "2024-09-11T02:42:17.936478Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], "source": [ - "# %pip install -qU langchain langchain-community langchain-openai langchain-chroma" + "%pip install -qU langchain langchain-community langchain-openai langchain-chroma" ] }, { @@ -51,15 +66,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "40e2979e-a818-4b96-ac25-039336f94319", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:17.939072Z", + "iopub.status.busy": "2024-09-11T02:42:17.938929Z", + "iopub.status.idle": "2024-09-11T02:42:17.941266Z", + "shell.execute_reply": "2024-09-11T02:42:17.940968Z" + } + }, "outputs": [], "source": [ "import getpass\n", "import os\n", "\n", - "os.environ[\"OPENAI_API_KEY\"] = getpass.getpass()\n", + "if \"OPENAI_API_KEY\" not in os.environ:\n", + " os.environ[\"OPENAI_API_KEY\"] = getpass.getpass()\n", "\n", "# Optional, uncomment to trace runs with LangSmith. Sign up here: https://smith.langchain.com.\n", "# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n", @@ -78,9 +101,16 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 3, "id": "1f621694", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:17.942794Z", + "iopub.status.busy": "2024-09-11T02:42:17.942674Z", + "iopub.status.idle": "2024-09-11T02:42:19.939459Z", + "shell.execute_reply": "2024-09-11T02:42:19.938842Z" + } + }, "outputs": [], "source": [ "from langchain_chroma import Chroma\n", @@ -110,9 +140,16 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 4, "id": "0b51dd76-820d-41a4-98c8-893f6fe0d1ea", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:19.942780Z", + "iopub.status.busy": "2024-09-11T02:42:19.942567Z", + "iopub.status.idle": "2024-09-11T02:42:19.947709Z", + "shell.execute_reply": "2024-09-11T02:42:19.947252Z" + } + }, "outputs": [], "source": [ "from typing import List, Optional\n", @@ -135,9 +172,16 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 5, "id": "783c03c3-8c72-4f88-9cf4-5829ce6745d6", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:19.949936Z", + "iopub.status.busy": "2024-09-11T02:42:19.949778Z", + "iopub.status.idle": "2024-09-11T02:42:20.073883Z", + "shell.execute_reply": "2024-09-11T02:42:20.073556Z" + } + }, "outputs": [], "source": [ "from langchain_core.output_parsers.openai_tools import PydanticToolsParser\n", @@ -169,17 +213,24 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 6, "id": "bc1d3863", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:20.075511Z", + "iopub.status.busy": "2024-09-11T02:42:20.075428Z", + "iopub.status.idle": "2024-09-11T02:42:20.902011Z", + "shell.execute_reply": "2024-09-11T02:42:20.901558Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "Search(query='workplace', person='HARRISON')" + "Search(query='work history', person='HARRISON')" ] }, - "execution_count": 19, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -190,17 +241,24 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 7, "id": "af62af17-4f90-4dbd-a8b4-dfff51f1db95", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:20.904384Z", + "iopub.status.busy": "2024-09-11T02:42:20.904195Z", + "iopub.status.idle": "2024-09-11T02:42:21.468172Z", + "shell.execute_reply": "2024-09-11T02:42:21.467639Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "Search(query='workplace', person='ANKUSH')" + "Search(query='work history', person='ANKUSH')" ] }, - "execution_count": 20, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -221,9 +279,16 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 8, "id": "1e047d87", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:21.470953Z", + "iopub.status.busy": "2024-09-11T02:42:21.470736Z", + "iopub.status.idle": "2024-09-11T02:42:21.473544Z", + "shell.execute_reply": "2024-09-11T02:42:21.473064Z" + } + }, "outputs": [], "source": [ "from langchain_core.runnables import chain" @@ -231,9 +296,16 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 9, "id": "4ec0c7fe", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:21.476024Z", + "iopub.status.busy": "2024-09-11T02:42:21.475835Z", + "iopub.status.idle": "2024-09-11T02:42:21.478359Z", + "shell.execute_reply": "2024-09-11T02:42:21.477932Z" + } + }, "outputs": [], "source": [ "retrievers = {\n", @@ -244,9 +316,16 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 10, "id": "8dac7866", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:21.480247Z", + "iopub.status.busy": "2024-09-11T02:42:21.480084Z", + "iopub.status.idle": "2024-09-11T02:42:21.482732Z", + "shell.execute_reply": "2024-09-11T02:42:21.482382Z" + } + }, "outputs": [], "source": [ "@chain\n", @@ -258,9 +337,16 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 11, "id": "232ad8a7-7990-4066-9228-d35a555f7293", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:21.484480Z", + "iopub.status.busy": "2024-09-11T02:42:21.484361Z", + "iopub.status.idle": "2024-09-11T02:42:22.136704Z", + "shell.execute_reply": "2024-09-11T02:42:22.136244Z" + } + }, "outputs": [ { "data": { @@ -268,7 +354,7 @@ "[Document(page_content='Harrison worked at Kensho')]" ] }, - "execution_count": 24, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -279,9 +365,16 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 12, "id": "28e14ba5", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:22.139305Z", + "iopub.status.busy": "2024-09-11T02:42:22.139106Z", + "iopub.status.idle": "2024-09-11T02:42:23.479739Z", + "shell.execute_reply": "2024-09-11T02:42:23.479170Z" + } + }, "outputs": [ { "data": { @@ -289,7 +382,7 @@ "[Document(page_content='Ankush worked at Facebook')]" ] }, - "execution_count": 25, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -323,7 +416,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.1" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/docs/docs/how_to/query_no_queries.ipynb b/docs/docs/how_to/query_no_queries.ipynb index c7a62cf5935..0024e5e608f 100644 --- a/docs/docs/how_to/query_no_queries.ipynb +++ b/docs/docs/how_to/query_no_queries.ipynb @@ -35,10 +35,25 @@ "cell_type": "code", "execution_count": 1, "id": "e168ef5c-e54e-49a6-8552-5502854a6f01", - "metadata": {}, - "outputs": [], + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:33.121714Z", + "iopub.status.busy": "2024-09-11T02:42:33.121392Z", + "iopub.status.idle": "2024-09-11T02:42:36.998607Z", + "shell.execute_reply": "2024-09-11T02:42:36.998126Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Note: you may need to restart the kernel to use updated packages.\n" + ] + } + ], "source": [ - "# %pip install -qU langchain langchain-community langchain-openai langchain-chroma" + "%pip install -qU langchain langchain-community langchain-openai langchain-chroma" ] }, { @@ -53,15 +68,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "40e2979e-a818-4b96-ac25-039336f94319", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:37.001017Z", + "iopub.status.busy": "2024-09-11T02:42:37.000859Z", + "iopub.status.idle": "2024-09-11T02:42:37.003704Z", + "shell.execute_reply": "2024-09-11T02:42:37.003335Z" + } + }, "outputs": [], "source": [ "import getpass\n", "import os\n", "\n", - "os.environ[\"OPENAI_API_KEY\"] = getpass.getpass()\n", + "if \"OPENAI_API_KEY\" not in os.environ:\n", + " os.environ[\"OPENAI_API_KEY\"] = getpass.getpass()\n", "\n", "# Optional, uncomment to trace runs with LangSmith. Sign up here: https://smith.langchain.com.\n", "# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n", @@ -80,9 +103,16 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 3, "id": "1f621694", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:37.005644Z", + "iopub.status.busy": "2024-09-11T02:42:37.005493Z", + "iopub.status.idle": "2024-09-11T02:42:38.288481Z", + "shell.execute_reply": "2024-09-11T02:42:38.287904Z" + } + }, "outputs": [], "source": [ "from langchain_chroma import Chroma\n", @@ -110,9 +140,16 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "id": "0b51dd76-820d-41a4-98c8-893f6fe0d1ea", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:38.291700Z", + "iopub.status.busy": "2024-09-11T02:42:38.291468Z", + "iopub.status.idle": "2024-09-11T02:42:38.295796Z", + "shell.execute_reply": "2024-09-11T02:42:38.295205Z" + } + }, "outputs": [], "source": [ "from typing import Optional\n", @@ -131,9 +168,16 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "id": "783c03c3-8c72-4f88-9cf4-5829ce6745d6", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:38.297840Z", + "iopub.status.busy": "2024-09-11T02:42:38.297712Z", + "iopub.status.idle": "2024-09-11T02:42:38.420456Z", + "shell.execute_reply": "2024-09-11T02:42:38.420140Z" + } + }, "outputs": [], "source": [ "from langchain_core.prompts import ChatPromptTemplate\n", @@ -164,17 +208,24 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "id": "bc1d3863", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:38.421934Z", + "iopub.status.busy": "2024-09-11T02:42:38.421831Z", + "iopub.status.idle": "2024-09-11T02:42:39.048915Z", + "shell.execute_reply": "2024-09-11T02:42:39.048519Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_ZnoVX4j9Mn8wgChaORyd1cvq', 'function': {'arguments': '{\"query\":\"Harrison\"}', 'name': 'Search'}, 'type': 'function'}]})" + "AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_korLZrh08PTRL94f4L7rFqdj', 'function': {'arguments': '{\"query\":\"Harrison\"}', 'name': 'Search'}, 'type': 'function'}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 14, 'prompt_tokens': 95, 'total_tokens': 109}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_483d39d857', 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-ea94d376-37bf-4f80-abe6-e3b42b767ea0-0', tool_calls=[{'name': 'Search', 'args': {'query': 'Harrison'}, 'id': 'call_korLZrh08PTRL94f4L7rFqdj', 'type': 'tool_call'}], usage_metadata={'input_tokens': 95, 'output_tokens': 14, 'total_tokens': 109})" ] }, - "execution_count": 4, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -185,17 +236,24 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "id": "af62af17-4f90-4dbd-a8b4-dfff51f1db95", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:39.050923Z", + "iopub.status.busy": "2024-09-11T02:42:39.050785Z", + "iopub.status.idle": "2024-09-11T02:42:40.090421Z", + "shell.execute_reply": "2024-09-11T02:42:40.089454Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "AIMessage(content='Hello! How can I assist you today?')" + "AIMessage(content='Hello! How can I assist you today?', additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 10, 'prompt_tokens': 93, 'total_tokens': 103}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_483d39d857', 'finish_reason': 'stop', 'logprobs': None}, id='run-ebdfc44a-455a-4ca6-be85-84559886b1e1-0', usage_metadata={'input_tokens': 93, 'output_tokens': 10, 'total_tokens': 103})" ] }, - "execution_count": 5, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -216,9 +274,16 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "id": "1e047d87", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:40.093716Z", + "iopub.status.busy": "2024-09-11T02:42:40.093472Z", + "iopub.status.idle": "2024-09-11T02:42:40.097732Z", + "shell.execute_reply": "2024-09-11T02:42:40.097274Z" + } + }, "outputs": [], "source": [ "from langchain_core.output_parsers.openai_tools import PydanticToolsParser\n", @@ -229,9 +294,16 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 9, "id": "8dac7866", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:40.100028Z", + "iopub.status.busy": "2024-09-11T02:42:40.099882Z", + "iopub.status.idle": "2024-09-11T02:42:40.103105Z", + "shell.execute_reply": "2024-09-11T02:42:40.102734Z" + } + }, "outputs": [], "source": [ "@chain\n", @@ -248,9 +320,16 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 10, "id": "232ad8a7-7990-4066-9228-d35a555f7293", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:40.105092Z", + "iopub.status.busy": "2024-09-11T02:42:40.104917Z", + "iopub.status.idle": "2024-09-11T02:42:41.341967Z", + "shell.execute_reply": "2024-09-11T02:42:41.341455Z" + } + }, "outputs": [ { "name": "stderr", @@ -265,7 +344,7 @@ "[Document(page_content='Harrison worked at Kensho')]" ] }, - "execution_count": 8, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -276,17 +355,24 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 11, "id": "28e14ba5", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:42:41.344639Z", + "iopub.status.busy": "2024-09-11T02:42:41.344411Z", + "iopub.status.idle": "2024-09-11T02:42:41.798332Z", + "shell.execute_reply": "2024-09-11T02:42:41.798054Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "AIMessage(content='Hello! How can I assist you today?')" + "AIMessage(content='Hello! How can I assist you today?', additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 10, 'prompt_tokens': 93, 'total_tokens': 103}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_483d39d857', 'finish_reason': 'stop', 'logprobs': None}, id='run-e87f058d-30c0-4075-8a89-a01b982d557e-0', usage_metadata={'input_tokens': 93, 'output_tokens': 10, 'total_tokens': 103})" ] }, - "execution_count": 9, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -320,7 +406,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.1" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/docs/docs/how_to/tool_calling.ipynb b/docs/docs/how_to/tool_calling.ipynb index 38e4aee0b49..6558f4843b5 100644 --- a/docs/docs/how_to/tool_calling.ipynb +++ b/docs/docs/how_to/tool_calling.ipynb @@ -64,7 +64,14 @@ { "cell_type": "code", "execution_count": 1, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:43:40.609832Z", + "iopub.status.busy": "2024-09-11T02:43:40.609565Z", + "iopub.status.idle": "2024-09-11T02:43:40.617860Z", + "shell.execute_reply": "2024-09-11T02:43:40.617391Z" + } + }, "outputs": [], "source": [ "# The function name, type hints, and docstring are all part of the tool\n", @@ -109,7 +116,14 @@ { "cell_type": "code", "execution_count": 2, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:43:40.620257Z", + "iopub.status.busy": "2024-09-11T02:43:40.620084Z", + "iopub.status.idle": "2024-09-11T02:43:40.689214Z", + "shell.execute_reply": "2024-09-11T02:43:40.688938Z" + } + }, "outputs": [], "source": [ "from pydantic import BaseModel, Field\n", @@ -144,7 +158,14 @@ { "cell_type": "code", "execution_count": 3, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:43:40.690850Z", + "iopub.status.busy": "2024-09-11T02:43:40.690739Z", + "iopub.status.idle": "2024-09-11T02:43:40.693436Z", + "shell.execute_reply": "2024-09-11T02:43:40.693199Z" + } + }, "outputs": [], "source": [ "from typing_extensions import Annotated, TypedDict\n", @@ -201,7 +222,8 @@ "\n", "from langchain_openai import ChatOpenAI\n", "\n", - "os.environ[\"OPENAI_API_KEY\"] = getpass()\n", + "if \"OPENAI_API_KEY\" not in os.environ:\n", + " os.environ[\"OPENAI_API_KEY\"] = getpass()\n", "\n", "llm = ChatOpenAI(model=\"gpt-4o-mini\", temperature=0)" ] @@ -209,12 +231,19 @@ { "cell_type": "code", "execution_count": 5, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:43:42.447839Z", + "iopub.status.busy": "2024-09-11T02:43:42.447760Z", + "iopub.status.idle": "2024-09-11T02:43:43.181171Z", + "shell.execute_reply": "2024-09-11T02:43:43.180680Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_BwYJ4UgU5pRVCBOUmiu7NhF9', 'function': {'arguments': '{\"a\":3,\"b\":12}', 'name': 'multiply'}, 'type': 'function'}]}, response_metadata={'token_usage': {'completion_tokens': 17, 'prompt_tokens': 80, 'total_tokens': 97}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_ba606877f9', 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-7f05e19e-4561-40e2-a2d0-8f4e28e9a00f-0', tool_calls=[{'name': 'multiply', 'args': {'a': 3, 'b': 12}, 'id': 'call_BwYJ4UgU5pRVCBOUmiu7NhF9', 'type': 'tool_call'}], usage_metadata={'input_tokens': 80, 'output_tokens': 17, 'total_tokens': 97})" + "AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_iXj4DiW1p7WLjTAQMRO0jxMs', 'function': {'arguments': '{\"a\":3,\"b\":12}', 'name': 'multiply'}, 'type': 'function'}], 'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 17, 'prompt_tokens': 80, 'total_tokens': 97}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_483d39d857', 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-0b620986-3f62-4df7-9ba3-4595089f9ad4-0', tool_calls=[{'name': 'multiply', 'args': {'a': 3, 'b': 12}, 'id': 'call_iXj4DiW1p7WLjTAQMRO0jxMs', 'type': 'tool_call'}], usage_metadata={'input_tokens': 80, 'output_tokens': 17, 'total_tokens': 97})" ] }, "execution_count": 5, @@ -259,18 +288,25 @@ { "cell_type": "code", "execution_count": 6, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:43:43.184004Z", + "iopub.status.busy": "2024-09-11T02:43:43.183777Z", + "iopub.status.idle": "2024-09-11T02:43:43.743024Z", + "shell.execute_reply": "2024-09-11T02:43:43.742171Z" + } + }, "outputs": [ { "data": { "text/plain": [ "[{'name': 'multiply',\n", " 'args': {'a': 3, 'b': 12},\n", - " 'id': 'call_rcdMie7E89Xx06lEKKxJyB5N',\n", + " 'id': 'call_1fyhJAbJHuKQe6n0PacubGsL',\n", " 'type': 'tool_call'},\n", " {'name': 'add',\n", " 'args': {'a': 11, 'b': 49},\n", - " 'id': 'call_nheGN8yfvSJsnIuGZaXihou3',\n", + " 'id': 'call_fc2jVkKzwuPWyU7kS9qn1hyG',\n", " 'type': 'tool_call'}]" ] }, @@ -306,7 +342,14 @@ { "cell_type": "code", "execution_count": 7, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:43:43.746273Z", + "iopub.status.busy": "2024-09-11T02:43:43.746020Z", + "iopub.status.idle": "2024-09-11T02:43:44.586236Z", + "shell.execute_reply": "2024-09-11T02:43:44.585619Z" + } + }, "outputs": [ { "data": { diff --git a/docs/docs/how_to/tool_runtime.ipynb b/docs/docs/how_to/tool_runtime.ipynb index 855060a8ead..9841d9d2aa4 100644 --- a/docs/docs/how_to/tool_runtime.ipynb +++ b/docs/docs/how_to/tool_runtime.ipynb @@ -55,13 +55,20 @@ { "cell_type": "code", "execution_count": 1, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:51.802901Z", + "iopub.status.busy": "2024-09-11T02:52:51.802682Z", + "iopub.status.idle": "2024-09-11T02:52:52.398167Z", + "shell.execute_reply": "2024-09-11T02:52:52.397911Z" + } + }, "outputs": [], "source": [ "# | output: false\n", "# | echo: false\n", "\n", - "# %pip install -qU langchain langchain_openai\n", + "%pip install -qU langchain langchain_openai\n", "\n", "import os\n", "from getpass import getpass\n", @@ -86,7 +93,14 @@ { "cell_type": "code", "execution_count": 2, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:52.399922Z", + "iopub.status.busy": "2024-09-11T02:52:52.399796Z", + "iopub.status.idle": "2024-09-11T02:52:52.406349Z", + "shell.execute_reply": "2024-09-11T02:52:52.406077Z" + } + }, "outputs": [], "source": [ "from typing import List\n", @@ -141,22 +155,29 @@ { "cell_type": "code", "execution_count": 3, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:52.407763Z", + "iopub.status.busy": "2024-09-11T02:52:52.407691Z", + "iopub.status.idle": "2024-09-11T02:52:52.411761Z", + "shell.execute_reply": "2024-09-11T02:52:52.411512Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "{'title': 'update_favorite_petsSchema',\n", - " 'description': 'Add the list of favorite pets.',\n", - " 'type': 'object',\n", - " 'properties': {'pets': {'title': 'Pets',\n", - " 'description': 'List of favorite pets to set.',\n", - " 'type': 'array',\n", - " 'items': {'type': 'string'}},\n", - " 'user_id': {'title': 'User Id',\n", - " 'description': \"User's ID.\",\n", + "{'description': 'Add the list of favorite pets.',\n", + " 'properties': {'pets': {'description': 'List of favorite pets to set.',\n", + " 'items': {'type': 'string'},\n", + " 'title': 'Pets',\n", + " 'type': 'array'},\n", + " 'user_id': {'description': \"User's ID.\",\n", + " 'title': 'User Id',\n", " 'type': 'string'}},\n", - " 'required': ['pets', 'user_id']}" + " 'required': ['pets', 'user_id'],\n", + " 'title': 'update_favorite_petsSchema',\n", + " 'type': 'object'}" ] }, "execution_count": 3, @@ -178,19 +199,26 @@ { "cell_type": "code", "execution_count": 4, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:52.427826Z", + "iopub.status.busy": "2024-09-11T02:52:52.427691Z", + "iopub.status.idle": "2024-09-11T02:52:52.431791Z", + "shell.execute_reply": "2024-09-11T02:52:52.431574Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "{'title': 'update_favorite_pets',\n", - " 'description': 'Add the list of favorite pets.',\n", - " 'type': 'object',\n", - " 'properties': {'pets': {'title': 'Pets',\n", - " 'description': 'List of favorite pets to set.',\n", - " 'type': 'array',\n", - " 'items': {'type': 'string'}}},\n", - " 'required': ['pets']}" + "{'description': 'Add the list of favorite pets.',\n", + " 'properties': {'pets': {'description': 'List of favorite pets to set.',\n", + " 'items': {'type': 'string'},\n", + " 'title': 'Pets',\n", + " 'type': 'array'}},\n", + " 'required': ['pets'],\n", + " 'title': 'update_favorite_pets',\n", + " 'type': 'object'}" ] }, "execution_count": 4, @@ -212,7 +240,14 @@ { "cell_type": "code", "execution_count": 5, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:52.433096Z", + "iopub.status.busy": "2024-09-11T02:52:52.433014Z", + "iopub.status.idle": "2024-09-11T02:52:52.437499Z", + "shell.execute_reply": "2024-09-11T02:52:52.437239Z" + } + }, "outputs": [ { "name": "stdout", @@ -240,14 +275,21 @@ { "cell_type": "code", "execution_count": 6, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:52.439148Z", + "iopub.status.busy": "2024-09-11T02:52:52.438742Z", + "iopub.status.idle": "2024-09-11T02:52:53.394524Z", + "shell.execute_reply": "2024-09-11T02:52:53.394005Z" + } + }, "outputs": [ { "data": { "text/plain": [ "[{'name': 'update_favorite_pets',\n", " 'args': {'pets': ['cats', 'parrots']},\n", - " 'id': 'call_W3cn4lZmJlyk8PCrKN4PRwqB',\n", + " 'id': 'call_pZ6XVREGh1L0BBSsiGIf1xVm',\n", " 'type': 'tool_call'}]" ] }, @@ -284,14 +326,21 @@ { "cell_type": "code", "execution_count": 7, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:53.397134Z", + "iopub.status.busy": "2024-09-11T02:52:53.396972Z", + "iopub.status.idle": "2024-09-11T02:52:53.403332Z", + "shell.execute_reply": "2024-09-11T02:52:53.402787Z" + } + }, "outputs": [ { "data": { "text/plain": [ "[{'name': 'update_favorite_pets',\n", " 'args': {'pets': ['cats', 'parrots'], 'user_id': '123'},\n", - " 'id': 'call_W3cn4lZmJlyk8PCrKN4PRwqB',\n", + " 'id': 'call_pZ6XVREGh1L0BBSsiGIf1xVm',\n", " 'type': 'tool_call'}]" ] }, @@ -329,12 +378,19 @@ { "cell_type": "code", "execution_count": 8, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:53.405183Z", + "iopub.status.busy": "2024-09-11T02:52:53.405048Z", + "iopub.status.idle": "2024-09-11T02:52:54.248576Z", + "shell.execute_reply": "2024-09-11T02:52:54.248107Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "[ToolMessage(content='null', name='update_favorite_pets', tool_call_id='call_HUyF6AihqANzEYxQnTUKxkXj')]" + "[ToolMessage(content='null', name='update_favorite_pets', tool_call_id='call_oYCD0THSedHTbwNAY3NW6uUj')]" ] }, "execution_count": 8, @@ -365,7 +421,14 @@ { "cell_type": "code", "execution_count": 9, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:54.251169Z", + "iopub.status.busy": "2024-09-11T02:52:54.250948Z", + "iopub.status.idle": "2024-09-11T02:52:54.254279Z", + "shell.execute_reply": "2024-09-11T02:52:54.253889Z" + } + }, "outputs": [ { "data": { @@ -394,22 +457,29 @@ { "cell_type": "code", "execution_count": 10, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:54.256425Z", + "iopub.status.busy": "2024-09-11T02:52:54.256279Z", + "iopub.status.idle": "2024-09-11T02:52:54.262533Z", + "shell.execute_reply": "2024-09-11T02:52:54.262228Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "{'title': 'UpdateFavoritePetsSchema',\n", - " 'description': 'Update list of favorite pets',\n", - " 'type': 'object',\n", - " 'properties': {'pets': {'title': 'Pets',\n", - " 'description': 'List of favorite pets to set.',\n", - " 'type': 'array',\n", - " 'items': {'type': 'string'}},\n", - " 'user_id': {'title': 'User Id',\n", - " 'description': \"User's ID.\",\n", + "{'description': 'Update list of favorite pets',\n", + " 'properties': {'pets': {'description': 'List of favorite pets to set.',\n", + " 'items': {'type': 'string'},\n", + " 'title': 'Pets',\n", + " 'type': 'array'},\n", + " 'user_id': {'description': \"User's ID.\",\n", + " 'title': 'User Id',\n", " 'type': 'string'}},\n", - " 'required': ['pets', 'user_id']}" + " 'required': ['pets', 'user_id'],\n", + " 'title': 'UpdateFavoritePetsSchema',\n", + " 'type': 'object'}" ] }, "execution_count": 10, @@ -440,19 +510,26 @@ { "cell_type": "code", "execution_count": 11, - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:54.264192Z", + "iopub.status.busy": "2024-09-11T02:52:54.264074Z", + "iopub.status.idle": "2024-09-11T02:52:54.267400Z", + "shell.execute_reply": "2024-09-11T02:52:54.267113Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "{'title': 'update_favorite_pets',\n", - " 'description': 'Update list of favorite pets',\n", - " 'type': 'object',\n", - " 'properties': {'pets': {'title': 'Pets',\n", - " 'description': 'List of favorite pets to set.',\n", - " 'type': 'array',\n", - " 'items': {'type': 'string'}}},\n", - " 'required': ['pets']}" + "{'description': 'Update list of favorite pets',\n", + " 'properties': {'pets': {'description': 'List of favorite pets to set.',\n", + " 'items': {'type': 'string'},\n", + " 'title': 'Pets',\n", + " 'type': 'array'}},\n", + " 'required': ['pets'],\n", + " 'title': 'update_favorite_pets',\n", + " 'type': 'object'}" ] }, "execution_count": 11, @@ -466,26 +543,33 @@ }, { "cell_type": "code", - "execution_count": 22, - "metadata": {}, + "execution_count": 12, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:54.269027Z", + "iopub.status.busy": "2024-09-11T02:52:54.268905Z", + "iopub.status.idle": "2024-09-11T02:52:54.276123Z", + "shell.execute_reply": "2024-09-11T02:52:54.275876Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "{'title': 'UpdateFavoritePetsSchema',\n", - " 'description': 'Update list of favorite pets',\n", - " 'type': 'object',\n", - " 'properties': {'pets': {'title': 'Pets',\n", - " 'description': 'List of favorite pets to set.',\n", - " 'type': 'array',\n", - " 'items': {'type': 'string'}},\n", - " 'user_id': {'title': 'User Id',\n", - " 'description': \"User's ID.\",\n", + "{'description': 'Update list of favorite pets',\n", + " 'properties': {'pets': {'description': 'List of favorite pets to set.',\n", + " 'items': {'type': 'string'},\n", + " 'title': 'Pets',\n", + " 'type': 'array'},\n", + " 'user_id': {'description': \"User's ID.\",\n", + " 'title': 'User Id',\n", " 'type': 'string'}},\n", - " 'required': ['pets', 'user_id']}" + " 'required': ['pets', 'user_id'],\n", + " 'title': 'UpdateFavoritePetsSchema',\n", + " 'type': 'object'}" ] }, - "execution_count": 22, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -508,23 +592,30 @@ }, { "cell_type": "code", - "execution_count": 23, - "metadata": {}, + "execution_count": 13, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:54.277497Z", + "iopub.status.busy": "2024-09-11T02:52:54.277400Z", + "iopub.status.idle": "2024-09-11T02:52:54.280323Z", + "shell.execute_reply": "2024-09-11T02:52:54.280072Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "{'title': 'update_favorite_pets',\n", - " 'description': 'Update list of favorite pets',\n", - " 'type': 'object',\n", - " 'properties': {'pets': {'title': 'Pets',\n", - " 'description': 'List of favorite pets to set.',\n", - " 'type': 'array',\n", - " 'items': {'type': 'string'}}},\n", - " 'required': ['pets']}" + "{'description': 'Update list of favorite pets',\n", + " 'properties': {'pets': {'description': 'List of favorite pets to set.',\n", + " 'items': {'type': 'string'},\n", + " 'title': 'Pets',\n", + " 'type': 'array'}},\n", + " 'required': ['pets'],\n", + " 'title': 'update_favorite_pets',\n", + " 'type': 'object'}" ] }, - "execution_count": 23, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -535,23 +626,30 @@ }, { "cell_type": "code", - "execution_count": 24, - "metadata": {}, + "execution_count": 14, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:54.281741Z", + "iopub.status.busy": "2024-09-11T02:52:54.281642Z", + "iopub.status.idle": "2024-09-11T02:52:54.288857Z", + "shell.execute_reply": "2024-09-11T02:52:54.288632Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "{'title': 'update_favorite_petsSchema',\n", - " 'description': 'Use the tool.\\n\\nAdd run_manager: Optional[CallbackManagerForToolRun] = None\\nto child implementations to enable tracing.',\n", - " 'type': 'object',\n", - " 'properties': {'pets': {'title': 'Pets',\n", - " 'type': 'array',\n", - " 'items': {'type': 'string'}},\n", + "{'description': 'Use the tool.\\n\\nAdd run_manager: Optional[CallbackManagerForToolRun] = None\\nto child implementations to enable tracing.',\n", + " 'properties': {'pets': {'items': {'type': 'string'},\n", + " 'title': 'Pets',\n", + " 'type': 'array'},\n", " 'user_id': {'title': 'User Id', 'type': 'string'}},\n", - " 'required': ['pets', 'user_id']}" + " 'required': ['pets', 'user_id'],\n", + " 'title': 'update_favorite_petsSchema',\n", + " 'type': 'object'}" ] }, - "execution_count": 24, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -570,22 +668,29 @@ }, { "cell_type": "code", - "execution_count": 26, - "metadata": {}, + "execution_count": 15, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T02:52:54.290237Z", + "iopub.status.busy": "2024-09-11T02:52:54.290145Z", + "iopub.status.idle": "2024-09-11T02:52:54.294273Z", + "shell.execute_reply": "2024-09-11T02:52:54.294053Z" + } + }, "outputs": [ { "data": { "text/plain": [ - "{'title': 'update_favorite_pets',\n", - " 'description': 'Update list of favorite pets',\n", - " 'type': 'object',\n", - " 'properties': {'pets': {'title': 'Pets',\n", - " 'type': 'array',\n", - " 'items': {'type': 'string'}}},\n", - " 'required': ['pets']}" + "{'description': 'Update list of favorite pets',\n", + " 'properties': {'pets': {'items': {'type': 'string'},\n", + " 'title': 'Pets',\n", + " 'type': 'array'}},\n", + " 'required': ['pets'],\n", + " 'title': 'update_favorite_pets',\n", + " 'type': 'object'}" ] }, - "execution_count": 26, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -597,7 +702,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -611,7 +716,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.5" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/docs/docs/how_to/tools_builtin.ipynb b/docs/docs/how_to/tools_builtin.ipynb index 03e596e4315..47fd4055275 100644 --- a/docs/docs/how_to/tools_builtin.ipynb +++ b/docs/docs/how_to/tools_builtin.ipynb @@ -46,19 +46,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "84f70856-b865-4658-9930-7577fb4712ce", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T03:01:11.847104Z", + "iopub.status.busy": "2024-09-11T03:01:11.846727Z", + "iopub.status.idle": "2024-09-11T03:01:13.200038Z", + "shell.execute_reply": "2024-09-11T03:01:13.199355Z" + } + }, "outputs": [], "source": [ - "!pip install -qU wikipedia" + "!pip install -qU langchain-community wikipedia" ] }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 2, "id": "b4eaed85-c5a6-4ba9-b401-40258b0131c2", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T03:01:13.203356Z", + "iopub.status.busy": "2024-09-11T03:01:13.202996Z", + "iopub.status.idle": "2024-09-11T03:01:14.740686Z", + "shell.execute_reply": "2024-09-11T03:01:14.739748Z" + } + }, "outputs": [ { "name": "stdout", @@ -89,18 +103,25 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 3, "id": "7f094f01-2e98-4947-acc4-0846963a96e0", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T03:01:14.745018Z", + "iopub.status.busy": "2024-09-11T03:01:14.744347Z", + "iopub.status.idle": "2024-09-11T03:01:14.752527Z", + "shell.execute_reply": "2024-09-11T03:01:14.752112Z" + } + }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Name: wiki-tool\n", - "Description: look up things in wikipedia\n", - "args schema: {'query': {'title': 'Query', 'description': 'query to look up in Wikipedia, should be 3 or less words', 'type': 'string'}}\n", - "returns directly?: True\n" + "Name: wikipedia\n", + "Description: A wrapper around Wikipedia. Useful for when you need to answer general questions about people, places, companies, facts, historical events, or other subjects. Input should be a search query.\n", + "args schema: {'query': {'description': 'query to look up on wikipedia', 'title': 'Query', 'type': 'string'}}\n", + "returns directly?: False\n" ] } ], @@ -124,9 +145,16 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 4, "id": "1365784c-e666-41c8-a1bb-e50f822b5936", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T03:01:14.755274Z", + "iopub.status.busy": "2024-09-11T03:01:14.755068Z", + "iopub.status.idle": "2024-09-11T03:01:15.375704Z", + "shell.execute_reply": "2024-09-11T03:01:15.374841Z" + } + }, "outputs": [ { "name": "stdout", @@ -164,9 +192,16 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 5, "id": "6e8850d6-6840-443e-a2be-adf64b30975c", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T03:01:15.378598Z", + "iopub.status.busy": "2024-09-11T03:01:15.378414Z", + "iopub.status.idle": "2024-09-11T03:01:15.382248Z", + "shell.execute_reply": "2024-09-11T03:01:15.381801Z" + } + }, "outputs": [ { "name": "stdout", @@ -174,7 +209,7 @@ "text": [ "Name: wiki-tool\n", "Description: look up things in wikipedia\n", - "args schema: {'query': {'title': 'Query', 'description': 'query to look up in Wikipedia, should be 3 or less words', 'type': 'string'}}\n", + "args schema: {'query': {'description': 'query to look up in Wikipedia, should be 3 or less words', 'title': 'Query', 'type': 'string'}}\n", "returns directly?: True\n" ] } @@ -212,9 +247,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "poetry-venv-311", "language": "python", - "name": "python3" + "name": "poetry-venv-311" }, "language_info": { "codemirror_mode": { diff --git a/docs/docs/how_to/tools_error.ipynb b/docs/docs/how_to/tools_error.ipynb index d1419c6b304..08e38e9c6f0 100644 --- a/docs/docs/how_to/tools_error.ipynb +++ b/docs/docs/how_to/tools_error.ipynb @@ -53,7 +53,14 @@ "cell_type": "code", "execution_count": 2, "id": "08785b6d-722d-4620-b6ec-36deb3842c69", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T03:10:25.005243Z", + "iopub.status.busy": "2024-09-11T03:10:25.005074Z", + "iopub.status.idle": "2024-09-11T03:10:25.007679Z", + "shell.execute_reply": "2024-09-11T03:10:25.007361Z" + } + }, "outputs": [], "source": [ "import getpass\n", @@ -81,9 +88,16 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "id": "86258950-5e61-4340-81b9-84a5d26e8773", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T03:10:25.009496Z", + "iopub.status.busy": "2024-09-11T03:10:25.009371Z", + "iopub.status.idle": "2024-09-11T03:10:25.552917Z", + "shell.execute_reply": "2024-09-11T03:10:25.552592Z" + } + }, "outputs": [], "source": [ "# | echo: false\n", @@ -91,16 +105,24 @@ "\n", "from langchain_openai import ChatOpenAI\n", "\n", - "os.environ[\"OPENAI_API_KEY\"] = getpass.getpass()\n", + "if \"OPENAI_API_KEY\" not in os.environ:\n", + " os.environ[\"OPENAI_API_KEY\"] = getpass.getpass()\n", "\n", "llm = ChatOpenAI(model=\"gpt-4o-mini\", temperature=0)" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "id": "1d20604e-c4d1-4d21-841b-23e4f61aec36", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T03:10:25.554543Z", + "iopub.status.busy": "2024-09-11T03:10:25.554439Z", + "iopub.status.idle": "2024-09-11T03:10:25.631610Z", + "shell.execute_reply": "2024-09-11T03:10:25.631346Z" + } + }, "outputs": [], "source": [ "# Define tool\n", @@ -131,26 +153,33 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "id": "d354664c-ac44-4967-a35f-8912b3ad9477", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T03:10:25.633050Z", + "iopub.status.busy": "2024-09-11T03:10:25.632978Z", + "iopub.status.idle": "2024-09-11T03:10:26.556508Z", + "shell.execute_reply": "2024-09-11T03:10:26.556233Z" + } + }, "outputs": [ { "ename": "ValidationError", - "evalue": "1 validation error for complex_toolSchema\ndict_arg\n field required (type=value_error.missing)", + "evalue": "1 validation error for complex_toolSchema\ndict_arg\n Field required [type=missing, input_value={'int_arg': 5, 'float_arg': 2.1}, input_type=dict]\n For further information visit https://errors.pydantic.dev/2.8/v/missing", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mValidationError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[6], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mchain\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 2\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43muse complex tool. the args are 5, 2.1, empty dictionary. don\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mt forget dict_arg\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\n\u001b[1;32m 3\u001b[0m \u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/.pyenv/versions/3.10.5/lib/python3.10/site-packages/langchain_core/runnables/base.py:2572\u001b[0m, in \u001b[0;36mRunnableSequence.invoke\u001b[0;34m(self, input, config, **kwargs)\u001b[0m\n\u001b[1;32m 2570\u001b[0m \u001b[38;5;28minput\u001b[39m \u001b[38;5;241m=\u001b[39m step\u001b[38;5;241m.\u001b[39minvoke(\u001b[38;5;28minput\u001b[39m, config, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 2571\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 2572\u001b[0m \u001b[38;5;28minput\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[43mstep\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2573\u001b[0m \u001b[38;5;66;03m# finish the root run\u001b[39;00m\n\u001b[1;32m 2574\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n", - "File \u001b[0;32m~/.pyenv/versions/3.10.5/lib/python3.10/site-packages/langchain_core/tools.py:380\u001b[0m, in \u001b[0;36mBaseTool.invoke\u001b[0;34m(self, input, config, **kwargs)\u001b[0m\n\u001b[1;32m 373\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21minvoke\u001b[39m(\n\u001b[1;32m 374\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 375\u001b[0m \u001b[38;5;28minput\u001b[39m: Union[\u001b[38;5;28mstr\u001b[39m, Dict],\n\u001b[1;32m 376\u001b[0m config: Optional[RunnableConfig] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m 377\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs: Any,\n\u001b[1;32m 378\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Any:\n\u001b[1;32m 379\u001b[0m config \u001b[38;5;241m=\u001b[39m ensure_config(config)\n\u001b[0;32m--> 380\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 381\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 382\u001b[0m \u001b[43m \u001b[49m\u001b[43mcallbacks\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcallbacks\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 383\u001b[0m \u001b[43m \u001b[49m\u001b[43mtags\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtags\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 384\u001b[0m \u001b[43m \u001b[49m\u001b[43mmetadata\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmetadata\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 385\u001b[0m \u001b[43m \u001b[49m\u001b[43mrun_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mrun_name\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 386\u001b[0m \u001b[43m \u001b[49m\u001b[43mrun_id\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpop\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mrun_id\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 387\u001b[0m \u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 388\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 389\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/.pyenv/versions/3.10.5/lib/python3.10/site-packages/langchain_core/tools.py:537\u001b[0m, in \u001b[0;36mBaseTool.run\u001b[0;34m(self, tool_input, verbose, start_color, color, callbacks, tags, metadata, run_name, run_id, config, **kwargs)\u001b[0m\n\u001b[1;32m 535\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m ValidationError \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 536\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhandle_validation_error:\n\u001b[0;32m--> 537\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m e\n\u001b[1;32m 538\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhandle_validation_error, \u001b[38;5;28mbool\u001b[39m):\n\u001b[1;32m 539\u001b[0m observation \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTool input validation error\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", - "File \u001b[0;32m~/.pyenv/versions/3.10.5/lib/python3.10/site-packages/langchain_core/tools.py:526\u001b[0m, in \u001b[0;36mBaseTool.run\u001b[0;34m(self, tool_input, verbose, start_color, color, callbacks, tags, metadata, run_name, run_id, config, **kwargs)\u001b[0m\n\u001b[1;32m 524\u001b[0m context \u001b[38;5;241m=\u001b[39m copy_context()\n\u001b[1;32m 525\u001b[0m context\u001b[38;5;241m.\u001b[39mrun(_set_config_context, child_config)\n\u001b[0;32m--> 526\u001b[0m parsed_input \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_parse_input\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtool_input\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 527\u001b[0m tool_args, tool_kwargs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_to_args_and_kwargs(parsed_input)\n\u001b[1;32m 528\u001b[0m observation \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 529\u001b[0m context\u001b[38;5;241m.\u001b[39mrun(\n\u001b[1;32m 530\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_run, \u001b[38;5;241m*\u001b[39mtool_args, run_manager\u001b[38;5;241m=\u001b[39mrun_manager, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mtool_kwargs\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 533\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m context\u001b[38;5;241m.\u001b[39mrun(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_run, \u001b[38;5;241m*\u001b[39mtool_args, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mtool_kwargs)\n\u001b[1;32m 534\u001b[0m )\n", - "File \u001b[0;32m~/.pyenv/versions/3.10.5/lib/python3.10/site-packages/langchain_core/tools.py:424\u001b[0m, in \u001b[0;36mBaseTool._parse_input\u001b[0;34m(self, tool_input)\u001b[0m\n\u001b[1;32m 422\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 423\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m input_args \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m--> 424\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43minput_args\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mparse_obj\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtool_input\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 425\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m {\n\u001b[1;32m 426\u001b[0m k: \u001b[38;5;28mgetattr\u001b[39m(result, k)\n\u001b[1;32m 427\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m k, v \u001b[38;5;129;01min\u001b[39;00m result\u001b[38;5;241m.\u001b[39mdict()\u001b[38;5;241m.\u001b[39mitems()\n\u001b[1;32m 428\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m k \u001b[38;5;129;01min\u001b[39;00m tool_input\n\u001b[1;32m 429\u001b[0m }\n\u001b[1;32m 430\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m tool_input\n", - "File \u001b[0;32m~/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pydantic/main.py:526\u001b[0m, in \u001b[0;36mpydantic.main.BaseModel.parse_obj\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32m~/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pydantic/main.py:341\u001b[0m, in \u001b[0;36mpydantic.main.BaseModel.__init__\u001b[0;34m()\u001b[0m\n", - "\u001b[0;31mValidationError\u001b[0m: 1 validation error for complex_toolSchema\ndict_arg\n field required (type=value_error.missing)" + "Cell \u001b[0;32mIn[5], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mchain\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 2\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43muse complex tool. the args are 5, 2.1, empty dictionary. don\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mt forget dict_arg\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\n\u001b[1;32m 3\u001b[0m \u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/langchain/.venv/lib/python3.11/site-packages/langchain_core/runnables/base.py:2998\u001b[0m, in \u001b[0;36mRunnableSequence.invoke\u001b[0;34m(self, input, config, **kwargs)\u001b[0m\n\u001b[1;32m 2996\u001b[0m \u001b[38;5;28minput\u001b[39m \u001b[38;5;241m=\u001b[39m context\u001b[38;5;241m.\u001b[39mrun(step\u001b[38;5;241m.\u001b[39minvoke, \u001b[38;5;28minput\u001b[39m, config, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 2997\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 2998\u001b[0m \u001b[38;5;28minput\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[43mcontext\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstep\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minvoke\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2999\u001b[0m \u001b[38;5;66;03m# finish the root run\u001b[39;00m\n\u001b[1;32m 3000\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n", + "File \u001b[0;32m~/langchain/.venv/lib/python3.11/site-packages/langchain_core/tools/base.py:456\u001b[0m, in \u001b[0;36mBaseTool.invoke\u001b[0;34m(self, input, config, **kwargs)\u001b[0m\n\u001b[1;32m 449\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21minvoke\u001b[39m(\n\u001b[1;32m 450\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 451\u001b[0m \u001b[38;5;28minput\u001b[39m: Union[\u001b[38;5;28mstr\u001b[39m, Dict, ToolCall],\n\u001b[1;32m 452\u001b[0m config: Optional[RunnableConfig] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m 453\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs: Any,\n\u001b[1;32m 454\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Any:\n\u001b[1;32m 455\u001b[0m tool_input, kwargs \u001b[38;5;241m=\u001b[39m _prep_run_args(\u001b[38;5;28minput\u001b[39m, config, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m--> 456\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtool_input\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/langchain/.venv/lib/python3.11/site-packages/langchain_core/tools/base.py:659\u001b[0m, in \u001b[0;36mBaseTool.run\u001b[0;34m(self, tool_input, verbose, start_color, color, callbacks, tags, metadata, run_name, run_id, config, tool_call_id, **kwargs)\u001b[0m\n\u001b[1;32m 657\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m error_to_raise:\n\u001b[1;32m 658\u001b[0m run_manager\u001b[38;5;241m.\u001b[39mon_tool_error(error_to_raise)\n\u001b[0;32m--> 659\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m error_to_raise\n\u001b[1;32m 660\u001b[0m output \u001b[38;5;241m=\u001b[39m _format_output(content, artifact, tool_call_id, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mname, status)\n\u001b[1;32m 661\u001b[0m run_manager\u001b[38;5;241m.\u001b[39mon_tool_end(output, color\u001b[38;5;241m=\u001b[39mcolor, name\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mname, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n", + "File \u001b[0;32m~/langchain/.venv/lib/python3.11/site-packages/langchain_core/tools/base.py:622\u001b[0m, in \u001b[0;36mBaseTool.run\u001b[0;34m(self, tool_input, verbose, start_color, color, callbacks, tags, metadata, run_name, run_id, config, tool_call_id, **kwargs)\u001b[0m\n\u001b[1;32m 620\u001b[0m context \u001b[38;5;241m=\u001b[39m copy_context()\n\u001b[1;32m 621\u001b[0m context\u001b[38;5;241m.\u001b[39mrun(_set_config_context, child_config)\n\u001b[0;32m--> 622\u001b[0m tool_args, tool_kwargs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_to_args_and_kwargs\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtool_input\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 623\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m signature(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_run)\u001b[38;5;241m.\u001b[39mparameters\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mrun_manager\u001b[39m\u001b[38;5;124m\"\u001b[39m):\n\u001b[1;32m 624\u001b[0m tool_kwargs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mrun_manager\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m run_manager\n", + "File \u001b[0;32m~/langchain/.venv/lib/python3.11/site-packages/langchain_core/tools/base.py:545\u001b[0m, in \u001b[0;36mBaseTool._to_args_and_kwargs\u001b[0;34m(self, tool_input)\u001b[0m\n\u001b[1;32m 544\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_to_args_and_kwargs\u001b[39m(\u001b[38;5;28mself\u001b[39m, tool_input: Union[\u001b[38;5;28mstr\u001b[39m, Dict]) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Tuple[Tuple, Dict]:\n\u001b[0;32m--> 545\u001b[0m tool_input \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_parse_input\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtool_input\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 546\u001b[0m \u001b[38;5;66;03m# For backwards compatibility, if run_input is a string,\u001b[39;00m\n\u001b[1;32m 547\u001b[0m \u001b[38;5;66;03m# pass as a positional argument.\u001b[39;00m\n\u001b[1;32m 548\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(tool_input, \u001b[38;5;28mstr\u001b[39m):\n", + "File \u001b[0;32m~/langchain/.venv/lib/python3.11/site-packages/langchain_core/tools/base.py:487\u001b[0m, in \u001b[0;36mBaseTool._parse_input\u001b[0;34m(self, tool_input)\u001b[0m\n\u001b[1;32m 485\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m input_args \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 486\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28missubclass\u001b[39m(input_args, BaseModel):\n\u001b[0;32m--> 487\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43minput_args\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmodel_validate\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtool_input\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 488\u001b[0m result_dict \u001b[38;5;241m=\u001b[39m result\u001b[38;5;241m.\u001b[39mmodel_dump()\n\u001b[1;32m 489\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28missubclass\u001b[39m(input_args, BaseModelV1):\n", + "File \u001b[0;32m~/langchain/.venv/lib/python3.11/site-packages/pydantic/main.py:568\u001b[0m, in \u001b[0;36mBaseModel.model_validate\u001b[0;34m(cls, obj, strict, from_attributes, context)\u001b[0m\n\u001b[1;32m 566\u001b[0m \u001b[38;5;66;03m# `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks\u001b[39;00m\n\u001b[1;32m 567\u001b[0m __tracebackhide__ \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[0;32m--> 568\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mcls\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m__pydantic_validator__\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mvalidate_python\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 569\u001b[0m \u001b[43m \u001b[49m\u001b[43mobj\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstrict\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstrict\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfrom_attributes\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfrom_attributes\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcontext\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcontext\u001b[49m\n\u001b[1;32m 570\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[0;31mValidationError\u001b[0m: 1 validation error for complex_toolSchema\ndict_arg\n Field required [type=missing, input_value={'int_arg': 5, 'float_arg': 2.1}, input_type=dict]\n For further information visit https://errors.pydantic.dev/2.8/v/missing" ] } ], @@ -172,9 +201,16 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 6, "id": "8fedb550-683d-45ae-8876-ae7acb332019", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T03:10:26.558131Z", + "iopub.status.busy": "2024-09-11T03:10:26.558031Z", + "iopub.status.idle": "2024-09-11T03:10:27.399844Z", + "shell.execute_reply": "2024-09-11T03:10:27.399201Z" + } + }, "outputs": [ { "name": "stdout", @@ -186,9 +222,10 @@ "\n", "raised the following error:\n", "\n", - ": 1 validation error for complex_toolSchema\n", + ": 1 validation error for complex_toolSchema\n", "dict_arg\n", - " field required (type=value_error.missing)\n" + " Field required [type=missing, input_value={'int_arg': 5, 'float_arg': 2.1}, input_type=dict]\n", + " For further information visit https://errors.pydantic.dev/2.8/v/missing\n" ] } ], @@ -226,9 +263,16 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 7, "id": "02cc4223-35fa-4240-976a-012299ca703c", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T03:10:27.404122Z", + "iopub.status.busy": "2024-09-11T03:10:27.403539Z", + "iopub.status.idle": "2024-09-11T03:10:38.080547Z", + "shell.execute_reply": "2024-09-11T03:10:38.079955Z" + } + }, "outputs": [ { "data": { @@ -236,7 +280,7 @@ "10.5" ] }, - "execution_count": 10, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -277,9 +321,16 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 8, "id": "b5659956-9454-468a-9753-a3ff9052b8f5", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T03:10:38.083810Z", + "iopub.status.busy": "2024-09-11T03:10:38.083623Z", + "iopub.status.idle": "2024-09-11T03:10:38.090089Z", + "shell.execute_reply": "2024-09-11T03:10:38.089682Z" + } + }, "outputs": [], "source": [ "from langchain_core.messages import AIMessage, HumanMessage, ToolCall, ToolMessage\n", @@ -335,9 +386,16 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 9, "id": "4c45f5bd-cbb4-47d5-b4b6-aec50673c750", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-09-11T03:10:38.092152Z", + "iopub.status.busy": "2024-09-11T03:10:38.092021Z", + "iopub.status.idle": "2024-09-11T03:10:39.592443Z", + "shell.execute_reply": "2024-09-11T03:10:39.591990Z" + } + }, "outputs": [ { "data": { @@ -345,7 +403,7 @@ "10.5" ] }, - "execution_count": 12, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -401,7 +459,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.5" + "version": "3.11.9" } }, "nbformat": 4,