docs: writer integration docs cosmetic fixes (#29984)

Fixed links at Writer partners integration docs
This commit is contained in:
Yan 2025-02-27 18:52:49 +03:00 committed by GitHub
parent f69deee1bd
commit d0c9b98171
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 138 additions and 136 deletions

View File

@ -15,9 +15,9 @@
"## Overview\n",
"\n",
"### Integration details\n",
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
"|:--------------------------------------------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
"| ChatWriter | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ | ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain-writer?style=flat-square&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain-writer?style=flat-square&label=%20) |\n",
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
"|:-------------------------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
"| [ChatWriter](https://github.com/writer/langchain-writer/blob/main/langchain_writer/chat_models.py#L308) | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ | ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain-writer?style=flat-square&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain-writer?style=flat-square&label=%20) |\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",
"| :---: |:-----------------:| :---: | :---: | :---: | :---: | :---: | :---: |:--------------------------------:|:--------:|\n",
@ -36,17 +36,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "433e8d2b-9519-4b49-b2c4-7ab65b046c94",
"metadata": {},
"outputs": [],
"metadata": {
"jupyter": {
"is_executing": true
}
},
"source": [
"import getpass\n",
"import os\n",
"\n",
"if not os.getenv(\"WRITER_API_KEY\"):\n",
" os.environ[\"WRITER_API_KEY\"] = getpass.getpass(\"Enter your Writer API key: \")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -58,14 +62,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "a15d341e-3e26-4ca3-830b-5aab30ed66de",
"metadata": {},
"outputs": [],
"source": [
"# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
"# os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -79,13 +83,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "652d6238-1f87-422a-b135-f5abbb8652fc",
"metadata": {},
"outputs": [],
"source": [
"%pip install -qU langchain-writer"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -99,10 +103,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "cb09c344-1836-4e0c-acf8-11d13ac1dbae",
"metadata": {},
"outputs": [],
"source": [
"from langchain_writer import ChatWriter\n",
"\n",
@ -113,7 +115,9 @@
" timeout=None,\n",
" max_retries=2,\n",
")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -127,12 +131,10 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "62e0dbc3",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"messages = [\n",
" (\n",
@ -143,7 +145,9 @@
"]\n",
"ai_msg = llm.invoke(messages)\n",
"ai_msg"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -155,13 +159,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "d86145b3-bfef-46e8-b227-4dda5c9c2705",
"metadata": {},
"outputs": [],
"source": [
"print(ai_msg.content)"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -175,10 +179,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "4a0f2112b3a4c79e",
"metadata": {},
"outputs": [],
"source": [
"messages = [\n",
" (\n",
@ -189,7 +191,9 @@
"]\n",
"ai_stream = llm.stream(messages)\n",
"ai_stream"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -201,14 +205,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "8c4b7b9b9308c757",
"metadata": {},
"outputs": [],
"source": [
"for chunk in ai_stream:\n",
" print(chunk.content, end=\"\")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -236,10 +240,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "47e2f0faceca533",
"metadata": {},
"outputs": [],
"source": [
"from pydantic import BaseModel, Field\n",
"\n",
@ -251,7 +253,9 @@
"\n",
"\n",
"llm.bind_tools([GetWeather])"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -263,16 +267,16 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "765527dd533ec967",
"metadata": {},
"outputs": [],
"source": [
"ai_msg = llm.invoke(\n",
" \"what is the weather like in New York City\",\n",
")\n",
"ai_msg"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -284,13 +288,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "f361c4769e772fe",
"metadata": {},
"outputs": [],
"source": [
"print(ai_msg.tool_calls)"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -316,10 +320,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "c8a217f6190747fe",
"metadata": {},
"outputs": [],
"source": [
"ai_batch = llm.batch(\n",
" [\n",
@ -330,7 +332,9 @@
" config={\"max_concurrency\": 3},\n",
")\n",
"ai_batch"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -342,15 +346,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "b6a228d448f3df23",
"metadata": {},
"outputs": [],
"source": [
"for batch in ai_batch:\n",
" print(batch.content)\n",
" print(\"-\" * 100)"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -374,10 +378,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "e197d1d7-a070-4c96-9f8a-a0e86d046e0b",
"metadata": {},
"outputs": [],
"source": [
"from langchain_core.prompts import ChatPromptTemplate\n",
"\n",
@ -399,7 +401,9 @@
" \"input\": \"I love programming.\",\n",
" }\n",
")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",

View File

@ -14,9 +14,9 @@
"## Overview\n",
"\n",
"### Integration details\n",
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
"|:------------------------------------------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
"| PDFParser | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ | ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain-writer?style=flat-square&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain-writer?style=flat-square&label=%20) |"
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
"|:-----------------------------------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
"| [PDFParser](https://github.com/writer/langchain-writer/blob/main/langchain_writer/pdf_parser.py#L55) | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ | ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain-writer?style=flat-square&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain-writer?style=flat-square&label=%20) |"
]
},
{
@ -31,17 +31,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "a8d653f15b7ee32d",
"metadata": {
"jupyter": {
"is_executing": true
}
},
"outputs": [],
"metadata": {},
"source": [
"%pip install --quiet -U langchain-writer"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -55,17 +51,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "2983e19c9d555e58",
"metadata": {},
"outputs": [],
"source": [
"import getpass\n",
"import os\n",
"\n",
"if not os.getenv(\"WRITER_API_KEY\"):\n",
" os.environ[\"WRITER_API_KEY\"] = getpass.getpass(\"Enter your Writer API key: \")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -77,14 +73,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "98d8422ecee77403",
"metadata": {},
"outputs": [],
"source": [
"# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
"# os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass()"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -98,15 +94,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "787b3ba8af32533f",
"metadata": {},
"outputs": [],
"source": [
"from langchain_writer.pdf_parser import PDFParser\n",
"\n",
"parser = PDFParser(format=\"markdown\")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -124,18 +120,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "d1a24b81a8a96f09",
"metadata": {},
"outputs": [],
"source": [
"from langchain_core.documents.base import Blob\n",
"\n",
"file = Blob.from_path(\"../../data/page_to_parse.pdf\")\n",
"file = Blob.from_path(\"../example_data/layout-parser-paper.pdf\")\n",
"\n",
"parsed_pages = parser.parse(blob=file)\n",
"parsed_pages"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -149,14 +145,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "e2f7fd52b7188c6c",
"metadata": {},
"outputs": [],
"source": [
"parsed_pages_async = await parser.aparse(blob=file)\n",
"parsed_pages_async"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",

View File

@ -51,3 +51,5 @@ Support of basic function calls defined via dicts, Pydantic, python functions et
```python
from langchain_writer.tools import GraphTool
```
Writer-specific remotely invoking tool

View File

@ -14,9 +14,9 @@
"## Overview\n",
"\n",
"### Integration details\n",
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
"|:-----------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
"| WriterTextSplitter | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ | ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain-writer?style=flat-square&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain-writer?style=flat-square&label=%20) |"
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
"|:-----------------------------------------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
"| [WriterTextSplitter](https://github.com/writer/langchain-writer/blob/main/langchain_writer/text_splitter.py#L11) | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ | ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain-writer?style=flat-square&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain-writer?style=flat-square&label=%20) |"
]
},
{
@ -31,11 +31,11 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "a8d653f15b7ee32d",
"metadata": {},
"source": "%pip install --quiet -U langchain-writer",
"outputs": [],
"source": "%pip install --quiet -U langchain-writer"
"execution_count": null
},
{
"cell_type": "markdown",
@ -49,17 +49,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "2983e19c9d555e58",
"metadata": {},
"outputs": [],
"source": [
"import getpass\n",
"import os\n",
"\n",
"if not os.getenv(\"WRITER_API_KEY\"):\n",
" os.environ[\"WRITER_API_KEY\"] = getpass.getpass(\"Enter your Writer API key: \")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -71,14 +71,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "98d8422ecee77403",
"metadata": {},
"outputs": [],
"source": [
"# os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
"# os.environ[\"LANGCHAIN_API_KEY\"] = getpass.getpass()"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -96,15 +96,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "787b3ba8af32533f",
"metadata": {},
"outputs": [],
"source": [
"from langchain_writer.text_splitter import WriterTextSplitter\n",
"\n",
"splitter = WriterTextSplitter(strategy=\"fast_split\")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -120,10 +120,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "d1a24b81a8a96f09",
"metadata": {},
"outputs": [],
"source": [
"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",
@ -201,7 +199,9 @@
"\n",
"chunks = splitter.split_text(text)\n",
"chunks"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -213,13 +213,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "a470daa875d99006",
"metadata": {},
"outputs": [],
"source": [
"print(len(chunks))"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -232,14 +232,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "e2f7fd52b7188c6c",
"metadata": {},
"outputs": [],
"source": [
"async_chunks = await splitter.asplit_text(text)\n",
"async_chunks"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -251,13 +251,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "a1439db14e687fa4",
"metadata": {},
"outputs": [],
"source": [
"print(len(async_chunks))"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",

View File

@ -14,9 +14,9 @@
"\n",
"### Integration details\n",
"\n",
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
"|:-------------------------------------------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
"| GraphTool | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ | ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain-writer?style=flat-square&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain-writer?style=flat-square&label=%20) |\n",
"| Class | Package | Local | Serializable | JS support | Package downloads | Package latest |\n",
"|:-----------------------------------------------------------------------------------------------------------|:-----------------| :---: | :---: |:----------:|:------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------:|\n",
"| [GraphTool](https://github.com/writer/langchain-writer/blob/main/langchain_writer/tools.py#L9) | [langchain-writer](https://pypi.org/project/langchain-writer/) | ❌ | ❌ | ❌ | ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain-writer?style=flat-square&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain-writer?style=flat-square&label=%20) |\n",
"\n",
"### Features\n",
"\n",
@ -43,17 +43,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "80d4e1a791aaa8",
"metadata": {},
"outputs": [],
"source": [
"import getpass\n",
"import os\n",
"\n",
"if not os.getenv(\"WRITER_API_KEY\"):\n",
" os.environ[\"WRITER_API_KEY\"] = getpass.getpass(\"Enter your Writer API key: \")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -77,10 +77,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "6faaae25509f0f28",
"metadata": {},
"outputs": [],
"source": [
"from langchain_writer.chat_models import ChatWriter\n",
"from langchain_writer.tools import GraphTool\n",
@ -89,7 +87,9 @@
"\n",
"graph_id = getpass.getpass(\"Enter Writer Knowledge Graph ID: \")\n",
"graph_tool = GraphTool(graph_ids=[graph_id])"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -99,10 +99,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "e98d7deedb0e5c6f",
"metadata": {},
"outputs": [],
"source": [
"from typing import Optional\n",
"\n",
@ -154,7 +152,9 @@
" },\n",
" },\n",
"}"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -167,15 +167,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "a4833f2597a87777",
"metadata": {},
"outputs": [],
"source": [
"chat.bind_tools(\n",
" [graph_tool, get_supercopa_trophies_count, GetWeather, get_product_info]\n",
")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -187,13 +187,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "ccb61b945a56672b",
"metadata": {},
"outputs": [],
"source": [
"chat.tools"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -205,13 +205,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "381f0d4b9a8357a4",
"metadata": {},
"outputs": [],
"source": [
"chat.tool_choice"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -225,10 +225,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "74df06b58b5dc2e9",
"metadata": {},
"outputs": [],
"source": [
"from langchain_core.messages import HumanMessage\n",
"\n",
@ -240,7 +238,9 @@
"\n",
"response = chat.invoke(messages)\n",
"messages.append(response)"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -252,13 +252,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "e271e0fc677446b2",
"metadata": {},
"outputs": [],
"source": [
"print(response.tool_calls)"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -270,10 +270,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "156b58108aa9b367",
"metadata": {},
"outputs": [],
"source": [
"for tool_call in response.tool_calls:\n",
" selected_tool = {\n",
@ -284,7 +282,9 @@
"\n",
"response = chat.invoke(messages)\n",
"print(response.content)"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -296,13 +296,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "4b3c6f05096fc9e3",
"metadata": {},
"outputs": [],
"source": [
"print(response.additional_kwargs[\"graph_data\"])"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -314,13 +314,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "eb6e0da74b10b8fc",
"metadata": {},
"outputs": [],
"source": [
"print(response.content)"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
@ -329,7 +329,7 @@
"source": [
"## Chaining\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"
]
},
{