mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-17 21:25:46 +02:00
doc updates (#1639)
--------- Co-authored-by: vbarda <vadym@langchain.dev>
This commit is contained in:
co-authored by
vbarda
parent
38a644cf79
commit
db306cd01b
@@ -37,7 +37,9 @@
|
||||
"id": "a85501ca-eb89-4795-aeab-cdab050ead6b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Environment "
|
||||
"## Setup\n",
|
||||
"\n",
|
||||
"First, let's install our required packages and set our API keys"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -58,35 +60,31 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"### LLMs\n",
|
||||
"import getpass\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = \"<your-api-key>\"\n",
|
||||
"os.environ[\"COHERE_API_KEY\"] = \"<your-api-key>\"\n",
|
||||
"os.environ[\"TAVILY_API_KEY\"] = \"<your-api-key>\""
|
||||
"\n",
|
||||
"def _set_env(var: str):\n",
|
||||
" if not os.environ.get(var):\n",
|
||||
" os.environ[var] = getpass.getpass(f\"{var}: \")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"_set_env(\"OPENAI_API_KEY\")\n",
|
||||
"_set_env(\"COHERE_API_KEY\")\n",
|
||||
"_set_env(\"TAVILY_API_KEY\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "018c9e9f-8199-4f33-b5b4-7adfb66d6219",
|
||||
"id": "47e04b18",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Tracing\n",
|
||||
"\n",
|
||||
"* Optionally, use [LangSmith](https://docs.smith.langchain.com/) for tracing (shown at bottom) by setting: "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "08edba00-988a-478b-96fc-ae0199cbef49",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"### Tracing (optional)\n",
|
||||
"os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
|
||||
"os.environ[\"LANGCHAIN_ENDPOINT\"] = \"https://api.smith.langchain.com\"\n",
|
||||
"os.environ[\"LANGCHAIN_API_KEY\"] = \"<your-api-key>\""
|
||||
"<div class=\"admonition tip\">\n",
|
||||
" <p class=\"admonition-title\">Set up <a href=\"https://smith.langchain.com\">LangSmith</a> for LangGraph development</p>\n",
|
||||
" <p style=\"padding-top: 5px;\">\n",
|
||||
" Sign up for LangSmith to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph — read more about how to get started <a href=\"https://docs.smith.langchain.com\">here</a>. \n",
|
||||
" </p>\n",
|
||||
"</div> "
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -94,7 +92,7 @@
|
||||
"id": "9ac1c2cd-81fb-40eb-8ba1-e9197800cba6",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Index"
|
||||
"## Create Index"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -462,11 +460,11 @@
|
||||
"id": "efbbff0e-8843-45bb-b2ff-137bef707ef4",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Graph \n",
|
||||
"## Construct the Graph \n",
|
||||
"\n",
|
||||
"Capture the flow in as a graph.\n",
|
||||
"\n",
|
||||
"## Graph state"
|
||||
"### Define Graph State"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -501,7 +499,7 @@
|
||||
"id": "7e2d6c0d-42e8-4399-9751-e315be16607a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Graph Flow "
|
||||
"### Define Graph Flow "
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -721,7 +719,7 @@
|
||||
"id": "3ab01f36-5628-49ab-bfd3-84bb6f1a1b0f",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Build Graph"
|
||||
"### Compile Graph"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -776,6 +774,14 @@
|
||||
"app = workflow.compile()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "85bce541",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Use Graph"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
|
||||
@@ -35,7 +35,9 @@
|
||||
"id": "8cece98f-a3ed-417e-8b6a-1754e8f9c42a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Environment "
|
||||
"## Setup\n",
|
||||
"\n",
|
||||
"First, let's install our required packages and set our API keys"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -49,6 +51,39 @@
|
||||
"%pip install -U langchain-nomic langchain_community tiktoken langchainhub chromadb langchain langgraph tavily-python nomic[local]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "2369652a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import getpass\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def _set_env(var: str):\n",
|
||||
" if not os.environ.get(var):\n",
|
||||
" os.environ[var] = getpass.getpass(f\"{var}: \")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"_set_env(\"TAVILY_API_KEY\")\n",
|
||||
"_set_env(\"NOMIC_API_KEY\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "aea269f6",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<div class=\"admonition tip\">\n",
|
||||
" <p class=\"admonition-title\">Set up <a href=\"https://smith.langchain.com\">LangSmith</a> for LangGraph development</p>\n",
|
||||
" <p style=\"padding-top: 5px;\">\n",
|
||||
" Sign up for LangSmith to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph — read more about how to get started <a href=\"https://docs.smith.langchain.com\">here</a>. \n",
|
||||
" </p>\n",
|
||||
"</div> "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6a5d4a26-249b-4551-aa13-6c373429618e",
|
||||
@@ -84,36 +119,12 @@
|
||||
"local_llm = \"mistral\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "5c104495-a8a4-4517-b6a6-9a2cbe1e82f2",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Tracing\n",
|
||||
"\n",
|
||||
"Optionally, use [LangSmith](https://docs.smith.langchain.com/) for tracing (shown at bottom)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "f6cb8dce-f580-421d-a05f-9fc71de2b023",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
|
||||
"os.environ[\"LANGCHAIN_ENDPOINT\"] = \"https://api.smith.langchain.com\"\n",
|
||||
"os.environ[\"LANGCHAIN_API_KEY\"] = \"<your-api-key>\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "04718a0c-7a48-4243-97a2-940a0239cc12",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Index"
|
||||
"## Create Index"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -11,7 +11,11 @@
|
||||
"\n",
|
||||
"To implement a retrieval agent, we simple need to give an LLM access to a retriever tool.\n",
|
||||
"\n",
|
||||
"We can incorporate this into [LangGraph](https://langchain-ai.github.io/langgraph/)."
|
||||
"We can incorporate this into [LangGraph](https://langchain-ai.github.io/langgraph/).\n",
|
||||
"\n",
|
||||
"## Setup\n",
|
||||
"\n",
|
||||
"First, let's download the required packages and set our API keys:"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -41,11 +45,20 @@
|
||||
" os.environ[key] = getpass.getpass(f\"{key}:\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"_set_env(\"OPENAI_API_KEY\")\n",
|
||||
"\n",
|
||||
"# (Optional) For tracing\n",
|
||||
"os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
|
||||
"_set_env(\"LANGCHAIN_API_KEY\")"
|
||||
"_set_env(\"OPENAI_API_KEY\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3d07e8d4",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<div class=\"admonition tip\">\n",
|
||||
" <p class=\"admonition-title\">Set up <a href=\"https://smith.langchain.com\">LangSmith</a> for LangGraph development</p>\n",
|
||||
" <p style=\"padding-top: 5px;\">\n",
|
||||
" Sign up for LangSmith to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph — read more about how to get started <a href=\"https://docs.smith.langchain.com\">here</a>. \n",
|
||||
" </p>\n",
|
||||
"</div> "
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -124,7 +137,7 @@
|
||||
"id": "fe6e8f78-1ef7-42ad-b2bf-835ed5850553",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Agent state\n",
|
||||
"## Agent State\n",
|
||||
" \n",
|
||||
"We will define a graph.\n",
|
||||
"\n",
|
||||
|
||||
@@ -38,7 +38,9 @@
|
||||
"id": "4931ac25-99f9-4f04-b3d1-4683f7853667",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Environment "
|
||||
"## Setup\n",
|
||||
"\n",
|
||||
"First, let's download our required packages and set our API keys"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -51,14 +53,6 @@
|
||||
"! pip install langchain_community tiktoken langchain-openai langchainhub chromadb langchain langgraph tavily-python"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "c9ca92ae-c84f-423e-bab5-2a8bd06bd4cf",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### LLMs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
@@ -66,51 +60,30 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import getpass\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = \"<your-api-key>\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "db34bf9b-fa1e-45d3-a83e-4f5eaf897bad",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Search\n",
|
||||
" \n",
|
||||
"We'll use [Tavily Search](https://python.langchain.com/docs/integrations/tools/tavily_search) for web search."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "c3ac6e65-2d4e-48dd-9fff-40047373332d",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"os.environ[\"TAVILY_API_KEY\"] = \"<your-api-key>\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "20d2644a-043e-419c-9ff8-45118b8e9f17",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Tracing\n",
|
||||
"\n",
|
||||
"Optionally, use [LangSmith](https://docs.smith.langchain.com/) for tracing (shown at bottom) by setting"
|
||||
"def _set_env(key: str):\n",
|
||||
" if key not in os.environ:\n",
|
||||
" os.environ[key] = getpass.getpass(f\"{key}:\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"_set_env(\"OPENAI_API_KEY\")\n",
|
||||
"_set_env(\"TAVILY_API_KEY\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "e205f57e-5218-478b-ad8e-1723bdb0d45e",
|
||||
"cell_type": "markdown",
|
||||
"id": "3adde047",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
|
||||
"os.environ[\"LANGCHAIN_ENDPOINT\"] = \"https://api.smith.langchain.com\"\n",
|
||||
"os.environ[\"LANGCHAIN_API_KEY\"] = \"<your-api-key>\""
|
||||
"<div class=\"admonition tip\">\n",
|
||||
" <p class=\"admonition-title\">Set up <a href=\"https://smith.langchain.com\">LangSmith</a> for LangGraph development</p>\n",
|
||||
" <p style=\"padding-top: 5px;\">\n",
|
||||
" Sign up for LangSmith to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph — read more about how to get started <a href=\"https://docs.smith.langchain.com\">here</a>. \n",
|
||||
" </p>\n",
|
||||
"</div> "
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -118,7 +91,7 @@
|
||||
"id": "a21f32d2-92ce-4995-b309-99347bafe3be",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Index\n",
|
||||
"## Create Index\n",
|
||||
" \n",
|
||||
"Let's index 3 blog posts."
|
||||
]
|
||||
@@ -326,11 +299,11 @@
|
||||
"id": "87194a1b-535a-4593-ab95-5736fae176d1",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Graph \n",
|
||||
"## Create Graph \n",
|
||||
"\n",
|
||||
"Capture the flow in as a graph.\n",
|
||||
"Now let's create our graph that will use CRAG\n",
|
||||
"\n",
|
||||
"## Graph state"
|
||||
"### Define Graph State"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -523,7 +496,7 @@
|
||||
"id": "fa076e90-7132-4fcf-8507-db5990314c4f",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Build Graph\n",
|
||||
"### Compile Graph\n",
|
||||
"\n",
|
||||
"The just follows the flow we outlined in the figure above."
|
||||
]
|
||||
@@ -565,6 +538,14 @@
|
||||
"app = workflow.compile()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "27ba16a8",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Use the graph"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 42,
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"id": "6ba4302f-09d9-4d2a-a18d-a6fd23704850",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Environment\n",
|
||||
"## Setup\n",
|
||||
"\n",
|
||||
"We'll use [Ollama](https://ollama.ai/) to access a local LLM:\n",
|
||||
"\n",
|
||||
@@ -47,7 +47,8 @@
|
||||
"\n",
|
||||
"We'll use a vectorstore with [Nomic local embeddings](https://blog.nomic.ai/posts/nomic-embed-text-v1) or, optionally, OpenAI embeddings.\n",
|
||||
"\n",
|
||||
"We'll use [LangSmith](https://docs.smith.langchain.com/) for tracing and evaluation."
|
||||
"\n",
|
||||
"Let's install our required packages and set our API keys:"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -68,35 +69,30 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Search\n",
|
||||
"import getpass\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"os.environ[\"TAVILY_API_KEY\"] = \"xxx\""
|
||||
"\n",
|
||||
"def _set_env(key: str):\n",
|
||||
" if key not in os.environ:\n",
|
||||
" os.environ[key] = getpass.getpass(f\"{key}:\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"_set_env(\"OPENAI_API_KEY\")\n",
|
||||
"_set_env(\"TAVILY_API_KEY\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0be68860-dded-481e-9fc7-a5042bf92c04",
|
||||
"cell_type": "markdown",
|
||||
"id": "98f863ea",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Embedding (optional)\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = \"xxx\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "7248ab88-2b97-41eb-8dbb-4ea65525ed9a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Tracing and testing (optional)\n",
|
||||
"os.environ[\"LANGCHAIN_API_KEY\"] = \"xxx\"\n",
|
||||
"os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
|
||||
"os.environ[\"LANGCHAIN_ENDPOINT\"] = \"https://api.smith.langchain.com\"\n",
|
||||
"os.environ[\"LANGCHAIN_PROJECT\"] = \"corrective-rag-agent-testing\""
|
||||
"<div class=\"admonition tip\">\n",
|
||||
" <p class=\"admonition-title\">Set up <a href=\"https://smith.langchain.com\">LangSmith</a> for LangGraph development</p>\n",
|
||||
" <p style=\"padding-top: 5px;\">\n",
|
||||
" Sign up for LangSmith to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph — read more about how to get started <a href=\"https://docs.smith.langchain.com\">here</a>. \n",
|
||||
" </p>\n",
|
||||
"</div> "
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -126,7 +122,7 @@
|
||||
"id": "6e2b6eed-3b3f-44b5-a34a-4ade1e94caf0",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Index\n",
|
||||
"## Create Index\n",
|
||||
"\n",
|
||||
"Let's index 3 blog posts."
|
||||
]
|
||||
@@ -194,7 +190,7 @@
|
||||
"id": "fe7fd10a-f64a-48de-a116-6d5890def1af",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Tools"
|
||||
"## Define Tools"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -318,7 +314,7 @@
|
||||
"id": "a3421cf0-9067-43fe-8681-0d3189d15dd3",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Graph \n",
|
||||
"## Create the Graph \n",
|
||||
"\n",
|
||||
"Here we'll explicitly define the majority of the control flow, only using an LLM to define a single branch point following grading."
|
||||
]
|
||||
|
||||
@@ -50,7 +50,9 @@
|
||||
"id": "72f3ee57-68ab-4040-bd36-4014e2a23d96",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Environment "
|
||||
"## Setup\n",
|
||||
"\n",
|
||||
"First let's install our required packages and set our API keys"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -63,46 +65,36 @@
|
||||
"! pip install -U langchain_community tiktoken langchain-openai langchainhub chromadb langchain langgraph"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "15569b93-3c68-4aac-838c-37112d33987a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### LLMs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "f18b63c7-d0d3-41c1-ae6b-5a0f1b8ccf0f",
|
||||
"id": "de4ee2a5",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import getpass\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"os.environ[\"OPENAI_API_KEY\"] = \"<your-api-key>\""
|
||||
"\n",
|
||||
"def _set_env(key: str):\n",
|
||||
" if key not in os.environ:\n",
|
||||
" os.environ[key] = getpass.getpass(f\"{key}:\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"_set_env(\"OPENAI_API_KEY\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "532d91fb-381e-4e11-b3b1-254321351773",
|
||||
"id": "25d16369",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Tracing\n",
|
||||
"\n",
|
||||
"Optionally, use [LangSmith](https://docs.smith.langchain.com/) for tracing (shown at bottom)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "ccc3dae5-1df6-48ca-af8a-50f0e6128876",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
|
||||
"os.environ[\"LANGCHAIN_ENDPOINT\"] = \"https://api.smith.langchain.com\"\n",
|
||||
"os.environ[\"LANGCHAIN_API_KEY\"] = \"<your-api-key>\""
|
||||
"<div class=\"admonition tip\">\n",
|
||||
" <p class=\"admonition-title\">Set up <a href=\"https://smith.langchain.com\">LangSmith</a> for LangGraph development</p>\n",
|
||||
" <p style=\"padding-top: 5px;\">\n",
|
||||
" Sign up for LangSmith to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph — read more about how to get started <a href=\"https://docs.smith.langchain.com\">here</a>. \n",
|
||||
" </p>\n",
|
||||
"</div> "
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"id": "848ba742-7443-4123-8115-061da9823309",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Self RAG using local LLMs\n",
|
||||
"# Self-RAG using local LLMs\n",
|
||||
"\n",
|
||||
"Self-RAG is a strategy for RAG that incorporates self-reflection / self-grading on retrieved documents and generations. \n",
|
||||
"\n",
|
||||
@@ -50,7 +50,9 @@
|
||||
"id": "9ed0a85a-a33b-40a6-99fa-2444bf57a6cc",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Environment "
|
||||
"## Setup\n",
|
||||
"\n",
|
||||
"First let's install our required packages and set our API keys"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -64,6 +66,38 @@
|
||||
"%pip install -U langchain-nomic langchain_community tiktoken langchainhub chromadb langchain langgraph nomic[local]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "71c540ca",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import getpass\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def _set_env(key: str):\n",
|
||||
" if key not in os.environ:\n",
|
||||
" os.environ[key] = getpass.getpass(f\"{key}:\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"_set_env(\"NOMIC_API_KEY\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "05e8cf60",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<div class=\"admonition tip\">\n",
|
||||
" <p class=\"admonition-title\">Set up <a href=\"https://smith.langchain.com\">LangSmith</a> for LangGraph development</p>\n",
|
||||
" <p style=\"padding-top: 5px;\">\n",
|
||||
" Sign up for LangSmith to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph — read more about how to get started <a href=\"https://docs.smith.langchain.com\">here</a>. \n",
|
||||
" </p>\n",
|
||||
"</div> "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ccc6b6bd-a2fa-4a43-83b7-704b8b6fb855",
|
||||
@@ -99,36 +133,12 @@
|
||||
"local_llm = \"mistral\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6306aa61-2e6a-47b6-b306-4987d0636f97",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Tracing\n",
|
||||
"\n",
|
||||
"Optionally, use [LangSmith](https://docs.smith.langchain.com/) for tracing (shown at bottom)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "2208f342-8163-4af3-8dc0-aa70f5e06143",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
|
||||
"os.environ[\"LANGCHAIN_ENDPOINT\"] = \"https://api.smith.langchain.com\"\n",
|
||||
"os.environ[\"LANGCHAIN_API_KEY\"] = \"<your-api-key>\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ba68a46d-b617-4fdc-9113-fabdcf736feb",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Index\n",
|
||||
"## Create Index\n",
|
||||
"\n",
|
||||
"Let's index 3 blog posts."
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user