mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-23 18:15:08 +02:00
docs: Tutorials up to date (#1734)
* edits * add js code to web voyager
This commit is contained in:
@@ -110,7 +110,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 1,
|
||||
"id": "af8379bd-7eae-4ba6-b632-12e89eab9920",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -132,7 +132,16 @@
|
||||
"execution_count": 3,
|
||||
"id": "f9ff6b99-080d-4827-b2cb-f775543d76f5",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Downloading: 100%|██████████| 274M/274M [00:43<00:00, 6.38MiB/s] \n",
|
||||
"Verifying: 100%|██████████| 274M/274M [00:00<00:00, 618MiB/s] \n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
|
||||
"from langchain_community.document_loaders import WebBaseLoader\n",
|
||||
@@ -178,6 +187,14 @@
|
||||
"id": "7045e064-e666-4aea-9111-6e9d2007f27e",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/var/folders/td/vzm913rx77x21csd90g63_7c0000gn/T/ipykernel_7200/1754575056.py:22: LangChainDeprecationWarning: The method `BaseRetriever.get_relevant_documents` was deprecated in langchain-core 0.1.46 and will be removed in 1.0. Use invoke instead.\n",
|
||||
" docs = retriever.get_relevant_documents(question)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
@@ -215,7 +232,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 5,
|
||||
"id": "813cdcef-8b75-4214-a2ed-b89077b3d287",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -257,15 +274,25 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 6,
|
||||
"id": "aeb8b373-0289-4dec-bd4b-8b2701200301",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/Users/isaachershenson/.pyenv/versions/3.11.9/lib/python3.11/site-packages/langsmith/client.py:5301: LangChainBetaWarning: The function `loads` is in beta. It is actively being worked on, so the API may change.\n",
|
||||
" prompt = loads(json.dumps(prompt_object.manifest))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
" In an LLM-powered autonomous agent system, the Large Language Model (LLM) functions as the agent's brain. The agent has key components including memory, planning, and reflection mechanisms. The memory component is a long-term memory module that records a comprehensive list of agents’ experience in natural language. It includes a memory stream, which is an external database for storing past experiences. The reflection mechanism synthesizes memories into higher-level inferences over time and guides the agent's future behavior.\n"
|
||||
"1. In an LLM-powered autonomous agent system, the memory component is divided into short-term and long-term memories. Short-term memory utilizes in-context learning, while long-term memory provides the capability to retain and recall information over extended periods using an external vector store.\n",
|
||||
"2. The long-term memory module, also known as the memory stream, records a comprehensive list of agents' experiences in natural language.\n",
|
||||
"3. The agent learns to call external APIs for extra information that is missing from the model weights, including current information, code execution capability, access to proprietary information sources and more.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -299,7 +326,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 7,
|
||||
"id": "38345cff-e2d0-436e-aa09-599522a61eed",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -309,7 +336,7 @@
|
||||
"{'score': 'yes'}"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -339,7 +366,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 8,
|
||||
"id": "9771caa1-5542-47c3-8354-aeeafcf51964",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -349,7 +376,7 @@
|
||||
"{'score': 'yes'}"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -379,17 +406,17 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 9,
|
||||
"id": "830ba5f7-9c8d-4c01-83b1-e4d51d40d48f",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"' What is agent memory and how can it be effectively utilized in vector database retrieval?'"
|
||||
"\" What is the function of an agent's memory in a given context?\""
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -422,7 +449,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": 10,
|
||||
"id": "6c3c1c70-ff84-41e8-bf72-738ed52f2dde",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -448,7 +475,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"execution_count": 11,
|
||||
"id": "6e09087e-b2a9-437a-abee-129e426df799",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -475,7 +502,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"execution_count": 12,
|
||||
"id": "7c5fa507-77ae-426a-a65f-f518b9525bd0",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -700,7 +727,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"execution_count": 13,
|
||||
"id": "450eb313-ca75-4a43-b57e-7034bd3f40bf",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -752,7 +779,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"execution_count": 14,
|
||||
"id": "b095c1db-8bd1-4a34-937c-1a9b74ae74ff",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -762,11 +789,35 @@
|
||||
"text": [
|
||||
"---ROUTE QUESTION---\n",
|
||||
"What is the AlphaCodium paper about?\n",
|
||||
"{'datasource': 'web_search'}\n",
|
||||
"web_search\n",
|
||||
"---ROUTE QUESTION TO WEB SEARCH---\n",
|
||||
"---WEB SEARCH---\n",
|
||||
"\"Node 'web_search':\"\n",
|
||||
"{'datasource': 'vectorstore'}\n",
|
||||
"vectorstore\n",
|
||||
"---ROUTE QUESTION TO RAG---\n",
|
||||
"---RETRIEVE---\n",
|
||||
"\"Node 'retrieve':\"\n",
|
||||
"'\\n---\\n'\n",
|
||||
"---CHECK DOCUMENT RELEVANCE TO QUESTION---\n",
|
||||
"---GRADE: DOCUMENT NOT RELEVANT---\n",
|
||||
"---GRADE: DOCUMENT NOT RELEVANT---\n",
|
||||
"---GRADE: DOCUMENT NOT RELEVANT---\n",
|
||||
"---GRADE: DOCUMENT NOT RELEVANT---\n",
|
||||
"---ASSESS GRADED DOCUMENTS---\n",
|
||||
"---DECISION: ALL DOCUMENTS ARE NOT RELEVANT TO QUESTION, TRANSFORM QUERY---\n",
|
||||
"\"Node 'grade_documents':\"\n",
|
||||
"'\\n---\\n'\n",
|
||||
"---TRANSFORM QUERY---\n",
|
||||
"\"Node 'transform_query':\"\n",
|
||||
"'\\n---\\n'\n",
|
||||
"---RETRIEVE---\n",
|
||||
"\"Node 'retrieve':\"\n",
|
||||
"'\\n---\\n'\n",
|
||||
"---CHECK DOCUMENT RELEVANCE TO QUESTION---\n",
|
||||
"---GRADE: DOCUMENT NOT RELEVANT---\n",
|
||||
"---GRADE: DOCUMENT RELEVANT---\n",
|
||||
"---GRADE: DOCUMENT RELEVANT---\n",
|
||||
"---GRADE: DOCUMENT NOT RELEVANT---\n",
|
||||
"---ASSESS GRADED DOCUMENTS---\n",
|
||||
"---DECISION: GENERATE---\n",
|
||||
"\"Node 'grade_documents':\"\n",
|
||||
"'\\n---\\n'\n",
|
||||
"---GENERATE---\n",
|
||||
"---CHECK HALLUCINATIONS---\n",
|
||||
@@ -775,14 +826,15 @@
|
||||
"---DECISION: GENERATION ADDRESSES QUESTION---\n",
|
||||
"\"Node 'generate':\"\n",
|
||||
"'\\n---\\n'\n",
|
||||
"(' The AlphaCodium paper introduces a new approach for code generation by '\n",
|
||||
" 'Large Language Models (LLMs). It presents AlphaCodium, an iterative process '\n",
|
||||
" 'that involves generating additional data to aid the flow, and testing it on '\n",
|
||||
" 'the CodeContests dataset. The results show that AlphaCodium outperforms '\n",
|
||||
" \"DeepMind's AlphaCode and AlphaCode2 without fine-tuning a model. The \"\n",
|
||||
" 'approach includes a pre-processing phase for problem reasoning in natural '\n",
|
||||
" 'language and an iterative code generation phase with runs and fixes against '\n",
|
||||
" 'tests.')\n"
|
||||
"(' The \"AlphaCodium\" research paper appears to focus on the development and '\n",
|
||||
" 'comparison of an autonomous agent system powered by a large language model '\n",
|
||||
" '(LLM). The system is compared with several baselines, including ED, source '\n",
|
||||
" 'policy, and RL^2. The LLM-powered agent demonstrates impressive performance '\n",
|
||||
" 'in in-context reinforcement learning, getting close to the performance of '\n",
|
||||
" 'RL^2 despite only using offline RL and learning much faster than other '\n",
|
||||
" 'baselines. Additionally, the paper discusses the use of adversarial attacks '\n",
|
||||
" 'on LLMs as a potential threat to their safe behavior in real-world '\n",
|
||||
" 'applications.')\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -830,7 +882,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.8"
|
||||
"version": "3.11.9"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user