2222
2323from agon .encoding import DEFAULT_ENCODING , count_tokens
2424from agon .errors import AGONError
25- from agon .formats import AGONColumns , AGONFormat , AGONText
25+ from agon .formats import AGONColumns , AGONFormat , AGONStruct , AGONText
2626
27- Format = Literal ["auto" , "json" , "text" , "columns" ]
27+ Format = Literal ["auto" , "json" , "text" , "columns" , "struct" ]
2828
2929
3030@dataclass (frozen = True )
@@ -45,6 +45,7 @@ class AGON:
4545 - "json": Raw JSON (baseline)
4646 - "text": AGONText row-based format
4747 - "columns": AGONColumns columnar format for wide tables
48+ - "struct": AGONStruct template format for repeated object shapes
4849
4950 Core ideas:
5051 - Key elimination: objects become positional rows with inline schema.
@@ -58,11 +59,13 @@ class AGON:
5859 "json" : lambda data : orjson .dumps (data ).decode (),
5960 "text" : AGONText .encode ,
6061 "columns" : AGONColumns .encode ,
62+ "struct" : AGONStruct .encode ,
6163 }
6264
6365 _decoders : ClassVar [dict [str , Callable [[str ], Any ]]] = {
6466 "@AGON text" : AGONText .decode ,
6567 "@AGON columns" : AGONColumns .decode ,
68+ "@AGON struct" : AGONStruct .decode ,
6669 }
6770
6871 @staticmethod
@@ -83,6 +86,7 @@ def encode(
8386 - "json": Raw JSON
8487 - "text": AGONText row-based format
8588 - "columns": AGONColumns columnar format for wide tables
89+ - "struct": AGONStruct template format for repeated shapes
8690 force: If True with format="auto", always use a non-JSON format.
8791 min_savings: Minimum token savings ratio vs JSON to use non-JSON format.
8892 encoding: Tiktoken encoding for token counting (default: o200k_base).
0 commit comments