Namespace: grammar
llamacpp.grammar
GBNF grammars. You can use them in the grammar
option of the TextGenerator
model.
Functions
fromJsonSchema
▸ fromJsonSchema(schema
): string
Convert JSON Schema to a GBNF grammar.
This is a modified version of https://github.com/ggerganov/llama.cpp/blob/master/examples/server/public/json-schema-to-grammar.mjs
Parameters
Name | Type |
---|---|
schema | unknown |
Returns
string
Defined in
packages/modelfusion/src/model-provider/llamacpp/convertJsonSchemaToGBNF.ts:9
Variables
json
• Const
json: string
GBNF grammar for JSON.
See
https://github.com/ggerganov/llama.cpp/blob/master/grammars/json.gbnf
Defined in
packages/modelfusion/src/model-provider/llamacpp/LlamaCppGrammars.ts:6
jsonArray
• Const
jsonArray: string
GBNF grammar for JSON array outputs. Restricts whitespace at the end of the array.
See
https://github.com/ggerganov/llama.cpp/blob/master/grammars/json_arr.gbnf
Defined in
packages/modelfusion/src/model-provider/llamacpp/LlamaCppGrammars.ts:39
list
• Const
list: string
GBNF grammar for list outputs. List items are separated by newlines and start with -
.
See
https://github.com/ggerganov/llama.cpp/blob/master/grammars/list.gbnf
Defined in
packages/modelfusion/src/model-provider/llamacpp/LlamaCppGrammars.ts:78