Skip to content

SafeLLamaGrammarHandle

Namespace: LLama.Native

A safe reference to a llama_grammar

public class SafeLLamaGrammarHandle : SafeLLamaHandleBase, System.IDisposable

Inheritance ObjectCriticalFinalizerObjectSafeHandleSafeLLamaHandleBaseSafeLLamaGrammarHandle
Implements IDisposable

Properties

IsInvalid

public bool IsInvalid { get; }

Property Value

Boolean

IsClosed

public bool IsClosed { get; }

Property Value

Boolean

Methods

ReleaseHandle()

protected bool ReleaseHandle()

Returns

Boolean

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

SafeLLamaGrammarHandle

Exceptions

RuntimeError

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

Returns

SafeLLamaGrammarHandle

Exceptions

RuntimeError