Method CreateJsonGrammarFromFields
- Namespace
- LMKit.TextGeneration.Sampling
- Assembly
- LM-Kit.NET.dll
CreateJsonGrammarFromFields(IEnumerable<string>, IEnumerable<Type>)
Creates a new instance of the Grammar class based on a collection of JSON field names and their corresponding types.
public static Grammar CreateJsonGrammarFromFields(IEnumerable<string> fieldNames, IEnumerable<Type> fieldTypes)
Parameters
fieldNames
IEnumerable<string>A collection of strings representing the names of the JSON fields. Each string in this collection should correspond to a field name in the JSON structure that will be included in the Grammar.
fieldTypes
IEnumerable<Type>A collection of JsonBasicType values representing the data types associated with each JSON field name. The order of types in this collection should correspond to the order of field names in
fieldNames
.
Returns
- Grammar
A new instance of the Grammar class constructed from the specified JSON field names and their corresponding types.
Exceptions
- ArgumentException
Thrown if the
fieldNames
collection is null or empty. This exception indicates that the method requires at least one field name to create a valid Grammar instance.