File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,23 +123,40 @@ tokens = count_tokens(toon_str) # Uses tiktoken (gpt5/gpt5-mini)
123123## LangChain Integration
124124
125125Install with:
126+
126127``` bash
127128pip install " toon-python[langchain]"
128129```
130+
129131Adds a ** completely optional** LangChain integration via the ` [langchain] ` extra.
130132
131133### Features
134+
132135- ` ToonSerializer ` : ` Document ` → TOON (30-60 % token reduction)
133136- ` ToonOutputParser ` : TOON response → Python object
134137- Sync + async support
135138- 2 unit tests (100 % coverage for new code)
136139- README example + optional doc page
137140
138141## Usage After Release
142+
139143``` bash
140144pip install " toon-python[langchain]"
145+ ```
146+
147+ ``` python
141148from toon_format.langchain import ToonSerializer
149+ from langchain_openai import ChatOpenAI
150+ from langchain_core.prompts import ChatPromptTemplate
151+
152+ chain = (
153+ retriever
154+ | ToonSerializer() # converts docs → compact TOON
155+ | ChatPromptTemplate.from_template(" Answer using this data:\n {data} " )
156+ | ChatOpenAI()
157+ )
142158```
159+
143160## Development
144161
145162``` bash
You can’t perform that action at this time.
0 commit comments