CoolFace
Modelpublic

Codeprocastinator/optimized-tinyllama-covalent

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
0likes119downloads
json-schema-to-grammar.h22 linesDownload Raw Back to common
1#pragma once2 3#include "ggml.h"4// Change JSON_ASSERT from assert() to GGML_ASSERT:5#define JSON_ASSERT GGML_ASSERT6#include "json.hpp"7 8std::string json_schema_to_grammar(const nlohmann::ordered_json & schema,9                                   bool force_gbnf = false);10 11struct common_grammar_builder {12    std::function<std::string(const std::string &, const std::string &)> add_rule;13    std::function<std::string(const std::string &, const nlohmann::ordered_json &)> add_schema;14    std::function<void(nlohmann::ordered_json &)> resolve_refs;15};16 17struct common_grammar_options {18    bool dotall = false;19};20 21std::string build_grammar(const std::function<void(const common_grammar_builder &)> & cb, const common_grammar_options & options = {});22