redline
Targeted, exact document edits for AI agents - no full-document rewrites.
Install
pip install py-redline
pip install "py-redline[pydantic-ai]" # optional, for the pydantic-ai wrapper
Usage
from redline import Document, apply_edit, read
doc = Document("# Todo\n- buy milk\n")
apply_edit(doc, "buy milk", "buy oat milk")
print(read(doc))
Document holds the text. apply_edit finds old_str and swaps in new_str -
it must match exactly once, unless allow_multiple=True. Other tools: read_lines,
append, undo.
With pydantic-ai
from pydantic_ai import Agent
from redline import Document
from redline.pydantic_ai import TOOLS
doc = Document(your_text)
agent = Agent("your-model", deps_type=Document, tools=TOOLS)
agent.run_sync("fix the typo in the intro", deps=doc)
print(doc.text)
TOOLS includes everything. For a session that should only ever read, use
READ_TOOLS instead - WRITE_TOOLS holds the tools that can change the
document.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_redline-0.2.0.tar.gz.
File metadata
- Download URL: py_redline-0.2.0.tar.gz
- Upload date:
- Size: 92.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e8f9a16d1fdf598669472f02ec6c3171268bdbdb96b251e4373d7414db67518
|
|
| MD5 |
0581a3e37d5f80c8cb3b229598c64b00
|
|
| BLAKE2b-256 |
f29a15069e197a9cd88e5e1bd9f8faf224ab6db500e0e25ce3739f32d57d6274
|
File details
Details for the file py_redline-0.2.0-py3-none-any.whl.
File metadata
- Download URL: py_redline-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e164f167190e60ce236db21fe9df432f2cbaaff901ddf07843e657bbdea93a4
|
|
| MD5 |
eff734f1deea64f4594f16449bd12947
|
|
| BLAKE2b-256 |
fa3275081144fe2aef8113e303c9af6061abe719c20a0e761b656777122e840f
|