|
liblloyal 1.0.0
Composable primitives for llama.cpp inference
|
Classes | |
| struct | BatchGuard |
| RAII guard for automatic batch cleanup Ensures llama_batch_free is called even if exceptions occur. More... | |
| struct | BuiltinRule |
| struct | is_optional |
| Type trait to detect std::optional<T> More... | |
| struct | is_optional< std::optional< T > > |
| class | SchemaConverter |
Functions | |
| void | add_tokens_to_batch (llama_batch &batch, const llama_token *tokens, int32_t start_idx, int32_t n_eval, int32_t n_past, int32_t capacity, llama_seq_id seq_id=0) |
| Add tokens to batch with position info. | |
| std::string | common_token_to_piece (const struct llama_vocab *vocab, llama_token token, bool special) |
| std::string | get_token_safe (const llama_model *model, llama_token token) |
| const char * | get_chatml_template () |
| std::string | apply_chat_template_helper (const std::string &template_str, const nlohmann::ordered_json &messages, const std::string &bos_token, const std::string &eos_token, bool add_generation_prompt, bool add_bos, bool add_eos) |
| bool | is_reserved_name (const std::string &name) |
| Check if name conflicts with GBNF reserved keywords. | |
| std::regex | INVALID_RULE_CHARS_RE ("[^a-zA-Z0-9-]+") |
| std::regex | GRAMMAR_LITERAL_ESCAPE_RE ("[\r\n\"]") |
| std::regex | GRAMMAR_RANGE_LITERAL_ESCAPE_RE ("[\r\n\"\\]\\-\\\\]") |
| std::string | build_repetition (const std::string &item_rule, int min_items, int max_items, const std::string &separator_rule="") |
| void | _build_min_max_int (int min_value, int max_value, std::stringstream &out, int decimals_left=16, bool top_level=true) |
| std::string | replacePattern (const std::string &input, const std::regex ®ex, const std::function< std::string(const std::smatch &)> &replacement) |
| std::string | format_literal (const std::string &literal) |
| template<class X , class T > | |
| constexpr T | as_value (const X &x, T def) |
| Extract value from either T or std::optional<T> with fallback. | |
Variables | |
| constexpr const char * | SPACE_RULE = "| \" \" | \"\\n\"{1,2} [ \\t]{0,20}" |
| const std::unordered_map< std::string, BuiltinRule > | PRIMITIVE_RULES |
| Built-in grammar rules for JSON primitives. | |
| const std::unordered_map< std::string, BuiltinRule > | STRING_FORMAT_RULES |
| Grammar rules for string format validation. | |
| const std::unordered_map< char, std::string > | GRAMMAR_LITERAL_ESCAPES |
| const std::unordered_set< char > | NON_LITERAL_SET |
| const std::unordered_set< char > | ESCAPED_IN_REGEXPS_BUT_NOT_IN_LITERALS |
|
inline |
Definition at line 216 of file json-schema-to-grammar.hpp.
|
inline |
Add tokens to batch with position info.
Definition at line 59 of file decoder.hpp.
|
inline |
Definition at line 523 of file helpers.hpp.
|
constexpr |
Extract value from either T or std::optional<T> with fallback.
Handles both:
Used by sampler to accept Nitrogen-generated params (which use std::optional)
Definition at line 50 of file sampler.hpp.
|
inline |
Definition at line 183 of file json-schema-to-grammar.hpp.
|
inline |
Definition at line 479 of file helpers.hpp.
|
inline |
Definition at line 431 of file json-schema-to-grammar.hpp.
|
inline |
Definition at line 509 of file helpers.hpp.
|
inline |
Definition at line 498 of file helpers.hpp.
|
inline |
|
inline |
|
inline |
|
inline |
Check if name conflicts with GBNF reserved keywords.
Tests whether a rule name would collide with built-in primitives ("root", "boolean", "number", "string", etc.) or format rules ("date", "time", "uuid", etc.). Used during schema conversion to append "-" suffix to conflicting names.
| name | Rule name to check |
Definition at line 156 of file json-schema-to-grammar.hpp.
|
inline |
Definition at line 411 of file json-schema-to-grammar.hpp.
|
inline |
Definition at line 178 of file json-schema-to-grammar.hpp.
|
inline |
Definition at line 173 of file json-schema-to-grammar.hpp.
|
inline |
Definition at line 176 of file json-schema-to-grammar.hpp.
|
inline |
Built-in grammar rules for JSON primitives.
Defines GBNF rules for basic JSON types: boolean, number, integer, string, array, object, null, uuid, and character escaping. Used as building blocks for schema conversion.
Definition at line 91 of file json-schema-to-grammar.hpp.
|
inlineconstexpr |
Definition at line 77 of file json-schema-to-grammar.hpp.
|
inline |
Grammar rules for string format validation.
Defines GBNF rules for JSON Schema string formats: date, time, date-time, uri, email, uuid. Used when schema specifies "format" field for string validation.
Definition at line 128 of file json-schema-to-grammar.hpp.