Name | langchain-writer JSON |
Version |
0.3.3
JSON |
| download |
home_page | https://www.writer.com |
Summary | An integration package connecting Writer and LangChain |
upload_time | 2025-08-19 10:19:09 |
maintainer | None |
docs_url | None |
author | Writer, Inc. |
requires_python | <4.0,>=3.9 |
license | MIT |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# langchain-writer
This package contains the official LangChain integrations for Writer through their `writer-sdk`.
## Installation and Setup
- Install the LangChain partner package:
```bash
pip install -U langchain-writer
```
- Sign up for [Writer AI Studio](https://app.writer.com/aistudio/signup?utm_campaign=devrel) and follow this [Quickstart](https://dev.writer.com/api-guides/quickstart) to obtain an API key.
- Set your Writer API key as an environment variable (`WRITER_API_KEY`).
## Chat capabilities
The `ChatWriter` class provides support of streaming and non-streaming chat completions, tool calls, batching, and asynchronous usage.
### Streaming (sync/async):
```python
from langchain_writer import ChatWriter
llm = ChatWriter()
# Sync chat call
generator = llm.stream("Sing a ballad of LangChain.")
for chunk in generator:
print(chunk)
# Async chat call
generator = await llm.astream("Sing a ballad of LangChain.")
async for chunk in generator:
print(chunk)
```
### Non-streaming (sync/async):
```python
from langchain_writer import ChatWriter
llm = ChatWriter()
# Sync chat call
llm.invoke("Sing a ballad of LangChain.")
# Async chat call
await llm.ainvoke("Sing a ballad of LangChain.")
```
### Batching (sync/async)
```python
from langchain_writer import ChatWriter
llm = ChatWriter()
llm.batch(
[
"How to cook pancakes?",
"How to compose poem?",
"How to run faster?",
],
config={"max_concurrency": 2},
)
```
### Tool binding
```python
from langchain_writer import ChatWriter
from langchain_core.tools import tool
from typing import Optional
from pydantic import BaseModel, Field
@tool
def get_supercopa_trophies_count(club_name: str) -> Optional[int]:
"""Returns information about supercopa trophies count.
Args:
club_name: Club you want to investigate info of supercopa trophies about
Returns:
Number of supercopa trophies or None if there is no info about requested club
"""
# Tool implementation
class GetWeather(BaseModel):
'''Get the current weather in a given location'''
location: str = Field(..., description="The city and state, e.g. San Francisco, CA")
llm = ChatWriter()
llm.bind_tools([get_supercopa_trophies_count, GetWeather])
```
## Additional resources
To learn more about LangChain, see the [official LangChain documentation](https://python.langchain.com/docs/introduction/). To learn more about Writer, see the [Writer developer documentation](https://dev.writer.com/home/introduction).
## About Writer
Writer is the full-stack generative AI platform for enterprises. Quickly and easily build and deploy generative AI apps with a suite of developer tools fully integrated with our platform of LLMs, graph-based RAG tools, AI guardrails, and more. Learn more at [writer.com](https://www.writer.com?utm_source=github&utm_medium=readme&utm_campaign=devrel).
Raw data
{
"_id": null,
"home_page": "https://www.writer.com",
"name": "langchain-writer",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Writer, Inc.",
"author_email": "dev-feedback@writer.com",
"download_url": "https://files.pythonhosted.org/packages/b5/22/4510f4402549414e2fdb06b2f3b930ad29c42f79900f5c72dbc77d3b0312/langchain_writer-0.3.3.tar.gz",
"platform": null,
"description": "# langchain-writer\n\nThis package contains the official LangChain integrations for Writer through their `writer-sdk`.\n\n## Installation and Setup\n\n- Install the LangChain partner package:\n\n```bash\npip install -U langchain-writer\n```\n\n- Sign up for [Writer AI Studio](https://app.writer.com/aistudio/signup?utm_campaign=devrel) and follow this [Quickstart](https://dev.writer.com/api-guides/quickstart) to obtain an API key.\n- Set your Writer API key as an environment variable (`WRITER_API_KEY`).\n\n## Chat capabilities\n\nThe `ChatWriter` class provides support of streaming and non-streaming chat completions, tool calls, batching, and asynchronous usage.\n\n### Streaming (sync/async):\n```python\nfrom langchain_writer import ChatWriter\n\nllm = ChatWriter()\n\n# Sync chat call\ngenerator = llm.stream(\"Sing a ballad of LangChain.\")\n\nfor chunk in generator:\n print(chunk)\n\n# Async chat call\ngenerator = await llm.astream(\"Sing a ballad of LangChain.\")\n\nasync for chunk in generator:\n print(chunk)\n```\n\n### Non-streaming (sync/async):\n\n```python\nfrom langchain_writer import ChatWriter\n\nllm = ChatWriter()\n\n# Sync chat call\nllm.invoke(\"Sing a ballad of LangChain.\")\n\n# Async chat call\nawait llm.ainvoke(\"Sing a ballad of LangChain.\")\n```\n\n### Batching (sync/async)\n\n```python\nfrom langchain_writer import ChatWriter\n\nllm = ChatWriter()\n\nllm.batch(\n [\n \"How to cook pancakes?\",\n \"How to compose poem?\",\n \"How to run faster?\",\n ],\n config={\"max_concurrency\": 2},\n )\n```\n\n### Tool binding\n\n```python\nfrom langchain_writer import ChatWriter\nfrom langchain_core.tools import tool\nfrom typing import Optional\nfrom pydantic import BaseModel, Field\n\n\n@tool\ndef get_supercopa_trophies_count(club_name: str) -> Optional[int]:\n \"\"\"Returns information about supercopa trophies count.\n\n Args:\n club_name: Club you want to investigate info of supercopa trophies about\n\n Returns:\n Number of supercopa trophies or None if there is no info about requested club\n \"\"\"\n # Tool implementation\n\n\nclass GetWeather(BaseModel):\n '''Get the current weather in a given location'''\n\n location: str = Field(..., description=\"The city and state, e.g. San Francisco, CA\")\n\n\nllm = ChatWriter()\n\nllm.bind_tools([get_supercopa_trophies_count, GetWeather])\n```\n\n## Additional resources\nTo learn more about LangChain, see the [official LangChain documentation](https://python.langchain.com/docs/introduction/). To learn more about Writer, see the [Writer developer documentation](https://dev.writer.com/home/introduction).\n\n## About Writer\nWriter is the full-stack generative AI platform for enterprises. Quickly and easily build and deploy generative AI apps with a suite of developer tools fully integrated with our platform of LLMs, graph-based RAG tools, AI guardrails, and more. Learn more at [writer.com](https://www.writer.com?utm_source=github&utm_medium=readme&utm_campaign=devrel).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "An integration package connecting Writer and LangChain",
"version": "0.3.3",
"project_urls": {
"Documentation": "https://dev.writer.com",
"Homepage": "https://www.writer.com",
"Repository": "https://github.com/writer/langchain-writer"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5852b72db332c4d0284da33ef4bf945539458c7b88ac37f19e0426819c472ccd",
"md5": "beed369df050e0624a479cb6dd88075d",
"sha256": "41d012f69287b52eb2dd32e4e0fc994f8520e84d2b82794f757e2d4f2f6dab42"
},
"downloads": -1,
"filename": "langchain_writer-0.3.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "beed369df050e0624a479cb6dd88075d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 19411,
"upload_time": "2025-08-19T10:19:08",
"upload_time_iso_8601": "2025-08-19T10:19:08.151429Z",
"url": "https://files.pythonhosted.org/packages/58/52/b72db332c4d0284da33ef4bf945539458c7b88ac37f19e0426819c472ccd/langchain_writer-0.3.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b5224510f4402549414e2fdb06b2f3b930ad29c42f79900f5c72dbc77d3b0312",
"md5": "adc8474410f4d44fb18d81b89a72d870",
"sha256": "6fc413ec95843223f7472d054f7aafe2c476c4490e67c76b183180d382acef74"
},
"downloads": -1,
"filename": "langchain_writer-0.3.3.tar.gz",
"has_sig": false,
"md5_digest": "adc8474410f4d44fb18d81b89a72d870",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 17501,
"upload_time": "2025-08-19T10:19:09",
"upload_time_iso_8601": "2025-08-19T10:19:09.375242Z",
"url": "https://files.pythonhosted.org/packages/b5/22/4510f4402549414e2fdb06b2f3b930ad29c42f79900f5c72dbc77d3b0312/langchain_writer-0.3.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-19 10:19:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "writer",
"github_project": "langchain-writer",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "langchain-writer"
}