raif-format 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- raif/__init__.py +43 -0
- raif/decode.py +1377 -0
- raif/encode.py +612 -0
- raif/fix.py +52 -0
- raif/py.typed +0 -0
- raif/validate.py +37 -0
- raif_format-0.5.0.dist-info/METADATA +92 -0
- raif_format-0.5.0.dist-info/RECORD +10 -0
- raif_format-0.5.0.dist-info/WHEEL +4 -0
- raif_format-0.5.0.dist-info/licenses/LICENSE +202 -0
raif/__init__.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""RAIF — a token-efficient, repair-tolerant interchange format for LLM I/O.
|
|
2
|
+
|
|
3
|
+
Pure-Python implementation of the full RAIF surface: `encode`, `decode`,
|
|
4
|
+
`decode_lenient`, `fix`, and `validate`, plus schema parsing. Output is
|
|
5
|
+
byte-identical to the canonical TypeScript reference and pinned by a shared
|
|
6
|
+
conformance corpus. Stdlib only; no runtime dependencies.
|
|
7
|
+
|
|
8
|
+
>>> from raif import encode, decode
|
|
9
|
+
>>> encode({"to": "a@b.com", "subject": "hi"})
|
|
10
|
+
'subject=hi\\nto=a@b.com'
|
|
11
|
+
>>> decode("a=1\\nb=hi")
|
|
12
|
+
{'ok': True, 'value': {'a': 1, 'b': 'hi'}, 'repairs': []}
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from .decode import (
|
|
18
|
+
RaifError,
|
|
19
|
+
RaifSchema,
|
|
20
|
+
SchemaNode,
|
|
21
|
+
decode,
|
|
22
|
+
decode_lenient,
|
|
23
|
+
parse_schema,
|
|
24
|
+
)
|
|
25
|
+
from .encode import EncodeOptions, EncodeProfile, encode
|
|
26
|
+
from .fix import fix
|
|
27
|
+
from .validate import validate
|
|
28
|
+
|
|
29
|
+
__all__ = [
|
|
30
|
+
"encode",
|
|
31
|
+
"decode",
|
|
32
|
+
"decode_lenient",
|
|
33
|
+
"fix",
|
|
34
|
+
"validate",
|
|
35
|
+
"parse_schema",
|
|
36
|
+
"RaifSchema",
|
|
37
|
+
"SchemaNode",
|
|
38
|
+
"RaifError",
|
|
39
|
+
"EncodeOptions",
|
|
40
|
+
"EncodeProfile",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
__version__ = "0.5.0"
|