CoolFace
Modelpublic

Felipe97/llama-cpp-compiled

sourceHugging Faceupdated 5d agoView on Hugging Face
0likes1.1kdownloads
json-schema-to-grammar.h24 linesDownload Raw Back to common
1#pragma once2 3#include "json-schema.h"4#include "json.h"5 6#include <functional>7#include <string>8 9std::string json_schema_to_grammar(const common_json & schema, bool force_gbnf = false);10std::string json_schema_to_grammar(const common_chat_schema_document & schema);11 12struct common_grammar_builder {13    std::function<std::string(const std::string &, const std::string &)>    add_rule;14    std::function<std::string(const std::string &, const common_chat_schema &)> add_schema;15};16 17struct common_grammar_options {18    bool dotall = false;19};20 21std::string gbnf_format_literal(const std::string & literal);22 23std::string build_grammar(const std::function<void(const common_grammar_builder &)> & cb, const common_grammar_options & options = {});24