common
: utils to split / join / repeat strings (from json converter) (#11342)
* Factor string_join, string_split, string_repeat into common * json: refactor to surface a versatile builder * Update common.cpp
This commit is contained in:
parent
3e3357fd77
commit
a94f3b2727
4 changed files with 90 additions and 64 deletions
|
@ -5,4 +5,12 @@
|
|||
#define JSON_ASSERT GGML_ASSERT
|
||||
#include "json.hpp"
|
||||
|
||||
std::string json_schema_to_grammar(const nlohmann::ordered_json& schema);
|
||||
std::string json_schema_to_grammar(const nlohmann::ordered_json & schema);
|
||||
|
||||
struct llama_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;
|
||||
};
|
||||
|
||||
std::string build_grammar(const std::function<void(const llama_grammar_builder &)> & cb);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue