Metadata-Version: 2.4
Name: token_tunnel
Version: 0.0.1
Summary: Token compression library
Project-URL: Homepage, https://github.com/Ix76y/token-tunnel
Project-URL: Issues, https://github.com/Ix76y/token-tunnel/issues
Author-email: Ix76y <troubledwaffle@protonmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Requires-Dist: langchain-core>=1.3.0
Description-Content-Type: text/markdown

# Token Tunnel

Python library to compress JSON payloads before they hit the LLM. 

> Cut your multi-agent API bills with two lines of code!

## Quickstart

```bash
pip install token-tunnel
```

### Example

```python
from langchain.agents import create_agent
from token_tunnel import TokenCompressionMiddleware

agent = create_agent(
    model="gpt-4o",
    tools=tools,
    middleware=[TokenCompressionMiddleware()]
)
```

## Functionality

The compressor looks for any JSON in a prompt and formats it to another format before passing it on to the model. (Currently format is to YAML, which is not the best but slightly better than JSON, other formats will be added soon). You can also directly call the compressor in case you have your own flow and are not working with `langchain`. 


## Running Examples

Make sure to have `token-tunnel` installed with pip before running the examples.

```bash
cd token-tunnel
pip install -e .  
```