SafeLLamaGrammarHandle
Namespace: LLama.Native
A safe reference to a llama_grammar
public class SafeLLamaGrammarHandle : SafeLLamaHandleBase, System.IDisposable
Inheritance Object → CriticalFinalizerObject → SafeHandle → SafeLLamaHandleBase → SafeLLamaGrammarHandle
Implements IDisposable
Properties
IsInvalid
public bool IsInvalid { get; }
Property Value
IsClosed
public bool IsClosed { get; }
Property Value
Methods
ReleaseHandle()
protected bool ReleaseHandle()
Returns
Create(IReadOnlyList<GrammarRule>, UInt64)
Create a new llama_grammar
public static SafeLLamaGrammarHandle Create(IReadOnlyList<GrammarRule> rules, ulong start_rule_index)
Parameters
rules
IReadOnlyList<GrammarRule>
A list of list of elements, each inner list makes up one grammar rule
start_rule_index
UInt64
The index (in the outer list) of the start rule
Returns
Exceptions
Create(LLamaGrammarElement, UInt64, UInt64)**
Create a new llama_grammar
public static SafeLLamaGrammarHandle Create(LLamaGrammarElement** rules, ulong nrules, ulong start_rule_index)
Parameters
rules
LLamaGrammarElement**
rules list, each rule is a list of rule elements (terminated by a LLamaGrammarElementType.END element)
nrules
UInt64
total number of rules
start_rule_index
UInt64
index of the start rule of the grammar