A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
a11::sdk::llm_context Namespace Reference

Functions

absl::StatusOr< std::string > CompactJson (std::string_view text, size_t max_bytes=8 *1024 *1024, size_t max_depth=128)
 Return JSON with representation whitespace removed, preserving all tokens.
 
absl::StatusOr< std::string > Encode (std::string_view text, std::string_view format, size_t max_bytes=8 *1024 *1024)
 Encode repeated lines or JSON key lexemes in a reversible JSON envelope.
 
absl::StatusOr< std::string > Expand (std::string_view encoded, size_t max_bytes=8 *1024 *1024)
 Expand a context encoding, enforcing the expanded byte limit.
 
size_t EstimateTokens (std::string_view text)
 Estimate tokens from UTF-8 bytes; this is not a provider tokenizer.
 

Function Documentation

◆ CompactJson()

absl::StatusOr< std::string > a11::sdk::llm_context::CompactJson ( std::string_view  text,
size_t  max_bytes = 8 *1024 *1024,
size_t  max_depth = 128 
)

Return JSON with representation whitespace removed, preserving all tokens.

Parameters
textComplete UTF-8 JSON, including duplicate keys or large numbers.
max_bytesMaximum admitted input size.
max_depthMaximum nested object/array depth.
Returns
Compacted text; InvalidArgument for malformed JSON/UTF-8 and ResourceExhausted for size/depth limits.

◆ Encode()

absl::StatusOr< std::string > a11::sdk::llm_context::Encode ( std::string_view  text,
std::string_view  format,
size_t  max_bytes = 8 *1024 *1024 
)

Encode repeated lines or JSON key lexemes in a reversible JSON envelope.

Parameters
textOriginal UTF-8 content; JSON-key encoding requires valid JSON.
formata11.lines/v1 or a11.json-keys/v1.
max_bytesMaximum admitted input size. The output may be larger; callers selecting candidates count the full envelope overhead.
Returns
A byte-reversible encoding or a validation/limit status.

◆ EstimateTokens()

size_t a11::sdk::llm_context::EstimateTokens ( std::string_view  text)

Estimate tokens from UTF-8 bytes; this is not a provider tokenizer.

◆ Expand()

absl::StatusOr< std::string > a11::sdk::llm_context::Expand ( std::string_view  encoded,
size_t  max_bytes = 8 *1024 *1024 
)

Expand a context encoding, enforcing the expanded byte limit.

Parameters
encodedVersioned encoding envelope produced by Encode.
max_bytesMaximum encoded input and expanded output size.
Returns
Exact original bytes or a validation/limit status. Expansion checks run-length multiplication before allocating the output.