A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
transform.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 The A11 Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
20#ifndef A11_SDK_LLM_CONTEXT_TRANSFORM_H_
21#define A11_SDK_LLM_CONTEXT_TRANSFORM_H_
22
23#include <cstddef>
24#include <string>
25#include <string_view>
26
27#include <absl/status/statusor.h>
28
29namespace a11::sdk::llm_context {
30
38absl::StatusOr<std::string> CompactJson(std::string_view text,
39 size_t max_bytes = 8 * 1024 * 1024,
40 size_t max_depth = 128);
41
49absl::StatusOr<std::string> Encode(std::string_view text,
50 std::string_view format,
51 size_t max_bytes = 8 * 1024 * 1024);
52
59absl::StatusOr<std::string> Expand(std::string_view encoded,
60 size_t max_bytes = 8 * 1024 * 1024);
61
63size_t EstimateTokens(std::string_view text);
64
65} // namespace a11::sdk::llm_context
66#endif // A11_SDK_LLM_CONTEXT_TRANSFORM_H_
std::optional< std::string > text
The text, where the value is a string literal or a name bound to one.
Definition discover.cc:596
Definition transform.cc:27
absl::StatusOr< std::string > Expand(std::string_view encoded, size_t max_bytes)
Expand a context encoding, enforcing the expanded byte limit.
Definition transform.cc:169
absl::StatusOr< std::string > CompactJson(std::string_view text, size_t max_bytes, size_t max_depth)
Return JSON with representation whitespace removed, preserving all tokens.
Definition transform.cc:44
size_t EstimateTokens(std::string_view text)
Estimate tokens from UTF-8 bytes; this is not a provider tokenizer.
Definition transform.cc:240
absl::StatusOr< std::string > Encode(std::string_view text, std::string_view format, size_t max_bytes)
Encode repeated lines or JSON key lexemes in a reversible JSON envelope.
Definition transform.cc:90
Output format
Definition main.cc:65