mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-16 01:37:59 +00:00
docs: writer integration docs cosmetic fixes (#29984)
Fixed links at Writer partners integration docs
This commit is contained in:
parent
f69deee1bd
commit
d0c9b98171
@ -15,9 +15,9 @@
|
|||||||
"## Overview\n",
|
"## Overview\n",
|
||||||
"\n",
|
"\n",
|
||||||
"### Integration details\n",
|
"### Integration details\n",
|
||||||
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
|
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
|
||||||
"|:--------------------------------------------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
|
"|:-------------------------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
|
||||||
"| ChatWriter | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ |  |  |\n",
|
"| [ChatWriter](https://github.com/writer/langchain-writer/blob/main/langchain_writer/chat_models.py#L308) | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ |  |  |\n",
|
||||||
"### Model features\n",
|
"### Model features\n",
|
||||||
"| [Tool calling](/docs/how_to/tool_calling) | Structured output | JSON mode | Image input | Audio input | Video input | [Token-level streaming](/docs/how_to/chat_streaming/) | Native async | [Token usage](/docs/how_to/chat_token_usage_tracking/) | Logprobs |\n",
|
"| [Tool calling](/docs/how_to/tool_calling) | Structured output | JSON mode | Image input | Audio input | Video input | [Token-level streaming](/docs/how_to/chat_streaming/) | Native async | [Token usage](/docs/how_to/chat_token_usage_tracking/) | Logprobs |\n",
|
||||||
"| :---: |:-----------------:| :---: | :---: | :---: | :---: | :---: | :---: |:--------------------------------:|:--------:|\n",
|
"| :---: |:-----------------:| :---: | :---: | :---: | :---: | :---: | :---: |:--------------------------------:|:--------:|\n",
|
||||||
@ -36,17 +36,21 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "433e8d2b-9519-4b49-b2c4-7ab65b046c94",
|
"id": "433e8d2b-9519-4b49-b2c4-7ab65b046c94",
|
||||||
"metadata": {},
|
"metadata": {
|
||||||
"outputs": [],
|
"jupyter": {
|
||||||
|
"is_executing": true
|
||||||
|
}
|
||||||
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"import getpass\n",
|
"import getpass\n",
|
||||||
"import os\n",
|
"import os\n",
|
||||||
"\n",
|
"\n",
|
||||||
"if not os.getenv(\"WRITER_API_KEY\"):\n",
|
"if not os.getenv(\"WRITER_API_KEY\"):\n",
|
||||||
" os.environ[\"WRITER_API_KEY\"] = getpass.getpass(\"Enter your Writer API key: \")"
|
" os.environ[\"WRITER_API_KEY\"] = getpass.getpass(\"Enter your Writer API key: \")"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -58,14 +62,14 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "a15d341e-3e26-4ca3-830b-5aab30ed66de",
|
"id": "a15d341e-3e26-4ca3-830b-5aab30ed66de",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
|
"# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
|
||||||
"# os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")"
|
"# os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -79,13 +83,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "652d6238-1f87-422a-b135-f5abbb8652fc",
|
"id": "652d6238-1f87-422a-b135-f5abbb8652fc",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"%pip install -qU langchain-writer"
|
"%pip install -qU langchain-writer"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -99,10 +103,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "cb09c344-1836-4e0c-acf8-11d13ac1dbae",
|
"id": "cb09c344-1836-4e0c-acf8-11d13ac1dbae",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"from langchain_writer import ChatWriter\n",
|
"from langchain_writer import ChatWriter\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -113,7 +115,9 @@
|
|||||||
" timeout=None,\n",
|
" timeout=None,\n",
|
||||||
" max_retries=2,\n",
|
" max_retries=2,\n",
|
||||||
")"
|
")"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -127,12 +131,10 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "62e0dbc3",
|
"id": "62e0dbc3",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"messages = [\n",
|
"messages = [\n",
|
||||||
" (\n",
|
" (\n",
|
||||||
@ -143,7 +145,9 @@
|
|||||||
"]\n",
|
"]\n",
|
||||||
"ai_msg = llm.invoke(messages)\n",
|
"ai_msg = llm.invoke(messages)\n",
|
||||||
"ai_msg"
|
"ai_msg"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -155,13 +159,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "d86145b3-bfef-46e8-b227-4dda5c9c2705",
|
"id": "d86145b3-bfef-46e8-b227-4dda5c9c2705",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"print(ai_msg.content)"
|
"print(ai_msg.content)"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -175,10 +179,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "4a0f2112b3a4c79e",
|
"id": "4a0f2112b3a4c79e",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"messages = [\n",
|
"messages = [\n",
|
||||||
" (\n",
|
" (\n",
|
||||||
@ -189,7 +191,9 @@
|
|||||||
"]\n",
|
"]\n",
|
||||||
"ai_stream = llm.stream(messages)\n",
|
"ai_stream = llm.stream(messages)\n",
|
||||||
"ai_stream"
|
"ai_stream"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -201,14 +205,14 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "8c4b7b9b9308c757",
|
"id": "8c4b7b9b9308c757",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"for chunk in ai_stream:\n",
|
"for chunk in ai_stream:\n",
|
||||||
" print(chunk.content, end=\"\")"
|
" print(chunk.content, end=\"\")"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -236,10 +240,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "47e2f0faceca533",
|
"id": "47e2f0faceca533",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"from pydantic import BaseModel, Field\n",
|
"from pydantic import BaseModel, Field\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -251,7 +253,9 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"llm.bind_tools([GetWeather])"
|
"llm.bind_tools([GetWeather])"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -263,16 +267,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "765527dd533ec967",
|
"id": "765527dd533ec967",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"ai_msg = llm.invoke(\n",
|
"ai_msg = llm.invoke(\n",
|
||||||
" \"what is the weather like in New York City\",\n",
|
" \"what is the weather like in New York City\",\n",
|
||||||
")\n",
|
")\n",
|
||||||
"ai_msg"
|
"ai_msg"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -284,13 +288,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "f361c4769e772fe",
|
"id": "f361c4769e772fe",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"print(ai_msg.tool_calls)"
|
"print(ai_msg.tool_calls)"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -316,10 +320,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "c8a217f6190747fe",
|
"id": "c8a217f6190747fe",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"ai_batch = llm.batch(\n",
|
"ai_batch = llm.batch(\n",
|
||||||
" [\n",
|
" [\n",
|
||||||
@ -330,7 +332,9 @@
|
|||||||
" config={\"max_concurrency\": 3},\n",
|
" config={\"max_concurrency\": 3},\n",
|
||||||
")\n",
|
")\n",
|
||||||
"ai_batch"
|
"ai_batch"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -342,15 +346,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "b6a228d448f3df23",
|
"id": "b6a228d448f3df23",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"for batch in ai_batch:\n",
|
"for batch in ai_batch:\n",
|
||||||
" print(batch.content)\n",
|
" print(batch.content)\n",
|
||||||
" print(\"-\" * 100)"
|
" print(\"-\" * 100)"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -374,10 +378,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "e197d1d7-a070-4c96-9f8a-a0e86d046e0b",
|
"id": "e197d1d7-a070-4c96-9f8a-a0e86d046e0b",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"from langchain_core.prompts import ChatPromptTemplate\n",
|
"from langchain_core.prompts import ChatPromptTemplate\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -399,7 +401,9 @@
|
|||||||
" \"input\": \"I love programming.\",\n",
|
" \"input\": \"I love programming.\",\n",
|
||||||
" }\n",
|
" }\n",
|
||||||
")"
|
")"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
"## Overview\n",
|
"## Overview\n",
|
||||||
"\n",
|
"\n",
|
||||||
"### Integration details\n",
|
"### Integration details\n",
|
||||||
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
|
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
|
||||||
"|:------------------------------------------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
|
"|:-----------------------------------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
|
||||||
"| PDFParser | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ |  |  |"
|
"| [PDFParser](https://github.com/writer/langchain-writer/blob/main/langchain_writer/pdf_parser.py#L55) | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ |  |  |"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -31,17 +31,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "a8d653f15b7ee32d",
|
"id": "a8d653f15b7ee32d",
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"jupyter": {
|
|
||||||
"is_executing": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"%pip install --quiet -U langchain-writer"
|
"%pip install --quiet -U langchain-writer"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -55,17 +51,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "2983e19c9d555e58",
|
"id": "2983e19c9d555e58",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import getpass\n",
|
"import getpass\n",
|
||||||
"import os\n",
|
"import os\n",
|
||||||
"\n",
|
"\n",
|
||||||
"if not os.getenv(\"WRITER_API_KEY\"):\n",
|
"if not os.getenv(\"WRITER_API_KEY\"):\n",
|
||||||
" os.environ[\"WRITER_API_KEY\"] = getpass.getpass(\"Enter your Writer API key: \")"
|
" os.environ[\"WRITER_API_KEY\"] = getpass.getpass(\"Enter your Writer API key: \")"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -77,14 +73,14 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "98d8422ecee77403",
|
"id": "98d8422ecee77403",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
|
"# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
|
||||||
"# os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass()"
|
"# os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass()"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -98,15 +94,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "787b3ba8af32533f",
|
"id": "787b3ba8af32533f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"from langchain_writer.pdf_parser import PDFParser\n",
|
"from langchain_writer.pdf_parser import PDFParser\n",
|
||||||
"\n",
|
"\n",
|
||||||
"parser = PDFParser(format=\"markdown\")"
|
"parser = PDFParser(format=\"markdown\")"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -124,18 +120,18 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "d1a24b81a8a96f09",
|
"id": "d1a24b81a8a96f09",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"from langchain_core.documents.base import Blob\n",
|
"from langchain_core.documents.base import Blob\n",
|
||||||
"\n",
|
"\n",
|
||||||
"file = Blob.from_path(\"../../data/page_to_parse.pdf\")\n",
|
"file = Blob.from_path(\"../example_data/layout-parser-paper.pdf\")\n",
|
||||||
"\n",
|
"\n",
|
||||||
"parsed_pages = parser.parse(blob=file)\n",
|
"parsed_pages = parser.parse(blob=file)\n",
|
||||||
"parsed_pages"
|
"parsed_pages"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -149,14 +145,14 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "e2f7fd52b7188c6c",
|
"id": "e2f7fd52b7188c6c",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"parsed_pages_async = await parser.aparse(blob=file)\n",
|
"parsed_pages_async = await parser.aparse(blob=file)\n",
|
||||||
"parsed_pages_async"
|
"parsed_pages_async"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
|
@ -51,3 +51,5 @@ Support of basic function calls defined via dicts, Pydantic, python functions et
|
|||||||
```python
|
```python
|
||||||
from langchain_writer.tools import GraphTool
|
from langchain_writer.tools import GraphTool
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Writer-specific remotely invoking tool
|
@ -14,9 +14,9 @@
|
|||||||
"## Overview\n",
|
"## Overview\n",
|
||||||
"\n",
|
"\n",
|
||||||
"### Integration details\n",
|
"### Integration details\n",
|
||||||
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
|
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
|
||||||
"|:-----------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
|
"|:-----------------------------------------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
|
||||||
"| WriterTextSplitter | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ |  |  |"
|
"| [WriterTextSplitter](https://github.com/writer/langchain-writer/blob/main/langchain_writer/text_splitter.py#L11) | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ |  |  |"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -31,11 +31,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "a8d653f15b7ee32d",
|
"id": "a8d653f15b7ee32d",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
|
"source": "%pip install --quiet -U langchain-writer",
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": "%pip install --quiet -U langchain-writer"
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -49,17 +49,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "2983e19c9d555e58",
|
"id": "2983e19c9d555e58",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import getpass\n",
|
"import getpass\n",
|
||||||
"import os\n",
|
"import os\n",
|
||||||
"\n",
|
"\n",
|
||||||
"if not os.getenv(\"WRITER_API_KEY\"):\n",
|
"if not os.getenv(\"WRITER_API_KEY\"):\n",
|
||||||
" os.environ[\"WRITER_API_KEY\"] = getpass.getpass(\"Enter your Writer API key: \")"
|
" os.environ[\"WRITER_API_KEY\"] = getpass.getpass(\"Enter your Writer API key: \")"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -71,14 +71,14 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "98d8422ecee77403",
|
"id": "98d8422ecee77403",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
|
"# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
|
||||||
"# os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass()"
|
"# os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass()"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -96,15 +96,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "787b3ba8af32533f",
|
"id": "787b3ba8af32533f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"from langchain_writer.text_splitter import WriterTextSplitter\n",
|
"from langchain_writer.text_splitter import WriterTextSplitter\n",
|
||||||
"\n",
|
"\n",
|
||||||
"splitter = WriterTextSplitter(strategy=\"fast_split\")"
|
"splitter = WriterTextSplitter(strategy=\"fast_split\")"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -120,10 +120,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "d1a24b81a8a96f09",
|
"id": "d1a24b81a8a96f09",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"text = \"\"\"Reeeeeeeeeeeeeeeeeeeeeaally long text you want to divide into smaller chunks. For example you can add a poem multiple times:\n",
|
"text = \"\"\"Reeeeeeeeeeeeeeeeeeeeeaally long text you want to divide into smaller chunks. For example you can add a poem multiple times:\n",
|
||||||
"Two roads diverged in a yellow wood,\n",
|
"Two roads diverged in a yellow wood,\n",
|
||||||
@ -201,7 +199,9 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"chunks = splitter.split_text(text)\n",
|
"chunks = splitter.split_text(text)\n",
|
||||||
"chunks"
|
"chunks"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -213,13 +213,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "a470daa875d99006",
|
"id": "a470daa875d99006",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"print(len(chunks))"
|
"print(len(chunks))"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -232,14 +232,14 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "e2f7fd52b7188c6c",
|
"id": "e2f7fd52b7188c6c",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"async_chunks = await splitter.asplit_text(text)\n",
|
"async_chunks = await splitter.asplit_text(text)\n",
|
||||||
"async_chunks"
|
"async_chunks"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -251,13 +251,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "a1439db14e687fa4",
|
"id": "a1439db14e687fa4",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"print(len(async_chunks))"
|
"print(len(async_chunks))"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"### Integration details\n",
|
"### Integration details\n",
|
||||||
"\n",
|
"\n",
|
||||||
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
|
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
|
||||||
"|:-------------------------------------------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
|
"|:-----------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
|
||||||
"| GraphTool | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ |  |  |\n",
|
"| [GraphTool](https://github.com/writer/langchain-writer/blob/main/langchain_writer/tools.py#L9) | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ |  |  |\n",
|
||||||
"\n",
|
"\n",
|
||||||
"### Features\n",
|
"### Features\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -43,17 +43,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "80d4e1a791aaa8",
|
"id": "80d4e1a791aaa8",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import getpass\n",
|
"import getpass\n",
|
||||||
"import os\n",
|
"import os\n",
|
||||||
"\n",
|
"\n",
|
||||||
"if not os.getenv(\"WRITER_API_KEY\"):\n",
|
"if not os.getenv(\"WRITER_API_KEY\"):\n",
|
||||||
" os.environ[\"WRITER_API_KEY\"] = getpass.getpass(\"Enter your Writer API key: \")"
|
" os.environ[\"WRITER_API_KEY\"] = getpass.getpass(\"Enter your Writer API key: \")"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -77,10 +77,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "6faaae25509f0f28",
|
"id": "6faaae25509f0f28",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"from langchain_writer.chat_models import ChatWriter\n",
|
"from langchain_writer.chat_models import ChatWriter\n",
|
||||||
"from langchain_writer.tools import GraphTool\n",
|
"from langchain_writer.tools import GraphTool\n",
|
||||||
@ -89,7 +87,9 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"graph_id = getpass.getpass(\"Enter Writer Knowledge Graph ID: \")\n",
|
"graph_id = getpass.getpass(\"Enter Writer Knowledge Graph ID: \")\n",
|
||||||
"graph_tool = GraphTool(graph_ids=[graph_id])"
|
"graph_tool = GraphTool(graph_ids=[graph_id])"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -99,10 +99,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "e98d7deedb0e5c6f",
|
"id": "e98d7deedb0e5c6f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"from typing import Optional\n",
|
"from typing import Optional\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -154,7 +152,9 @@
|
|||||||
" },\n",
|
" },\n",
|
||||||
" },\n",
|
" },\n",
|
||||||
"}"
|
"}"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -167,15 +167,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "a4833f2597a87777",
|
"id": "a4833f2597a87777",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"chat.bind_tools(\n",
|
"chat.bind_tools(\n",
|
||||||
" [graph_tool, get_supercopa_trophies_count, GetWeather, get_product_info]\n",
|
" [graph_tool, get_supercopa_trophies_count, GetWeather, get_product_info]\n",
|
||||||
")"
|
")"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -187,13 +187,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "ccb61b945a56672b",
|
"id": "ccb61b945a56672b",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"chat.tools"
|
"chat.tools"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -205,13 +205,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "381f0d4b9a8357a4",
|
"id": "381f0d4b9a8357a4",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"chat.tool_choice"
|
"chat.tool_choice"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -225,10 +225,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "74df06b58b5dc2e9",
|
"id": "74df06b58b5dc2e9",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"from langchain_core.messages import HumanMessage\n",
|
"from langchain_core.messages import HumanMessage\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -240,7 +238,9 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"response = chat.invoke(messages)\n",
|
"response = chat.invoke(messages)\n",
|
||||||
"messages.append(response)"
|
"messages.append(response)"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -252,13 +252,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "e271e0fc677446b2",
|
"id": "e271e0fc677446b2",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"print(response.tool_calls)"
|
"print(response.tool_calls)"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -270,10 +270,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "156b58108aa9b367",
|
"id": "156b58108aa9b367",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"for tool_call in response.tool_calls:\n",
|
"for tool_call in response.tool_calls:\n",
|
||||||
" selected_tool = {\n",
|
" selected_tool = {\n",
|
||||||
@ -284,7 +282,9 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"response = chat.invoke(messages)\n",
|
"response = chat.invoke(messages)\n",
|
||||||
"print(response.content)"
|
"print(response.content)"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -296,13 +296,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "4b3c6f05096fc9e3",
|
"id": "4b3c6f05096fc9e3",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"print(response.additional_kwargs[\"graph_data\"])"
|
"print(response.additional_kwargs[\"graph_data\"])"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -314,13 +314,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "eb6e0da74b10b8fc",
|
"id": "eb6e0da74b10b8fc",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"print(response.content)"
|
"print(response.content)"
|
||||||
]
|
],
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
@ -329,7 +329,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Chaining\n",
|
"## Chaining\n",
|
||||||
"\n",
|
"\n",
|
||||||
"#TODO: fill chaining section"
|
"Due to specificity of Writer Graph tool (you don't need to call it manually, Writer server will call it by himself and return RAG based generation) it's impossible to invoke it separately, so GraphTool can't be used as part of chain"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user