mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-11-04 09:32:00 +00:00 
			
		
		
		
	* sampler: turn lazy grammar trigger words to regexes * add scripts/tool_bench.sh & .py * constrain llama json output regardless of function name if matches at beginning * update relaxed newline space rule in grammar tests * support add_generation_prompt query parameter (useful for /apply_template) * Update src/llama-grammar.cpp Co-authored-by: Georgi Gerganov <ggerganov@gmail.com> --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
		
			
				
	
	
		
			22 lines
		
	
	
		
			749 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			749 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;
 | 
						|
};
 | 
						|
 | 
						|
std::string build_grammar(const std::function<void(const common_grammar_builder &)> & cb, const common_grammar_options & options = {});
 |