langchain-writer
This package contains the official LangChain integrations for Writer through their writer-sdk.
Installation and Setup
- Install the LangChain partner package:
pip install -U langchain-writer
- Sign up for Writer AI Studio and follow this 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):
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):
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)
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
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. To learn more about Writer, see the Writer developer documentation.
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.
Metadata
Release files for langchain-writer 0.3.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| langchain_writer-0.3.5.tar.gz | 18.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_writer-0.3.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.7 kB
Release files / langchain_writer-0.3.5.tar.gz
| Download URL | langchain_writer-0.3.5.tar.gz |
|---|---|
| Size | 18.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e1049228908215bbe911cfa9f485d929fcd7f4d65f2dfb3f7b847b91fe41a3e
|
|
BLAKE2b-256 checksum How to use checksums |
42a3d4ef69d9bc8b2fbecb1f606b5a01c889dde6a55da99602f592f493d182ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.13.7 Darwin/24.6.0
|
Release files / langchain_writer-0.3.5-py3-none-any.whl
| Download URL | langchain_writer-0.3.5-py3-none-any.whl |
|---|---|
| Size | 20.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be2a1699a0d3d75df70270b4ad7f356d7ee3e310eb7a5a650f1b24b4068ca449
|
|
BLAKE2b-256 checksum How to use checksums |
e0496a6f7b332fd385a03b8c74101b0fd47bbb63abd477109c0e26966e110531
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.13.7 Darwin/24.6.0
|
Security for langchain-writer 0.3.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.