mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-29 08:41:22 +00:00 
			
		
		
		
	 a94f3b2727
			
		
	
	a94f3b2727
	
	
	
		
			
			* Factor string_join, string_split, string_repeat into common * json: refactor to surface a versatile builder * Update common.cpp
		
			
				
	
	
		
			17 lines
		
	
	
		
			581 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			581 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);
 | |
| 
 | |
| 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);
 |