MCPcopy Index your code
hub / github.com/abetlen/llama-cpp-python / add_grammar

Method add_grammar

llama_cpp/_internals.py:753–757  ·  view source on GitHub ↗
(self, model: LlamaModel, grammar: LlamaGrammar)

Source from the content-addressed store, hash-verified

751 llama_cpp.llama_sampler_chain_add(self.sampler, sampler)
752
753 def add_grammar(self, model: LlamaModel, grammar: LlamaGrammar):
754 sampler = llama_cpp.llama_sampler_init_grammar(
755 model.vocab, grammar._grammar.encode("utf-8"), grammar._root.encode("utf-8")
756 )
757 llama_cpp.llama_sampler_chain_add(self.sampler, sampler)
758
759 def add_grammar_lazy_patterns(
760 self,

Callers 1

_init_samplerMethod · 0.95

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected