You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

llama.native.safellamagrammarhandle.md 2.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # SafeLLamaGrammarHandle
  2. Namespace: LLama.Native
  3. A safe reference to a `llama_grammar`
  4. ```csharp
  5. public class SafeLLamaGrammarHandle : SafeLLamaHandleBase, System.IDisposable
  6. ```
  7. Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [SafeLLamaGrammarHandle](./llama.native.safellamagrammarhandle.md)<br>
  8. Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
  9. ## Properties
  10. ### **IsInvalid**
  11. ```csharp
  12. public bool IsInvalid { get; }
  13. ```
  14. #### Property Value
  15. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  16. ### **IsClosed**
  17. ```csharp
  18. public bool IsClosed { get; }
  19. ```
  20. #### Property Value
  21. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  22. ## Methods
  23. ### **ReleaseHandle()**
  24. ```csharp
  25. protected bool ReleaseHandle()
  26. ```
  27. #### Returns
  28. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  29. ### **Create(IReadOnlyList&lt;GrammarRule&gt;, UInt64)**
  30. Create a new llama_grammar
  31. ```csharp
  32. public static SafeLLamaGrammarHandle Create(IReadOnlyList<GrammarRule> rules, ulong start_rule_index)
  33. ```
  34. #### Parameters
  35. `rules` [IReadOnlyList&lt;GrammarRule&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1)<br>
  36. A list of list of elements, each inner list makes up one grammar rule
  37. `start_rule_index` [UInt64](https://docs.microsoft.com/en-us/dotnet/api/system.uint64)<br>
  38. The index (in the outer list) of the start rule
  39. #### Returns
  40. [SafeLLamaGrammarHandle](./llama.native.safellamagrammarhandle.md)<br>
  41. #### Exceptions
  42. [RuntimeError](./llama.exceptions.runtimeerror.md)<br>
  43. ### **Create(LLamaGrammarElement**, UInt64, UInt64)**
  44. Create a new llama_grammar
  45. ```csharp
  46. public static SafeLLamaGrammarHandle Create(LLamaGrammarElement** rules, ulong nrules, ulong start_rule_index)
  47. ```
  48. #### Parameters
  49. `rules` [LLamaGrammarElement**](./llama.native.llamagrammarelement**.md)<br>
  50. rules list, each rule is a list of rule elements (terminated by a LLamaGrammarElementType.END element)
  51. `nrules` [UInt64](https://docs.microsoft.com/en-us/dotnet/api/system.uint64)<br>
  52. total number of rules
  53. `start_rule_index` [UInt64](https://docs.microsoft.com/en-us/dotnet/api/system.uint64)<br>
  54. index of the start rule of the grammar
  55. #### Returns
  56. [SafeLLamaGrammarHandle](./llama.native.safellamagrammarhandle.md)<br>
  57. #### Exceptions
  58. [RuntimeError](./llama.exceptions.runtimeerror.md)<br>