Skip to content

Commit 1c66aea

Browse files
authored
Update README with LangChain integration info
Added LangChain integration details and usage examples.
1 parent c101135 commit 1c66aea

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,23 +123,40 @@ tokens = count_tokens(toon_str) # Uses tiktoken (gpt5/gpt5-mini)
123123
## LangChain Integration
124124

125125
Install with:
126+
126127
```bash
127128
pip install "toon-python[langchain]"
128129
```
130+
129131
Adds 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
140144
pip install "toon-python[langchain]"
145+
```
146+
147+
```python
141148
from 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

0 commit comments

Comments
 (0)