langchain-writer
, we provide usage of WRITER’s context-aware splitting endpoint as a LangChain text splitter.
Overview
Integration details
Class | Package | Local | Serializable | JS support | Downloads | Version |
---|---|---|---|---|---|---|
WriterTextSplitter | langchain-writer | ❌ | ❌ | ❌ |
Setup
TheWriterTextSplitter
is available in the langchain-writer
package:
Credentials
Sign up for WRITER AI Studio to generate an API key (you can follow this Quickstart). Then, set the WRITER_API_KEY environment variable:LANGSMITH_TRACING
and LANGSMITH_API_KEY
environment variables:
Instantiation
Instantiate an instance ofWriterTextSplitter
with the strategy
parameter set to one of the following:
llm_split
: Uses language model for precise semantic splittingfast_split
: Uses heuristic-based approach for quick splittinghybrid_split
: Combines both approaches
Usage
TheWriterTextSplitter
can be used synchronously or asynchronously.
Synchronous usage
To use theWriterTextSplitter
synchronously, call the split_text
method with the text you want to split:
Asynchronous usage
To use theWriterTextSplitter
asynchronously, call the asplit_text
method with the text you want to split:
API reference
For detailed documentation of allWriterTextSplitter
features and configurations head to the API reference.