mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2025-02-06 08:30:33 +01:00
ff227703d6
* initial porting of previous LLG patch * update for new APIs * build: integrate llguidance as an external project * use '%llguidance' as marker to enable llg lark syntax * add some docs * clarify docs * code style fixes * remove llguidance.h from .gitignore * fix tests when llg is enabled * pass vocab not model to llama_sampler_init_llg() * copy test-grammar-integration.cpp to test-llguidance.cpp * clang fmt * fix ref-count bug * build and run test * gbnf -> lark syntax * conditionally include llguidance test based on LLAMA_LLGUIDANCE flag * rename llguidance test file to test-grammar-llguidance.cpp * add gh action for llg test * align tests with LLG grammar syntax and JSON Schema spec * llama_tokenizer() in fact requires valid utf8 * update llg * format file * add $LLGUIDANCE_LOG_LEVEL support * fix whitespace * fix warning * include <cmath> for INFINITY * add final newline * fail llama_sampler_init_llg() at runtime * Link gbnf_to_lark.py script; fix links; refer to llg docs for lexemes * simplify #includes * improve doc string for LLAMA_LLGUIDANCE * typo in merge * bump llguidance to 0.6.12
23 lines
782 B
C++
23 lines
782 B
C++
#pragma once
|
|
|
|
#include "ggml.h"
|
|
// Change JSON_ASSERT from assert() to GGML_ASSERT:
|
|
#define JSON_ASSERT GGML_ASSERT
|
|
#include "json.hpp"
|
|
|
|
std::string json_schema_to_grammar(const nlohmann::ordered_json & schema,
|
|
bool force_gbnf = false);
|
|
|
|
struct common_grammar_builder {
|
|
std::function<std::string(const std::string &, const std::string &)> add_rule;
|
|
std::function<std::string(const std::string &, const nlohmann::ordered_json &)> add_schema;
|
|
std::function<void(nlohmann::ordered_json &)> resolve_refs;
|
|
};
|
|
|
|
struct common_grammar_options {
|
|
bool dotall = false;
|
|
bool compact_spaces = false;
|
|
};
|
|
|
|
std::string build_grammar(const std::function<void(const common_grammar_builder &)> & cb, const common_grammar_options & options = {});
|