Skip to content

Class: LlamaGrammar

Defined in: evaluator/LlamaGrammar.ts:31

See

Using Grammar tutorial

Extended by

Constructors

new LlamaGrammar()

ts
new LlamaGrammar(llama: Llama, options: LlamaGrammarOptions): LlamaGrammar

Defined in: evaluator/LlamaGrammar.ts:50

GBNF files are supported. More info here: github:ggerganov/llama.cpp:grammars/README.md

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

Parameters

ParameterTypeDescription
llamaLlama
optionsLlamaGrammarOptions

Returns

LlamaGrammar

Deprecated

Use llama.createGrammar(...) instead.

Accessors

grammar

Get Signature

ts
get grammar(): string

Defined in: evaluator/LlamaGrammar.ts:64

Returns

string


rootRuleName

Get Signature

ts
get rootRuleName(): string

Defined in: evaluator/LlamaGrammar.ts:68

Returns

string


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)[])[]


trimWhitespaceSuffix

Get Signature

ts
get trimWhitespaceSuffix(): boolean

Defined in: evaluator/LlamaGrammar.ts:76

Returns

boolean

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>