mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-12 12:47:53 +02:00
Add doc strings for all channels, small update to names/semantics
This commit is contained in:
+13
-13
@@ -25,7 +25,7 @@
|
||||
"from langchain.schema.document import Document\n",
|
||||
"from langchain.schema import format_document\n",
|
||||
"\n",
|
||||
"from permchain import Pregel, PregelRead, channels\n"
|
||||
"from permchain import Pregel, PregelRead, channels"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -45,7 +45,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langchain.schema.runnable import RunnableLambda\n"
|
||||
"from langchain.schema.runnable import RunnableLambda"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -59,7 +59,7 @@
|
||||
"\n",
|
||||
"_combine_documents = RunnableLambda(\n",
|
||||
" lambda x: format_document(x, DEFAULT_DOCUMENT_PROMPT)\n",
|
||||
").map() | (lambda x: \"\\n\\n\".join(x))\n"
|
||||
").map() | (lambda x: \"\\n\\n\".join(x))"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -72,7 +72,7 @@
|
||||
"docs = [\n",
|
||||
" Document(page_content=\"Harrison used to work at Kensho\"),\n",
|
||||
" Document(page_content=\"Ankush worked at Facebook\"),\n",
|
||||
"]\n"
|
||||
"]"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -98,7 +98,7 @@
|
||||
" )\n",
|
||||
" | ChatOpenAI()\n",
|
||||
" | StrOutputParser()\n",
|
||||
")\n"
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -119,7 +119,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"stuff_chain.invoke({\"question\": \"where did harrison work\", \"docs\": docs})\n"
|
||||
"stuff_chain.invoke({\"question\": \"where did harrison work\", \"docs\": docs})"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -139,7 +139,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"many_docs = docs * 5\n"
|
||||
"many_docs = docs * 5"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -164,7 +164,7 @@
|
||||
" new_result_doc_list.append(_sub_result_docs[:-1])\n",
|
||||
" _sub_result_docs = _sub_result_docs[-1:]\n",
|
||||
" new_result_doc_list.append(_sub_result_docs)\n",
|
||||
" return new_result_doc_list\n"
|
||||
" return new_result_doc_list"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -196,7 +196,7 @@
|
||||
"source": [
|
||||
"# Just to show what its like split\n",
|
||||
"split_docs = _split_list_of_docs(many_docs)\n",
|
||||
"split_docs\n"
|
||||
"split_docs"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -214,7 +214,7 @@
|
||||
" \"docs_to_finalize\": channels.Inbox(Document),\n",
|
||||
" # output\n",
|
||||
" \"answer\": channels.LastValue(str),\n",
|
||||
"}\n"
|
||||
"}"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -249,7 +249,7 @@
|
||||
" Pregel.subscribe_to(\"docs_to_finalize\", key=\"docs\").join([\"question\"])\n",
|
||||
" | stuff_chain\n",
|
||||
" | Pregel.write_to(\"answer\")\n",
|
||||
")\n"
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -268,7 +268,7 @@
|
||||
" input=[\"question\", \"docs\"],\n",
|
||||
" output=\"answer\",\n",
|
||||
" debug=True,\n",
|
||||
")\n"
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -332,7 +332,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"reduce_chain.invoke({\"question\": \"where did harrison work\", \"docs\": many_docs})\n"
|
||||
"reduce_chain.invoke({\"question\": \"where did harrison work\", \"docs\": many_docs})"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -86,8 +86,8 @@ def recursive_web_loader(
|
||||
channels = {
|
||||
"base_url": Channels.LastValue(str),
|
||||
"next_urls": Channels.UniqueInbox(str),
|
||||
"documents": Channels.Stream(Document),
|
||||
"visited": Channels.Set(str),
|
||||
"documents": Channels.Archive(Document),
|
||||
"visited": Channels.UniqueArchive(str),
|
||||
"client": Channels.ContextManager(httpx_client, httpx_aclient),
|
||||
}
|
||||
# the main chain that gets executed recursively
|
||||
|
||||
Reference in New Issue
Block a user