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.

ParseState.cs 794 B

1234567891011121314151617181920212223242526
  1. using LLama.Native;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace LLama.Grammar
  5. {
  6. /// <summary>
  7. /// Source:
  8. /// https://github.com/ggerganov/llama.cpp/blob/6381d4e110bd0ec02843a60bbeb8b6fc37a9ace9/common/grammar-parser.h
  9. ///
  10. /// The commit hash from URL is the actual commit hash that reflects current C# code.
  11. /// </summary>
  12. internal class ParseState
  13. {
  14. public Dictionary<string, uint> SymbolIds { get; } = new Dictionary<string, uint>();
  15. public List<List<LLamaGrammarElement>> Rules { get; } = new List<List<LLamaGrammarElement>>();
  16. public IEnumerable<List<LLamaGrammarElement>> CRules()
  17. {
  18. foreach (var rule in Rules)
  19. {
  20. yield return rule;
  21. }
  22. }
  23. }
  24. }