Skip to content

Class: LlamaJsonSchemaGrammar<T>

Extends

Type Parameters

Type Parameter
T extends Readonly<GbnfJsonSchema>

Constructors

new LlamaJsonSchemaGrammar()

ts
new LlamaJsonSchemaGrammar<T>(llama: Llama, schema: T): LlamaJsonSchemaGrammar<T>

Prefer to create a new instance of this class by using llama.createGrammarForJsonSchema(...).

Parameters

ParameterType
llamaLlama
schemaT

Returns

LlamaJsonSchemaGrammar<T>

Overrides

LlamaGrammar.constructor

Defined in

evaluator/LlamaJsonSchemaGrammar.ts:14

Accessors

grammar

ts
get grammar(): string

Returns

string

Inherited from

LlamaGrammar.grammar

Defined in

evaluator/LlamaGrammar.ts:58


rootRuleName

ts
get rootRuleName(): string

Returns

string

Inherited from

LlamaGrammar.rootRuleName

Defined in

evaluator/LlamaGrammar.ts:62


stopGenerationTriggers

ts
get stopGenerationTriggers(): readonly (string | LlamaText | readonly (string | Token)[])[]

Returns

readonly (string | LlamaText | readonly (string | Token)[])[]

Inherited from

LlamaGrammar.stopGenerationTriggers

Defined in

evaluator/LlamaGrammar.ts:66


trimWhitespaceSuffix

ts
get trimWhitespaceSuffix(): boolean

Returns

boolean

Inherited from

LlamaGrammar.trimWhitespaceSuffix

Defined in

evaluator/LlamaGrammar.ts:70

Methods

getFor()

ts
static getFor(llama: Llama, type: 
  | "json"
  | "json_arr"
  | "list"
  | "c"
  | "arithmetic"
  | "japanese"
  | "chess"): Promise<LlamaGrammar>

Parameters

ParameterType
llamaLlama
type| "json" | "json_arr" | "list" | "c" | "arithmetic" | "japanese" | "chess"

Returns

Promise<LlamaGrammar>

Inherited from

LlamaGrammar.getFor

Defined in

evaluator/LlamaGrammar.ts:74


parse()

ts
parse(json: string): GbnfJsonSchemaToType<T>

Parameters

ParameterType
jsonstring

Returns

GbnfJsonSchemaToType<T>

Defined in

evaluator/LlamaJsonSchemaGrammar.ts:26