Skip to content

Class: LlamaJsonSchemaGrammar<T>

Defined in: evaluator/LlamaJsonSchemaGrammar.ts:13

See

Extends

Type Parameters

Type Parameter
T extends GbnfJsonSchema

Constructors

new LlamaJsonSchemaGrammar()

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

Defined in: evaluator/LlamaJsonSchemaGrammar.ts:20

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

Parameters

ParameterType
llamaLlama
schemaReadonly<T>

Returns

LlamaJsonSchemaGrammar<T>

Deprecated

Use llama.createGrammarForJsonSchema(...) instead.

Overrides

LlamaGrammar.constructor

Accessors

grammar

Get Signature

ts
get grammar(): string

Defined in: evaluator/LlamaGrammar.ts:64

Returns

string

Inherited from

LlamaGrammar.grammar


rootRuleName

Get Signature

ts
get rootRuleName(): string

Defined in: evaluator/LlamaGrammar.ts:68

Returns

string

Inherited from

LlamaGrammar.rootRuleName


stopGenerationTriggers

Get Signature

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

Defined in: evaluator/LlamaGrammar.ts:72

Returns

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

Inherited from

LlamaGrammar.stopGenerationTriggers


trimWhitespaceSuffix

Get Signature

ts
get trimWhitespaceSuffix(): boolean

Defined in: evaluator/LlamaGrammar.ts:76

Returns

boolean

Inherited from

LlamaGrammar.trimWhitespaceSuffix


schema

Get Signature

ts
get schema(): Readonly<T>

Defined in: evaluator/LlamaJsonSchemaGrammar.ts:32

Returns

Readonly<T>

Methods

getFor()

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

Defined in: evaluator/LlamaGrammar.ts:88

Parameters

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

Returns

Promise<LlamaGrammar>

Inherited from

LlamaGrammar.getFor


parse()

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

Defined in: evaluator/LlamaJsonSchemaGrammar.ts:36

Parameters

ParameterType
jsonstring

Returns

GbnfJsonSchemaToType<T>