From 2dfe20d9c6589e8897ce1da2e78986f922c95cb4 Mon Sep 17 00:00:00 2001 From: Harrison Chase Date: Mon, 15 Jan 2024 16:35:46 -0800 Subject: [PATCH] cr --- examples/agent_executor/base.ipynb | 60 ++++++++++++++++++ .../force-calling-a-tool-first.ipynb | 61 +++++++++++++++++++ examples/agent_executor/high-level.ipynb | 61 +++++++++++++++++++ .../agent_executor/human-in-the-loop.ipynb | 61 +++++++++++++++++++ .../agent_executor/managing-agent-steps.ipynb | 61 +++++++++++++++++++ 5 files changed, 304 insertions(+) diff --git a/examples/agent_executor/base.ipynb b/examples/agent_executor/base.ipynb index 83b17b20e..2e4ba7a83 100644 --- a/examples/agent_executor/base.ipynb +++ b/examples/agent_executor/base.ipynb @@ -10,6 +10,66 @@ "In this notebook we will go over how to build a basic agent executor from scratch." ] }, + { + "cell_type": "markdown", + "id": "c0860511-03c2-49bb-937b-035f84142b7e", + "metadata": {}, + "source": [ + "## Setup¶\n", + "First we need to install the packages required" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fdd4ce41-4152-423b-b3f7-be3b4d568cf4", + "metadata": {}, + "outputs": [], + "source": [ + "!pip install --quiet -U langchain langchain_openai tavily-python" + ] + }, + { + "cell_type": "markdown", + "id": "5f4179ce-48fa-4aaf-a5a1-027b5229be1a", + "metadata": {}, + "source": [ + "Next, we need to set API keys for OpenAI (the LLM we will use) and Tavily (the search tool we will use)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6398c4c1-da78-4595-8a5a-051ed2d1de72", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import getpass\n", + "\n", + "os.environ[\"OPENAI_API_KEY\"] = getpass.getpass(\"OpenAI API Key:\")\n", + "os.environ[\"TAVILY_API_KEY\"] = getpass.getpass(\"Tavily API Key:\")" + ] + }, + { + "cell_type": "markdown", + "id": "37943b1c-2b0a-4c09-bfbd-5dc24b839e3c", + "metadata": {}, + "source": [ + "Optionally, we can set API key for [LangSmith tracing](https://smith.langchain.com/), which will give us best-in-class observability." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "dcbf79ad-4de5-43b0-a3a1-25b33711e46c", + "metadata": {}, + "outputs": [], + "source": [ + "os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n", + "os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass(\"LangSmith API Key:\")" + ] + }, { "cell_type": "markdown", "id": "5dace4a9-7c9e-4da2-bf7b-e58d0d05581e", diff --git a/examples/agent_executor/force-calling-a-tool-first.ipynb b/examples/agent_executor/force-calling-a-tool-first.ipynb index b36121bb5..49dccc319 100644 --- a/examples/agent_executor/force-calling-a-tool-first.ipynb +++ b/examples/agent_executor/force-calling-a-tool-first.ipynb @@ -14,6 +14,67 @@ "Any modifications of that example are called below with **MODIFICATION**, so if you are looking for the differences you can just search for that." ] }, + { + "cell_type": "markdown", + "id": "6821de30-6eeb-4f70-b0a7-e05d3187b14b", + "metadata": {}, + "source": [ + "## Setup\n", + "\n", + "First we need to install the packages required" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "694cfc4c-22a7-495d-930d-56b21d850ff9", + "metadata": {}, + "outputs": [], + "source": [ + "!pip install --quiet -U langchain langchain_openai tavily-python" + ] + }, + { + "cell_type": "markdown", + "id": "dc039752-6d34-4ad4-aa31-9a10f4d4d597", + "metadata": {}, + "source": [ + "Next, we need to set API keys for OpenAI (the LLM we will use) and Tavily (the search tool we will use)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "30c06a84-291a-4f58-9d31-53d3b56a3def", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import getpass\n", + "\n", + "os.environ[\"OPENAI_API_KEY\"] = getpass.getpass(\"OpenAI API Key:\")\n", + "os.environ[\"TAVILY_API_KEY\"] = getpass.getpass(\"Tavily API Key:\")" + ] + }, + { + "cell_type": "markdown", + "id": "5e7f4767-54fb-4b6e-bd9a-3d433df924fb", + "metadata": {}, + "source": [ + "Optionally, we can set API key for [LangSmith tracing](https://smith.langchain.com/), which will give us best-in-class observability." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a8fb285a-7e6e-46fc-a273-43ab1a676189", + "metadata": {}, + "outputs": [], + "source": [ + "os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n", + "os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass(\"LangSmith API Key:\")" + ] + }, { "cell_type": "markdown", "id": "5dace4a9-7c9e-4da2-bf7b-e58d0d05581e", diff --git a/examples/agent_executor/high-level.ipynb b/examples/agent_executor/high-level.ipynb index f2d853d5a..1922e5ab7 100644 --- a/examples/agent_executor/high-level.ipynb +++ b/examples/agent_executor/high-level.ipynb @@ -12,6 +12,67 @@ "However, it is highly likely you will want to customize the logic - for information on that, check out the other examples in this folder." ] }, + { + "cell_type": "markdown", + "id": "e6dd032b-bfe9-458c-a8ef-a14c78e0ad3f", + "metadata": {}, + "source": [ + "## Setup\n", + "\n", + "First we need to install the packages required" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1759bc06-8af3-4b73-abbf-0be3fa4c31fb", + "metadata": {}, + "outputs": [], + "source": [ + "!pip install --quiet -U langchain langchain_openai tavily-python" + ] + }, + { + "cell_type": "markdown", + "id": "fa08bd1a-efaa-46f5-adf8-47a84f738381", + "metadata": {}, + "source": [ + "Next, we need to set API keys for OpenAI (the LLM we will use) and Tavily (the search tool we will use)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "eb8e51dc-028b-4ea5-9847-f22fcbed6dac", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import getpass\n", + "\n", + "os.environ[\"OPENAI_API_KEY\"] = getpass.getpass(\"OpenAI API Key:\")\n", + "os.environ[\"TAVILY_API_KEY\"] = getpass.getpass(\"Tavily API Key:\")" + ] + }, + { + "cell_type": "markdown", + "id": "9242c0d7-b1da-41a0-9a3e-ed3afab3528e", + "metadata": {}, + "source": [ + "Optionally, we can set API key for [LangSmith tracing](https://smith.langchain.com/), which will give us best-in-class observability." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5db4438c-7802-4050-9dd9-14a6cac21a91", + "metadata": {}, + "outputs": [], + "source": [ + "os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n", + "os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass(\"LangSmith API Key:\")" + ] + }, { "cell_type": "markdown", "id": "6ae180d9-abd3-4a44-8fb1-a2c89434fbeb", diff --git a/examples/agent_executor/human-in-the-loop.ipynb b/examples/agent_executor/human-in-the-loop.ipynb index c127aee6a..d52ad06e2 100644 --- a/examples/agent_executor/human-in-the-loop.ipynb +++ b/examples/agent_executor/human-in-the-loop.ipynb @@ -14,6 +14,67 @@ "Any modifications of that example are called below with **MODIFICATION**, so if you are looking for the differences you can just search for that." ] }, + { + "cell_type": "markdown", + "id": "f7714f98-eb0e-43dd-8ae7-4a32ef2e72de", + "metadata": {}, + "source": [ + "## Setup\n", + "\n", + "First we need to install the packages required" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3fa9e224-2f00-49e2-bca3-e9cb8d9f3d41", + "metadata": {}, + "outputs": [], + "source": [ + "!pip install --quiet -U langchain langchain_openai tavily-python" + ] + }, + { + "cell_type": "markdown", + "id": "2dd8be50-2f92-478b-a918-6d9e4ad66dd6", + "metadata": {}, + "source": [ + "Next, we need to set API keys for OpenAI (the LLM we will use) and Tavily (the search tool we will use)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d180f0d0-385f-4ce3-994c-11e1d64595b5", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import getpass\n", + "\n", + "os.environ[\"OPENAI_API_KEY\"] = getpass.getpass(\"OpenAI API Key:\")\n", + "os.environ[\"TAVILY_API_KEY\"] = getpass.getpass(\"Tavily API Key:\")" + ] + }, + { + "cell_type": "markdown", + "id": "31d59506-f33f-42ad-b072-9a344c4af2e6", + "metadata": {}, + "source": [ + "Optionally, we can set API key for [LangSmith tracing](https://smith.langchain.com/), which will give us best-in-class observability." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "72ad0539-ecd8-4eb1-b2c1-2242e5fc556f", + "metadata": {}, + "outputs": [], + "source": [ + "os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n", + "os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass(\"LangSmith API Key:\")" + ] + }, { "cell_type": "markdown", "id": "5dace4a9-7c9e-4da2-bf7b-e58d0d05581e", diff --git a/examples/agent_executor/managing-agent-steps.ipynb b/examples/agent_executor/managing-agent-steps.ipynb index b53b7e91a..d509d8f8d 100644 --- a/examples/agent_executor/managing-agent-steps.ipynb +++ b/examples/agent_executor/managing-agent-steps.ipynb @@ -14,6 +14,67 @@ "Any modifications of that example are called below with **MODIFICATION**, so if you are looking for the differences you can just search for that." ] }, + { + "cell_type": "markdown", + "id": "bd763d4e-fd5e-4ce4-aa3a-54ab895d10a6", + "metadata": {}, + "source": [ + "## Setup\n", + "\n", + "First we need to install the packages required" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "aa752131-27e3-4bd8-9f21-d6749a7e74f4", + "metadata": {}, + "outputs": [], + "source": [ + "!pip install --quiet -U langchain langchain_openai tavily-python" + ] + }, + { + "cell_type": "markdown", + "id": "dbbfe916-5c23-4bf4-a5fa-5048e676dae3", + "metadata": {}, + "source": [ + "Next, we need to set API keys for OpenAI (the LLM we will use) and Tavily (the search tool we will use)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5732e68f-4ae2-4db9-bf9c-454b4cc9ec01", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import getpass\n", + "\n", + "os.environ[\"OPENAI_API_KEY\"] = getpass.getpass(\"OpenAI API Key:\")\n", + "os.environ[\"TAVILY_API_KEY\"] = getpass.getpass(\"Tavily API Key:\")" + ] + }, + { + "cell_type": "markdown", + "id": "4141f30e-4e5a-4b98-9fd8-b95e859d203a", + "metadata": {}, + "source": [ + "Optionally, we can set API key for [LangSmith tracing](https://smith.langchain.com/), which will give us best-in-class observability." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "652d4600-8f95-493f-b9b9-d4095aed9218", + "metadata": {}, + "outputs": [], + "source": [ + "os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n", + "os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass(\"LangSmith API Key:\")" + ] + }, { "cell_type": "markdown", "id": "5dace4a9-7c9e-4da2-bf7b-e58d0d05581e",