First upload version 0.0.1
This commit is contained in:
19
node_modules/node-llama-cpp/dist/utils/gbnfJson/GbnfGrammarGenerator.d.ts
generated
vendored
Normal file
19
node_modules/node-llama-cpp/dist/utils/gbnfJson/GbnfGrammarGenerator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { MultiKeyMap } from "lifecycle-utils";
|
||||
import { GbnfJsonSchema } from "./types.js";
|
||||
export declare class GbnfGrammarGenerator {
|
||||
rules: Map<string, string>;
|
||||
ruleContentToRuleName: Map<string, string>;
|
||||
literalValueRuleNames: Map<string | number, string>;
|
||||
defRuleNames: MultiKeyMap<[string, GbnfJsonSchema], string | null>;
|
||||
defScopeDefs: MultiKeyMap<[string, GbnfJsonSchema], Record<string, GbnfJsonSchema>>;
|
||||
usedRootRuleName: boolean;
|
||||
private ruleId;
|
||||
private valueRuleId;
|
||||
private defRuleId;
|
||||
generateRuleName(): string;
|
||||
generateRuleNameForLiteralValue(value: string | number): string;
|
||||
generateRuleNameForDef(defName: string, def: GbnfJsonSchema): string;
|
||||
registerDefs(scopeDefs: Record<string, GbnfJsonSchema>): void;
|
||||
generateGbnfFile(rootGrammar: string): string;
|
||||
getProposedLiteralValueRuleNameLength(): number;
|
||||
}
|
||||
60
node_modules/node-llama-cpp/dist/utils/gbnfJson/GbnfGrammarGenerator.js
generated
vendored
Normal file
60
node_modules/node-llama-cpp/dist/utils/gbnfJson/GbnfGrammarGenerator.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import { MultiKeyMap } from "lifecycle-utils";
|
||||
export class GbnfGrammarGenerator {
|
||||
rules = new Map();
|
||||
ruleContentToRuleName = new Map();
|
||||
literalValueRuleNames = new Map();
|
||||
defRuleNames = new MultiKeyMap();
|
||||
defScopeDefs = new MultiKeyMap();
|
||||
usedRootRuleName = false;
|
||||
ruleId = 0;
|
||||
valueRuleId = 0;
|
||||
defRuleId = 0;
|
||||
generateRuleName() {
|
||||
const ruleId = this.ruleId;
|
||||
this.ruleId++;
|
||||
return `rule${ruleId}`;
|
||||
}
|
||||
generateRuleNameForLiteralValue(value) {
|
||||
const existingRuleName = this.literalValueRuleNames.get(value);
|
||||
if (existingRuleName != null)
|
||||
return existingRuleName;
|
||||
const ruleName = `val${this.valueRuleId}`;
|
||||
this.valueRuleId++;
|
||||
this.literalValueRuleNames.set(value, ruleName);
|
||||
return ruleName;
|
||||
}
|
||||
generateRuleNameForDef(defName, def) {
|
||||
const existingRuleName = this.defRuleNames.get([defName, def]);
|
||||
if (existingRuleName != null)
|
||||
return existingRuleName;
|
||||
const ruleName = `def${this.defRuleId}`;
|
||||
this.defRuleId++;
|
||||
this.defRuleNames.set([defName, def], ruleName);
|
||||
return ruleName;
|
||||
}
|
||||
registerDefs(scopeDefs) {
|
||||
for (const [defName, def] of Object.entries(scopeDefs))
|
||||
this.defScopeDefs.set([defName, def], scopeDefs);
|
||||
}
|
||||
generateGbnfFile(rootGrammar) {
|
||||
const rules = [{
|
||||
name: "root",
|
||||
grammar: rootGrammar
|
||||
}];
|
||||
for (const [ruleName, grammar] of this.rules.entries()) {
|
||||
if (grammar == null)
|
||||
continue;
|
||||
rules.push({
|
||||
name: ruleName,
|
||||
grammar
|
||||
});
|
||||
}
|
||||
const ruleStrings = rules.map((rule) => rule.name + " ::= " + rule.grammar);
|
||||
const gbnf = ruleStrings.join("\n");
|
||||
return gbnf;
|
||||
}
|
||||
getProposedLiteralValueRuleNameLength() {
|
||||
return `val${this.valueRuleId}`.length;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfGrammarGenerator.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/GbnfGrammarGenerator.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/GbnfGrammarGenerator.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfGrammarGenerator.js","sourceRoot":"","sources":["../../../src/utils/gbnfJson/GbnfGrammarGenerator.ts"],"names":[],"mappings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ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { GbnfGrammarGenerator } from "./GbnfGrammarGenerator.js";
|
||||
export declare abstract class GbnfTerminal {
|
||||
private _ruleName;
|
||||
/** To be used only by `getRuleName` */
|
||||
protected generateRuleName(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
protected getRuleName(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
abstract getGrammar(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
protected getGrammarFromResolve(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
private _getRootRuleName;
|
||||
resolve(grammarGenerator: GbnfGrammarGenerator, resolveAsRootGrammar?: boolean): string;
|
||||
}
|
||||
54
node_modules/node-llama-cpp/dist/utils/gbnfJson/GbnfTerminal.js
generated
vendored
Normal file
54
node_modules/node-llama-cpp/dist/utils/gbnfJson/GbnfTerminal.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
export class GbnfTerminal {
|
||||
_ruleName = null;
|
||||
/** To be used only by `getRuleName` */
|
||||
generateRuleName(grammarGenerator) {
|
||||
return grammarGenerator.generateRuleName();
|
||||
}
|
||||
getRuleName(grammarGenerator) {
|
||||
if (this._ruleName != null)
|
||||
return this._ruleName;
|
||||
const ruleName = this.generateRuleName(grammarGenerator);
|
||||
this._ruleName = ruleName;
|
||||
return ruleName;
|
||||
}
|
||||
getGrammarFromResolve(grammarGenerator) {
|
||||
return this.getGrammar(grammarGenerator);
|
||||
}
|
||||
_getRootRuleName(grammarGenerator) {
|
||||
if (this._ruleName != null)
|
||||
return this._ruleName;
|
||||
const ruleName = grammarGenerator.usedRootRuleName
|
||||
? this.getRuleName(grammarGenerator)
|
||||
: "root";
|
||||
this._ruleName = ruleName;
|
||||
if (ruleName === "root")
|
||||
grammarGenerator.usedRootRuleName = true;
|
||||
return ruleName;
|
||||
}
|
||||
resolve(grammarGenerator, resolveAsRootGrammar = false) {
|
||||
if (this._ruleName != null)
|
||||
return this._ruleName;
|
||||
const grammar = this.getGrammarFromResolve(grammarGenerator);
|
||||
const existingRuleName = grammarGenerator.ruleContentToRuleName.get(grammar);
|
||||
if (existingRuleName != null) {
|
||||
this._ruleName = existingRuleName;
|
||||
return existingRuleName;
|
||||
}
|
||||
const ruleName = resolveAsRootGrammar
|
||||
? this._getRootRuleName(grammarGenerator)
|
||||
: this.getRuleName(grammarGenerator);
|
||||
if (resolveAsRootGrammar)
|
||||
return grammar;
|
||||
if (grammar === ruleName) {
|
||||
this._ruleName = ruleName;
|
||||
return ruleName;
|
||||
}
|
||||
if (!grammarGenerator.rules.has(ruleName)) {
|
||||
grammarGenerator.rules.set(ruleName, grammar);
|
||||
grammarGenerator.ruleContentToRuleName.set(grammar, ruleName);
|
||||
}
|
||||
this._ruleName = ruleName;
|
||||
return ruleName;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfTerminal.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/GbnfTerminal.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/GbnfTerminal.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfTerminal.js","sourceRoot":"","sources":["../../../src/utils/gbnfJson/GbnfTerminal.ts"],"names":[],"mappings":"AAGA,MAAM,OAAgB,YAAY;IACtB,SAAS,GAAkB,IAAI,CAAC;IAExC,uCAAuC;IAC7B,gBAAgB,CAAC,gBAAsC;QAC7D,OAAO,gBAAgB,CAAC,gBAAgB,EAAE,CAAC;IAC/C,CAAC;IAES,WAAW,CAAC,gBAAsC;QACxD,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI;YACtB,OAAO,IAAI,CAAC,SAAS,CAAC;QAE1B,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;QACzD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAE1B,OAAO,QAAQ,CAAC;IACpB,CAAC;IAIS,qBAAqB,CAAC,gB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,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC9C,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAClE,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ"}
|
||||
5
node_modules/node-llama-cpp/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.d.ts
generated
vendored
Normal file
5
node_modules/node-llama-cpp/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { GbnfJsonSchema } from "./types.js";
|
||||
export declare function getGbnfGrammarForGbnfJsonSchema(schema: Readonly<GbnfJsonSchema>, { allowNewLines, scopePadSpaces }?: {
|
||||
allowNewLines?: boolean;
|
||||
scopePadSpaces?: number;
|
||||
}): string;
|
||||
11
node_modules/node-llama-cpp/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.js
generated
vendored
Normal file
11
node_modules/node-llama-cpp/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { getGbnfJsonTerminalForGbnfJsonSchema } from "./utils/getGbnfJsonTerminalForGbnfJsonSchema.js";
|
||||
import { GbnfGrammarGenerator } from "./GbnfGrammarGenerator.js";
|
||||
import { GbnfJsonScopeState } from "./utils/GbnfJsonScopeState.js";
|
||||
export function getGbnfGrammarForGbnfJsonSchema(schema, { allowNewLines = true, scopePadSpaces = 4 } = {}) {
|
||||
const grammarGenerator = new GbnfGrammarGenerator();
|
||||
const scopeState = new GbnfJsonScopeState({ allowNewLines, scopePadSpaces });
|
||||
const rootTerminal = getGbnfJsonTerminalForGbnfJsonSchema(schema, grammarGenerator, scopeState);
|
||||
const rootGrammar = rootTerminal.resolve(grammarGenerator, true);
|
||||
return grammarGenerator.generateGbnfFile(rootGrammar + ` "${"\\n".repeat(4)}"` + " [\\n]*");
|
||||
}
|
||||
//# sourceMappingURL=getGbnfGrammarForGbnfJsonSchema.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"getGbnfGrammarForGbnfJsonSchema.js","sourceRoot":"","sources":["../../../src/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,oCAAoC,EAAC,MAAM,iDAAiD,CAAC;AACrG,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAC;AAGjE,MAAM,UAAU,+BAA+B,CAAC,MAAgC,EAAE,EAC9E,aAAa,GAAG,IAAI,EACpB,cAAc,GAAG,CAAC,KAIlB,EAAE;IACF,MAAM,gBAAgB,GAAG,IAAI,oBAAoB,EAAE,CAAC;IACpD,MAAM,UAAU,GAAG,IAAI,kBAAkB,CAAC,EAAC,aAAa,EAAE,cAAc,EAAC,CAAC,CAAC;IAC3E,MAAM,YAAY,GAAG,oCAAoC,CAAC,MAAM,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAC;IAChG,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAEjE,OAAO,gBAAgB,CAAC,gBAAgB,CAAC,WAAW,GAAG,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC;AAChG,CAAC"}
|
||||
9
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfAnyJson.d.ts
generated
vendored
Normal file
9
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfAnyJson.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfGrammarGenerator } from "../GbnfGrammarGenerator.js";
|
||||
import { GbnfJsonScopeState } from "../utils/GbnfJsonScopeState.js";
|
||||
export declare class GbnfAnyJson extends GbnfTerminal {
|
||||
readonly scopeState: GbnfJsonScopeState;
|
||||
constructor(scopeState?: GbnfJsonScopeState);
|
||||
getGrammar(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
protected getRuleName(): string;
|
||||
}
|
||||
53
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfAnyJson.js
generated
vendored
Normal file
53
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfAnyJson.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfJsonScopeState } from "../utils/GbnfJsonScopeState.js";
|
||||
import { GbnfString } from "./GbnfString.js";
|
||||
import { GbnfOr } from "./GbnfOr.js";
|
||||
import { GbnfNumber } from "./GbnfNumber.js";
|
||||
import { GbnfBoolean } from "./GbnfBoolean.js";
|
||||
import { GbnfNull } from "./GbnfNull.js";
|
||||
import { GbnfArray } from "./GbnfArray.js";
|
||||
import { reservedRuleNames } from "./gbnfConsts.js";
|
||||
import { GbnfObjectMap } from "./GbnfObjectMap.js";
|
||||
export class GbnfAnyJson extends GbnfTerminal {
|
||||
scopeState;
|
||||
constructor(scopeState = new GbnfJsonScopeState()) {
|
||||
super();
|
||||
this.scopeState = scopeState;
|
||||
}
|
||||
getGrammar(grammarGenerator) {
|
||||
const subAnyJsonScopeItem = this.scopeState.settings.allowNewLines
|
||||
? new GbnfAnyJson(new GbnfJsonScopeState({
|
||||
allowNewLines: false,
|
||||
scopePadSpaces: this.scopeState.settings.scopePadSpaces
|
||||
}, this.scopeState.currentNestingScope))
|
||||
: new GbnfSubAnyJson(this.scopeState);
|
||||
return new GbnfOr([
|
||||
new GbnfString(),
|
||||
new GbnfNumber({ allowFractional: true }),
|
||||
new GbnfBoolean(),
|
||||
new GbnfNull(),
|
||||
new GbnfArray({
|
||||
items: subAnyJsonScopeItem,
|
||||
scopeState: this.scopeState
|
||||
}),
|
||||
new GbnfObjectMap({
|
||||
fields: [],
|
||||
additionalProperties: subAnyJsonScopeItem,
|
||||
scopeState: this.scopeState
|
||||
})
|
||||
]).getGrammar(grammarGenerator);
|
||||
}
|
||||
getRuleName() {
|
||||
return reservedRuleNames.anyJson({
|
||||
allowNewLines: this.scopeState.settings.allowNewLines,
|
||||
scopeSpaces: this.scopeState.settings.scopePadSpaces,
|
||||
nestingScope: this.scopeState.currentNestingScope
|
||||
});
|
||||
}
|
||||
}
|
||||
class GbnfSubAnyJson extends GbnfAnyJson {
|
||||
getGrammar() {
|
||||
return this.getRuleName();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfAnyJson.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfAnyJson.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfAnyJson.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfAnyJson.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfAnyJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EA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C;IAEkB,WAAW;QAC1B,OAAO,iBAAiB,CAAC,OAAO,CAAC;YAC7B,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,aAAa;YACrD,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc;YACpD,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,mBAAmB;SACpD,CAAC,CAAC;IACP,CAAC;CACJ;AAED,MAAM,cAAe,SAAQ,WAAW;IACpB,UAAU;QACtB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC9B,CAAC;CACJ"}
|
||||
18
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfArray.d.ts
generated
vendored
Normal file
18
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfArray.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfGrammarGenerator } from "../GbnfGrammarGenerator.js";
|
||||
import { GbnfJsonScopeState } from "../utils/GbnfJsonScopeState.js";
|
||||
export declare class GbnfArray extends GbnfTerminal {
|
||||
readonly items?: GbnfTerminal;
|
||||
readonly prefixItems?: GbnfTerminal[];
|
||||
readonly minItems: number;
|
||||
readonly maxItems?: number;
|
||||
readonly scopeState: GbnfJsonScopeState;
|
||||
constructor({ items, prefixItems, minItems, maxItems, scopeState }: {
|
||||
items?: GbnfTerminal;
|
||||
prefixItems?: GbnfTerminal[];
|
||||
minItems?: number;
|
||||
maxItems?: number;
|
||||
scopeState: GbnfJsonScopeState;
|
||||
});
|
||||
getGrammar(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
}
|
||||
83
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfArray.js
generated
vendored
Normal file
83
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfArray.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfJsonScopeState } from "../utils/GbnfJsonScopeState.js";
|
||||
import { GbnfWhitespace } from "./GbnfWhitespace.js";
|
||||
import { GbnfGrammar } from "./GbnfGrammar.js";
|
||||
import { GbnfRepetition } from "./GbnfRepetition.js";
|
||||
import { GbnfCommaWhitespace } from "./GbnfCommaWhitespace.js";
|
||||
import { GbnfAnyJson } from "./GbnfAnyJson.js";
|
||||
export class GbnfArray extends GbnfTerminal {
|
||||
items;
|
||||
prefixItems;
|
||||
minItems;
|
||||
maxItems;
|
||||
scopeState;
|
||||
constructor({ items, prefixItems, minItems = 0, maxItems, scopeState = new GbnfJsonScopeState() }) {
|
||||
super();
|
||||
this.items = items;
|
||||
this.prefixItems = prefixItems;
|
||||
this.minItems = Math.floor(minItems);
|
||||
this.maxItems = maxItems == null ? undefined : Math.floor(maxItems);
|
||||
this.scopeState = scopeState;
|
||||
if (this.prefixItems != null && this.minItems < this.prefixItems.length)
|
||||
this.minItems = this.prefixItems.length;
|
||||
else if (this.minItems < 0)
|
||||
this.minItems = 0;
|
||||
if (this.maxItems != null && this.maxItems < this.minItems)
|
||||
this.maxItems = this.minItems;
|
||||
else if (this.maxItems != null && this.maxItems < 0)
|
||||
this.maxItems = 0;
|
||||
}
|
||||
getGrammar(grammarGenerator) {
|
||||
const getWhitespaceRule = (newScope, newLine) => (newScope
|
||||
? new GbnfWhitespace(this.scopeState.getForNewScope(), { newLine })
|
||||
: new GbnfWhitespace(this.scopeState, { newLine }));
|
||||
const getWhitespaceRuleName = (newScope, newLine) => (getWhitespaceRule(newScope, newLine).resolve(grammarGenerator));
|
||||
const getCommaWhitespaceRule = (newScope, newLine) => (newScope
|
||||
? new GbnfCommaWhitespace(this.scopeState.getForNewScope(), { newLine })
|
||||
: new GbnfCommaWhitespace(this.scopeState, { newLine }));
|
||||
const getCommaWhitespaceRuleName = (newScope, newLine) => (getCommaWhitespaceRule(newScope, newLine).resolve(grammarGenerator));
|
||||
const arrayItemsGrammar = [];
|
||||
if (this.prefixItems != null && this.prefixItems.length > 0) {
|
||||
for (const item of this.prefixItems) {
|
||||
if (arrayItemsGrammar.length > 0)
|
||||
arrayItemsGrammar.push(getCommaWhitespaceRuleName(true, "before"));
|
||||
arrayItemsGrammar.push(item.resolve(grammarGenerator));
|
||||
}
|
||||
if (this.minItems > this.prefixItems.length || this.maxItems == null || this.maxItems > this.prefixItems.length) {
|
||||
const restMinRepetitions = this.minItems - this.prefixItems.length;
|
||||
const restMaxRepetitions = this.maxItems == null
|
||||
? undefined
|
||||
: this.maxItems - this.prefixItems.length;
|
||||
if (arrayItemsGrammar.length > 0)
|
||||
arrayItemsGrammar.push(new GbnfRepetition({
|
||||
value: new GbnfGrammar([
|
||||
getCommaWhitespaceRuleName(true, "before"),
|
||||
(this.items ?? new GbnfAnyJson()).resolve(grammarGenerator)
|
||||
], true),
|
||||
minRepetitions: restMinRepetitions,
|
||||
maxRepetitions: restMaxRepetitions
|
||||
}).getGrammar(grammarGenerator));
|
||||
else
|
||||
arrayItemsGrammar.push(new GbnfRepetition({
|
||||
value: this.items ?? new GbnfAnyJson(),
|
||||
separator: getCommaWhitespaceRule(true, "before"),
|
||||
minRepetitions: restMinRepetitions,
|
||||
maxRepetitions: restMaxRepetitions
|
||||
}).getGrammar(grammarGenerator));
|
||||
}
|
||||
}
|
||||
else
|
||||
arrayItemsGrammar.push(new GbnfRepetition({
|
||||
value: this.items ?? new GbnfAnyJson(),
|
||||
separator: getCommaWhitespaceRule(true, "before"),
|
||||
minRepetitions: this.minItems,
|
||||
maxRepetitions: this.maxItems
|
||||
}).getGrammar(grammarGenerator));
|
||||
return new GbnfGrammar([
|
||||
'"["', getWhitespaceRuleName(true, "before"),
|
||||
new GbnfGrammar(arrayItemsGrammar).getGrammar(),
|
||||
getWhitespaceRuleName(false, "before"), '"]"'
|
||||
]).getGrammar();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfArray.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfArray.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfArray.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfArray.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfArray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAG7C,MAAM,OAAO,SAAU,SAAQ,YAAY;IACvB,KAAK,CAAgB;IACrB,WAAW,CAAkB;IAC7B,QAAQ,CAAS;IACjB,QAAQ,CAAU;IAClB,UAAU,CAAqB;IAE/C,YAAmB,EACf,KAAK,EAAE,WAAW,EAAE,QAAQ,GAAG,CAAC,EAAE,QAAQ,EAC1C,UAAU,GAAG,IAAI,kBAAkB,EAAE,EAIxC;QACG,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACpE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,IAAI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Boolean.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
export declare class GbnfBoolean extends GbnfTerminal {
|
||||
getGrammar(): string;
|
||||
protected getGrammarFromResolve(): string;
|
||||
private _getGrammar;
|
||||
protected getRuleName(): string;
|
||||
}
|
||||
22
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfBoolean.js
generated
vendored
Normal file
22
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfBoolean.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { reservedRuleNames } from "./gbnfConsts.js";
|
||||
export class GbnfBoolean extends GbnfTerminal {
|
||||
getGrammar() {
|
||||
return this._getGrammar();
|
||||
}
|
||||
getGrammarFromResolve() {
|
||||
return this._getGrammar(false);
|
||||
}
|
||||
_getGrammar(wrap = true) {
|
||||
const values = ['"true"', '"false"'];
|
||||
if (wrap)
|
||||
return [
|
||||
"(", values.join(" | "), ")"
|
||||
].join(" ");
|
||||
return values.join(" | ");
|
||||
}
|
||||
getRuleName() {
|
||||
return reservedRuleNames.boolean;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfBoolean.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfBoolean.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfBoolean.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfBoolean.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfBoolean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAGlD,MAAM,OAAO,WAAY,SAAQ,YAAY;IAClC,UAAU;QACb,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC9B,CAAC;IAEkB,qBAAqB;QACpC,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAEO,WAAW,CAAC,OAAgB,IAAI;QACpC,MAAM,MAAM,GAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAE/C,IAAI,IAAI;YACJ,OAAO;gBACH,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG;aAC/B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEhB,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAEkB,WAAW;QAC1B,OAAO,iBAAiB,CAAC,OAAO,CAAC;IACrC,CAAC;CACJ"}
|
||||
7
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfBooleanValue.d.ts
generated
vendored
Normal file
7
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfBooleanValue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
export declare class GbnfBooleanValue extends GbnfTerminal {
|
||||
readonly value: boolean;
|
||||
constructor(value: boolean);
|
||||
getGrammar(): string;
|
||||
resolve(): string;
|
||||
}
|
||||
17
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfBooleanValue.js
generated
vendored
Normal file
17
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfBooleanValue.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
export class GbnfBooleanValue extends GbnfTerminal {
|
||||
value;
|
||||
constructor(value) {
|
||||
super();
|
||||
this.value = value;
|
||||
}
|
||||
getGrammar() {
|
||||
if (this.value)
|
||||
return '"true"';
|
||||
return '"false"';
|
||||
}
|
||||
resolve() {
|
||||
return this.getGrammar();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfBooleanValue.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfBooleanValue.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfBooleanValue.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfBooleanValue.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfBooleanValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAGhD,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IAC9B,KAAK,CAAU;IAE/B,YAAmB,KAAc;QAC7B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAEM,UAAU;QACb,IAAI,IAAI,CAAC,KAAK;YACV,OAAO,QAAQ,CAAC;QAEpB,OAAO,SAAS,CAAC;IACrB,CAAC;IAEe,OAAO;QACnB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;CACJ"}
|
||||
11
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.d.ts
generated
vendored
Normal file
11
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfJsonScopeState } from "../utils/GbnfJsonScopeState.js";
|
||||
export declare class GbnfCommaWhitespace extends GbnfTerminal {
|
||||
readonly scopeState: GbnfJsonScopeState;
|
||||
readonly newLine: "before" | "after" | false;
|
||||
constructor(scopeState: GbnfJsonScopeState, { newLine }?: {
|
||||
newLine?: "before" | "after" | false;
|
||||
});
|
||||
getGrammar(): string;
|
||||
protected getRuleName(): string;
|
||||
}
|
||||
28
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.js
generated
vendored
Normal file
28
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfGrammar } from "./GbnfGrammar.js";
|
||||
import { GbnfWhitespace } from "./GbnfWhitespace.js";
|
||||
import { reservedRuleNames } from "./gbnfConsts.js";
|
||||
export class GbnfCommaWhitespace extends GbnfTerminal {
|
||||
scopeState;
|
||||
newLine;
|
||||
constructor(scopeState, { newLine = "before" } = {}) {
|
||||
super();
|
||||
this.scopeState = scopeState;
|
||||
this.newLine = newLine;
|
||||
}
|
||||
getGrammar() {
|
||||
return new GbnfGrammar([
|
||||
'","', new GbnfWhitespace(this.scopeState, { newLine: this.newLine }).getGrammar()
|
||||
]).getGrammar();
|
||||
}
|
||||
getRuleName() {
|
||||
return reservedRuleNames.commaWhitespace({
|
||||
newLine: this.scopeState.settings.allowNewLines
|
||||
? this.newLine
|
||||
: false,
|
||||
scopeSpaces: this.scopeState.settings.scopePadSpaces,
|
||||
nestingScope: this.scopeState.currentNestingScope
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfCommaWhitespace.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfCommaWhitespace.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfCommaWhitespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAGlD,MAAM,OAAO,mBAAoB,SAAQ,YAAY;IACjC,UAAU,CAAqB;IAC/B,OAAO,CAA6B;IAEpD,YAAmB,UAA8B,EAAE,EAC/C,OAAO,GAAG,QAAQ,KAGlB,EAAE;QACF,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAEM,UAAU;QACb,OAAO,IAAI,WAAW,CAAC;YACnB,KAAK,EAAE,IAAI,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,EAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAC,CAAC,CAAC,UAAU,EAAE;SACnF,CAAC,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAEkB,WAAW;QAC1B,OAAO,iBAAiB,CAAC,eAAe,CAAC;YACrC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,aAAa;gBAC3C,CAAC,CAAC,IAAI,CAAC,OAAO;gBACd,CAAC,CAAC,KAAK;YACX,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc;YACpD,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,mBAAmB;SACpD,CAAC,CAAC;IACP,CAAC;CACJ"}
|
||||
11
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfFormatString.d.ts
generated
vendored
Normal file
11
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfFormatString.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfGrammarGenerator } from "../GbnfGrammarGenerator.js";
|
||||
import { GbnfJsonFormatStringSchema } from "../types.js";
|
||||
export declare class GbnfFormatString extends GbnfTerminal {
|
||||
readonly format: GbnfJsonFormatStringSchema["format"];
|
||||
constructor(format: GbnfJsonFormatStringSchema["format"]);
|
||||
getGrammar(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
protected getRuleName(): string;
|
||||
private _getDateGrammar;
|
||||
private _getTimeGrammar;
|
||||
}
|
||||
90
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfFormatString.js
generated
vendored
Normal file
90
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfFormatString.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { reservedRuleNames } from "./gbnfConsts.js";
|
||||
import { GbnfGrammar } from "./GbnfGrammar.js";
|
||||
import { GbnfString } from "./GbnfString.js";
|
||||
export class GbnfFormatString extends GbnfTerminal {
|
||||
format;
|
||||
constructor(format) {
|
||||
super();
|
||||
this.format = format;
|
||||
}
|
||||
getGrammar(grammarGenerator) {
|
||||
const quote = '"\\""';
|
||||
if (this.format === "date")
|
||||
return new GbnfGrammar([
|
||||
quote,
|
||||
this._getDateGrammar(),
|
||||
quote
|
||||
]).getGrammar();
|
||||
else if (this.format === "time") {
|
||||
return new GbnfGrammar([
|
||||
quote,
|
||||
this._getTimeGrammar(),
|
||||
quote
|
||||
]).getGrammar();
|
||||
}
|
||||
else if (this.format === "date-time")
|
||||
return new GbnfGrammar([
|
||||
quote,
|
||||
this._getDateGrammar(),
|
||||
'"T"',
|
||||
this._getTimeGrammar(),
|
||||
quote
|
||||
]).getGrammar();
|
||||
return new GbnfString({
|
||||
minLength: 0,
|
||||
maxLength: 0
|
||||
}).resolve(grammarGenerator);
|
||||
}
|
||||
getRuleName() {
|
||||
return reservedRuleNames.formatString(this.format);
|
||||
}
|
||||
_getDateGrammar() {
|
||||
return new GbnfGrammar([
|
||||
"[0-9]{4}",
|
||||
'"-"',
|
||||
or([
|
||||
'"0" [1-9]',
|
||||
'"1" [012]'
|
||||
]),
|
||||
'"-"',
|
||||
or([
|
||||
'"0" [1-9]',
|
||||
"[12] [0-9]",
|
||||
'"3" [01]'
|
||||
])
|
||||
]).getGrammar();
|
||||
}
|
||||
_getTimeGrammar() {
|
||||
return new GbnfGrammar([
|
||||
or([
|
||||
"[01] [0-9]",
|
||||
'"2" [0-3]'
|
||||
]),
|
||||
'":"',
|
||||
"[0-5] [0-9]",
|
||||
'":"',
|
||||
"[0-5] [0-9]",
|
||||
'( "." [0-9]{3} )?',
|
||||
or([
|
||||
'"Z"',
|
||||
new GbnfGrammar([
|
||||
or([
|
||||
'"+"',
|
||||
'"-"'
|
||||
]),
|
||||
or([
|
||||
"[01] [0-9]",
|
||||
'"2" [0-3]'
|
||||
]),
|
||||
'":"',
|
||||
"[0-5] [0-9]"
|
||||
]).getGrammar()
|
||||
])
|
||||
]).getGrammar();
|
||||
}
|
||||
}
|
||||
function or(values) {
|
||||
return "(" + values.join(" | ") + ")";
|
||||
}
|
||||
//# sourceMappingURL=GbnfFormatString.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfFormatString.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfFormatString.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfFormatString.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfFormatString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAG3C,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IAC9B,MAAM,CAAuC;IAE7D,YAAmB,MAA4C;QAC3D,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEM,UAAU,CAAC,gBAAsC;QACpD,MAAM,KAAK,GAAG,OAA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AAI,WAAW,CAAC;oBACZ,EAAE,CAAC;wBACC,KAAK;wBACL,KAAK;qBACR,CAAC;oBACF,EAAE,CAAC;wBACC,YAAY;wBACZ,WAAW;qBACd,CAAC;oBACF,KAAK;oBACL,aAAa;iBAChB,CAAC,CAAC,UAAU,EAAE;aAClB,CAAC;SACL,CAAC,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;CACJ;AAED,SAAS,EAAE,CAAC,MAAgB;IACxB,OAAO,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;AAC1C,CAAC"}
|
||||
9
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfGrammar.d.ts
generated
vendored
Normal file
9
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfGrammar.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfGrammarGenerator } from "../GbnfGrammarGenerator.js";
|
||||
export declare class GbnfGrammar extends GbnfTerminal {
|
||||
readonly grammar: string | string[];
|
||||
readonly resolveToRawGrammar: boolean;
|
||||
constructor(grammar: string | string[], resolveToRawGrammar?: boolean);
|
||||
getGrammar(): string;
|
||||
resolve(grammarGenerator: GbnfGrammarGenerator, resolveAsRootGrammar?: boolean): string;
|
||||
}
|
||||
23
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfGrammar.js
generated
vendored
Normal file
23
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfGrammar.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
export class GbnfGrammar extends GbnfTerminal {
|
||||
grammar;
|
||||
resolveToRawGrammar;
|
||||
constructor(grammar, resolveToRawGrammar = false) {
|
||||
super();
|
||||
this.grammar = grammar;
|
||||
this.resolveToRawGrammar = resolveToRawGrammar;
|
||||
}
|
||||
getGrammar() {
|
||||
if (this.grammar instanceof Array)
|
||||
return this.grammar
|
||||
.filter((item) => item !== "")
|
||||
.join(" ");
|
||||
return this.grammar;
|
||||
}
|
||||
resolve(grammarGenerator, resolveAsRootGrammar = false) {
|
||||
if (this.resolveToRawGrammar)
|
||||
return this.getGrammar();
|
||||
return super.resolve(grammarGenerator, resolveAsRootGrammar);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfGrammar.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfGrammar.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfGrammar.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfGrammar.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfGrammar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAIhD,MAAM,OAAO,WAAY,SAAQ,YAAY;IACzB,OAAO,CAAoB;IAC3B,mBAAmB,CAAU;IAE7C,YAAmB,OAA0B,EAAE,sBAA+B,KAAK;QAC/E,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACnD,CAAC;IAEM,UAAU;QACb,IAAI,IAAI,CAAC,OAAO,YAAY,KAAK;YAC7B,OAAO,IAAI,CAAC,OAAO;iBACd,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC;iBAC7B,IAAI,CAAC,GAAG,CAAC,CAAC;QAEnB,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAEe,OAAO,CAAC,gBAAsC,EAAE,uBAAgC,KAAK;QACjG,IAAI,IAAI,CAAC,mBAAmB;YACxB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;QAE7B,OAAO,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;IACjE,CAAC;CACJ"}
|
||||
5
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.d.ts
generated
vendored
Normal file
5
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
export declare class GbnfInsideStringChar extends GbnfTerminal {
|
||||
getGrammar(): string;
|
||||
protected getRuleName(): string;
|
||||
}
|
||||
24
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.js
generated
vendored
Normal file
24
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { reservedRuleNames } from "./gbnfConsts.js";
|
||||
export class GbnfInsideStringChar extends GbnfTerminal {
|
||||
getGrammar() {
|
||||
return [
|
||||
negatedCharacterSet([
|
||||
'"',
|
||||
"\\\\",
|
||||
"\\x7F",
|
||||
"\\x00-\\x1F"
|
||||
]),
|
||||
// escape sequences
|
||||
'"\\\\" ["\\\\/bfnrt]',
|
||||
'"\\\\u" [0-9a-fA-F]{4}'
|
||||
].join(" | ");
|
||||
}
|
||||
getRuleName() {
|
||||
return reservedRuleNames.stringChar;
|
||||
}
|
||||
}
|
||||
function negatedCharacterSet(characterDefinitions) {
|
||||
return "[^" + characterDefinitions.join("") + "]";
|
||||
}
|
||||
//# sourceMappingURL=GbnfInsideStringChar.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfInsideStringChar.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfInsideStringChar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAElD,MAAM,OAAO,oBAAqB,SAAQ,YAAY;IAC3C,UAAU;QACb,OAAO;YACH,mBAAmB,CAAC;gBAChB,GAAG;gBACH,MAAM;gBACN,OAAO;gBACP,aAAa;aAChB,CAAC;YAEF,mBAAmB;YACnB,sBAAsB;YACtB,wBAAwB;SAC3B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC;IAEkB,WAAW;QAC1B,OAAO,iBAAiB,CAAC,UAAU,CAAC;IACxC,CAAC;CACJ;AAED,SAAS,mBAAmB,CAAC,oBAA8B;IACvD,OAAO,IAAI,GAAG,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;AACtD,CAAC"}
|
||||
5
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNull.d.ts
generated
vendored
Normal file
5
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNull.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
export declare class GbnfNull extends GbnfTerminal {
|
||||
getGrammar(): string;
|
||||
protected getRuleName(): string;
|
||||
}
|
||||
11
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNull.js
generated
vendored
Normal file
11
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNull.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { reservedRuleNames } from "./gbnfConsts.js";
|
||||
export class GbnfNull extends GbnfTerminal {
|
||||
getGrammar() {
|
||||
return '"null"';
|
||||
}
|
||||
getRuleName() {
|
||||
return reservedRuleNames.null;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfNull.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNull.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNull.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfNull.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfNull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAGlD,MAAM,OAAO,QAAS,SAAQ,YAAY;IAC/B,UAAU;QACb,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEkB,WAAW;QAC1B,OAAO,iBAAiB,CAAC,IAAI,CAAC;IAClC,CAAC;CACJ"}
|
||||
9
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNumber.d.ts
generated
vendored
Normal file
9
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNumber.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
export declare class GbnfNumber extends GbnfTerminal {
|
||||
readonly allowFractional: boolean;
|
||||
constructor({ allowFractional }: {
|
||||
allowFractional: boolean;
|
||||
});
|
||||
getGrammar(): string;
|
||||
protected getRuleName(): string;
|
||||
}
|
||||
22
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNumber.js
generated
vendored
Normal file
22
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNumber.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { reservedRuleNames } from "./gbnfConsts.js";
|
||||
export class GbnfNumber extends GbnfTerminal {
|
||||
allowFractional;
|
||||
constructor({ allowFractional = true }) {
|
||||
super();
|
||||
this.allowFractional = allowFractional;
|
||||
}
|
||||
getGrammar() {
|
||||
const num = '"-"? ("0" | [1-9] [0-9]{0,15})';
|
||||
const exponent = ' ([eE] [-+]? ("0" | [1-9] [0-9]{0,15}))?';
|
||||
if (this.allowFractional)
|
||||
return num + ' ("." [0-9]{1,16})?' + exponent;
|
||||
return num + exponent;
|
||||
}
|
||||
getRuleName() {
|
||||
if (this.allowFractional)
|
||||
return reservedRuleNames.number.fractional;
|
||||
return reservedRuleNames.number.integer;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfNumber.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNumber.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNumber.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfNumber.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAGlD,MAAM,OAAO,UAAW,SAAQ,YAAY;IACxB,eAAe,CAAU;IAEzC,YAAmB,EAAC,eAAe,GAAG,IAAI,EAA6B;QACnE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IAC3C,CAAC;IAEM,UAAU;QACb,MAAM,GAAG,GAAG,gCAAgC,CAAC;QAC7C,MAAM,QAAQ,GAAG,0CAA0C,CAAC;QAE5D,IAAI,IAAI,CAAC,eAAe;YACpB,OAAO,GAAG,GAAG,qBAAqB,GAAG,QAAQ,CAAC;QAElD,OAAO,GAAG,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAEkB,WAAW;QAC1B,IAAI,IAAI,CAAC,eAAe;YACpB,OAAO,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC;QAE/C,OAAO,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC;IAC5C,CAAC;CACJ"}
|
||||
9
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNumberValue.d.ts
generated
vendored
Normal file
9
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNumberValue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfGrammarGenerator } from "../GbnfGrammarGenerator.js";
|
||||
export declare class GbnfNumberValue extends GbnfTerminal {
|
||||
readonly value: number;
|
||||
constructor(value: number);
|
||||
getGrammar(): string;
|
||||
resolve(grammarGenerator: GbnfGrammarGenerator, resolveAsRootGrammar?: boolean): string;
|
||||
protected generateRuleName(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
}
|
||||
21
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNumberValue.js
generated
vendored
Normal file
21
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNumberValue.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
export class GbnfNumberValue extends GbnfTerminal {
|
||||
value;
|
||||
constructor(value) {
|
||||
super();
|
||||
this.value = value;
|
||||
}
|
||||
getGrammar() {
|
||||
return '"' + JSON.stringify(this.value) + '"';
|
||||
}
|
||||
resolve(grammarGenerator, resolveAsRootGrammar = false) {
|
||||
const grammar = this.getGrammar();
|
||||
if (grammar.length <= grammarGenerator.getProposedLiteralValueRuleNameLength())
|
||||
return grammar;
|
||||
return super.resolve(grammarGenerator, resolveAsRootGrammar);
|
||||
}
|
||||
generateRuleName(grammarGenerator) {
|
||||
return grammarGenerator.generateRuleNameForLiteralValue(this.value);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfNumberValue.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNumberValue.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfNumberValue.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfNumberValue.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfNumberValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAIhD,MAAM,OAAO,eAAgB,SAAQ,YAAY;IAC7B,KAAK,CAAS;IAE9B,YAAmB,KAAa;QAC5B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAEe,UAAU;QACtB,OAAO,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;IAClD,CAAC;IAEe,OAAO,CAAC,gBAAsC,EAAE,uBAAgC,KAAK;QACjG,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAClC,IAAI,OAAO,CAAC,MAAM,IAAI,gBAAgB,CAAC,qCAAqC,EAAE;YAC1E,OAAO,OAAO,CAAC;QAEnB,OAAO,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;IACjE,CAAC;IAEkB,gBAAgB,CAAC,gBAAsC;QACtE,OAAO,gBAAgB,CAAC,+BAA+B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxE,CAAC;CACJ"}
|
||||
28
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfObjectMap.d.ts
generated
vendored
Normal file
28
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfObjectMap.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfGrammarGenerator } from "../GbnfGrammarGenerator.js";
|
||||
import { GbnfJsonScopeState } from "../utils/GbnfJsonScopeState.js";
|
||||
import { GbnfString } from "./GbnfString.js";
|
||||
import { GbnfStringValue } from "./GbnfStringValue.js";
|
||||
export declare class GbnfObjectMap extends GbnfTerminal {
|
||||
readonly fields: Array<Readonly<{
|
||||
key: GbnfString | GbnfStringValue;
|
||||
value: GbnfTerminal;
|
||||
required: true;
|
||||
}>>;
|
||||
readonly additionalProperties?: GbnfTerminal;
|
||||
readonly minProperties: number;
|
||||
readonly maxProperties?: number;
|
||||
readonly scopeState: GbnfJsonScopeState;
|
||||
constructor({ fields, additionalProperties, minProperties, maxProperties, scopeState }: {
|
||||
fields: Array<Readonly<{
|
||||
key: GbnfString | GbnfStringValue;
|
||||
value: GbnfTerminal;
|
||||
required: true;
|
||||
}>>;
|
||||
additionalProperties?: GbnfTerminal;
|
||||
minProperties?: number;
|
||||
maxProperties?: number;
|
||||
scopeState?: GbnfJsonScopeState;
|
||||
});
|
||||
getGrammar(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
}
|
||||
88
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfObjectMap.js
generated
vendored
Normal file
88
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfObjectMap.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfJsonScopeState } from "../utils/GbnfJsonScopeState.js";
|
||||
import { GbnfString } from "./GbnfString.js";
|
||||
import { GbnfWhitespace } from "./GbnfWhitespace.js";
|
||||
import { GbnfGrammar } from "./GbnfGrammar.js";
|
||||
import { GbnfRepetition } from "./GbnfRepetition.js";
|
||||
import { GbnfCommaWhitespace } from "./GbnfCommaWhitespace.js";
|
||||
export class GbnfObjectMap extends GbnfTerminal {
|
||||
fields;
|
||||
additionalProperties;
|
||||
minProperties;
|
||||
maxProperties;
|
||||
scopeState;
|
||||
constructor({ fields, additionalProperties, minProperties = 0, maxProperties, scopeState = new GbnfJsonScopeState() }) {
|
||||
super();
|
||||
this.fields = fields;
|
||||
this.additionalProperties = additionalProperties;
|
||||
this.minProperties = Math.floor(minProperties);
|
||||
this.maxProperties = maxProperties == null ? undefined : Math.floor(maxProperties);
|
||||
this.scopeState = scopeState;
|
||||
if (this.minProperties < this.fields.length)
|
||||
this.minProperties = this.fields.length;
|
||||
if (this.maxProperties != null && this.maxProperties < this.minProperties)
|
||||
this.maxProperties = this.minProperties;
|
||||
else if (this.maxProperties != null && this.maxProperties < 0)
|
||||
this.maxProperties = 0;
|
||||
}
|
||||
getGrammar(grammarGenerator) {
|
||||
const getWhitespaceRuleName = (newScope, newLine) => (newScope
|
||||
? new GbnfWhitespace(this.scopeState.getForNewScope(), { newLine }).resolve(grammarGenerator)
|
||||
: new GbnfWhitespace(this.scopeState, { newLine }).resolve(grammarGenerator));
|
||||
const getCommaWhitespaceRule = (newScope, newLine) => (newScope
|
||||
? new GbnfCommaWhitespace(this.scopeState.getForNewScope(), { newLine })
|
||||
: new GbnfCommaWhitespace(this.scopeState, { newLine }));
|
||||
const getCommaWhitespaceRuleName = (newScope, newLine) => (getCommaWhitespaceRule(newScope, newLine).resolve(grammarGenerator));
|
||||
const objectItemsGrammar = [];
|
||||
for (const { key, value } of this.fields) {
|
||||
if (objectItemsGrammar.length > 0)
|
||||
objectItemsGrammar.push(getCommaWhitespaceRuleName(true, "before"));
|
||||
objectItemsGrammar.push(new GbnfGrammar([
|
||||
key.getGrammar(grammarGenerator), '":"', "[ ]?", value.resolve(grammarGenerator)
|
||||
]).getGrammar());
|
||||
}
|
||||
if (this.additionalProperties != null) {
|
||||
const additionalPropertiesGrammar = new GbnfGrammar([
|
||||
new GbnfString().resolve(grammarGenerator), '":"', "[ ]?", this.additionalProperties.resolve(grammarGenerator)
|
||||
]);
|
||||
if (this.minProperties > this.fields.length) {
|
||||
if (objectItemsGrammar.length > 0)
|
||||
objectItemsGrammar.push(getCommaWhitespaceRuleName(true, "before"));
|
||||
objectItemsGrammar.push(new GbnfRepetition({
|
||||
value: additionalPropertiesGrammar,
|
||||
separator: getCommaWhitespaceRule(true, "before"),
|
||||
minRepetitions: this.minProperties - this.fields.length,
|
||||
maxRepetitions: this.maxProperties == null
|
||||
? undefined
|
||||
: this.maxProperties - this.fields.length
|
||||
}).getGrammar(grammarGenerator));
|
||||
}
|
||||
else if (this.maxProperties == null || this.maxProperties > this.fields.length) {
|
||||
if (objectItemsGrammar.length === 0)
|
||||
objectItemsGrammar.push(new GbnfRepetition({
|
||||
value: additionalPropertiesGrammar,
|
||||
separator: getCommaWhitespaceRule(true, "before"),
|
||||
maxRepetitions: this.maxProperties == null
|
||||
? undefined
|
||||
: this.maxProperties - this.fields.length
|
||||
}).getGrammar(grammarGenerator));
|
||||
else
|
||||
objectItemsGrammar.push(new GbnfRepetition({
|
||||
value: new GbnfGrammar([
|
||||
getCommaWhitespaceRuleName(true, "before"),
|
||||
additionalPropertiesGrammar.resolve(grammarGenerator)
|
||||
], true),
|
||||
maxRepetitions: this.maxProperties == null
|
||||
? undefined
|
||||
: this.maxProperties - this.fields.length
|
||||
}).getGrammar(grammarGenerator));
|
||||
}
|
||||
}
|
||||
return new GbnfGrammar([
|
||||
'"{"', getWhitespaceRuleName(true, "before"),
|
||||
new GbnfGrammar(objectItemsGrammar).getGrammar(),
|
||||
getWhitespaceRuleName(false, "before"), '"}"'
|
||||
]).getGrammar();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfObjectMap.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfObjectMap.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfObjectMap.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfObjectMap.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfObjectMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAC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,2BAA2B;wBAClC,SAAS,EAAE,sBAAsB,CAAC,IAAI,EAAE,QAAQ,CAAC;wBACjD,cAAc,EAAE,IAAI,CAAC,aAAa,IAAI,IAAI;4BACtC,CAAC,CAAC,SAAS;4BACX,CAAC,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM;qBAChD,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAClC,CAAC;;oBAEF,kBAAkB,CAAC,IAAI,CACnB,IAAI,cAAc,CAAC;wBACf,KAAK,EAAE,IAAI,WAAW,CAAC;4BACnB,0BAA0B,CAAC,IAAI,EAAE,QAAQ,CAAC;4BAC1C,2BAA2B,CAAC,OAAO,CAAC,gBAAgB,CAAC;yBACxD,EAAE,IAAI,CAAC;wBACR,cAAc,EAAE,IAAI,CAAC,aAAa,IAAI,IAAI;4BACtC,CAAC,CAAC,SAAS;4BACX,CAAC,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM;qBAChD,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAClC,CAAC;YACV,CAAC;QACL,CAAC;QAED,OAAO,IAAI,WAAW,CAAC;YACnB,KAAK,EAAE,qBAAqB,CAAC,IAAI,EAAE,QAAQ,CAAC;YAC5C,IAAI,WAAW,CAAC,kBAAkB,CAAC,CAAC,UAAU,EAAE;YAChD,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,KAAK;SAChD,CAAC,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;CACJ"}
|
||||
9
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfOr.d.ts
generated
vendored
Normal file
9
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfOr.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfGrammarGenerator } from "../GbnfGrammarGenerator.js";
|
||||
export declare class GbnfOr extends GbnfTerminal {
|
||||
readonly values: readonly GbnfTerminal[];
|
||||
readonly useRawGrammar: boolean;
|
||||
constructor(values: readonly GbnfTerminal[], useRawGrammar?: boolean);
|
||||
getGrammar(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
resolve(grammarGenerator: GbnfGrammarGenerator, resolveAsRootGrammar?: boolean): string;
|
||||
}
|
||||
34
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfOr.js
generated
vendored
Normal file
34
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfOr.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { grammarNoValue } from "./gbnfConsts.js";
|
||||
export class GbnfOr extends GbnfTerminal {
|
||||
values;
|
||||
useRawGrammar;
|
||||
constructor(values, useRawGrammar = false) {
|
||||
super();
|
||||
this.values = values;
|
||||
this.useRawGrammar = useRawGrammar;
|
||||
}
|
||||
getGrammar(grammarGenerator) {
|
||||
const mappedValues = this.values
|
||||
.map((v) => (this.useRawGrammar
|
||||
? v.getGrammar(grammarGenerator)
|
||||
: v.resolve(grammarGenerator)))
|
||||
.filter((value) => value !== "" && value !== grammarNoValue);
|
||||
if (mappedValues.length === 0)
|
||||
return grammarNoValue;
|
||||
else if (mappedValues.length === 1)
|
||||
return mappedValues[0];
|
||||
return "( " + mappedValues.join(" | ") + " )";
|
||||
}
|
||||
resolve(grammarGenerator, resolveAsRootGrammar = false) {
|
||||
const mappedValues = this.values
|
||||
.map((v) => v.resolve(grammarGenerator))
|
||||
.filter((value) => value !== "" && value !== grammarNoValue);
|
||||
if (mappedValues.length === 0)
|
||||
return grammarNoValue;
|
||||
else if (mappedValues.length === 1)
|
||||
return mappedValues[0];
|
||||
return super.resolve(grammarGenerator, resolveAsRootGrammar);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfOr.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfOr.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfOr.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfOr.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfOr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAG/C,MAAM,OAAO,MAAO,SAAQ,YAAY;IACpB,MAAM,CAA0B;IAChC,aAAa,CAAU;IAEvC,YAAmB,MAA+B,EAAE,gBAAyB,KAAK;QAC9E,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACvC,CAAC;IAEM,UAAU,CAAC,gBAAsC;QACpD,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM;aAC3B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CACR,IAAI,CAAC,aAAa;YACd,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC;YAChC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CACpC,CAAC;aACD,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,cAAc,CAAC,CAAC;QAEjE,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;YACzB,OAAO,cAAc,CAAC;aACrB,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;YAC9B,OAAO,YAAY,CAAC,CAAC,CAAE,CAAC;QAE5B,OAAO,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAClD,CAAC;IAEe,OAAO,CAAC,gBAAsC,EAAE,uBAAgC,KAAK;QACjG,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM;aAC3B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;aACvC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,cAAc,CAAC,CAAC;QAEjE,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;YACzB,OAAO,cAAc,CAAC;aACrB,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;YAC9B,OAAO,YAAY,CAAC,CAAC,CAAE,CAAC;QAE5B,OAAO,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;IACjE,CAAC;CACJ"}
|
||||
15
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfRef.d.ts
generated
vendored
Normal file
15
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfRef.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfGrammarGenerator } from "../GbnfGrammarGenerator.js";
|
||||
import { GbnfJsonSchema } from "../types.js";
|
||||
export declare class GbnfRef extends GbnfTerminal {
|
||||
readonly getValueTerminal: () => GbnfTerminal;
|
||||
readonly defName: string;
|
||||
readonly def: GbnfJsonSchema;
|
||||
constructor({ getValueTerminal, defName, def }: {
|
||||
getValueTerminal: () => GbnfTerminal;
|
||||
defName: string;
|
||||
def: GbnfJsonSchema;
|
||||
});
|
||||
getGrammar(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
protected generateRuleName(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
}
|
||||
34
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfRef.js
generated
vendored
Normal file
34
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfRef.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
export class GbnfRef extends GbnfTerminal {
|
||||
getValueTerminal;
|
||||
defName;
|
||||
def;
|
||||
constructor({ getValueTerminal, defName, def }) {
|
||||
super();
|
||||
this.getValueTerminal = getValueTerminal;
|
||||
this.defName = defName;
|
||||
this.def = def;
|
||||
}
|
||||
getGrammar(grammarGenerator) {
|
||||
return this.generateRuleName(grammarGenerator);
|
||||
}
|
||||
generateRuleName(grammarGenerator) {
|
||||
if (!grammarGenerator.defRuleNames.has([this.defName, this.def])) {
|
||||
const alreadyGeneratingGrammarForThisRef = grammarGenerator.defRuleNames.get([this.defName, this.def]) === null;
|
||||
if (alreadyGeneratingGrammarForThisRef)
|
||||
return grammarGenerator.generateRuleNameForDef(this.defName, this.def);
|
||||
grammarGenerator.defRuleNames.set([this.defName, this.def], null);
|
||||
const grammar = this.getValueTerminal().resolve(grammarGenerator);
|
||||
if (grammarGenerator.rules.has(grammar) && grammarGenerator.defRuleNames.get([this.defName, this.def]) === null) {
|
||||
grammarGenerator.defRuleNames.set([this.defName, this.def], grammar);
|
||||
return grammar;
|
||||
}
|
||||
const ruleName = grammarGenerator.generateRuleNameForDef(this.defName, this.def);
|
||||
grammarGenerator.rules.set(ruleName, grammar);
|
||||
grammarGenerator.ruleContentToRuleName.set(grammar, ruleName);
|
||||
return ruleName;
|
||||
}
|
||||
return grammarGenerator.generateRuleNameForDef(this.defName, this.def);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfRef.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfRef.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfRef.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfRef.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAKhD,MAAM,OAAO,OA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AAgB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;gBACrE,OAAO,OAAO,CAAC;YACnB,CAAC;YAED,MAAM,QAAQ,GAAG,gBAAgB,CAAC,sBAAsB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;YACjF,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC9C,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAE9D,OAAO,QAAQ,CAAC;QACpB,CAAC;QAED,OAAO,gBAAgB,CAAC,sBAAsB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3E,CAAC;CACJ"}
|
||||
15
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfRepetition.d.ts
generated
vendored
Normal file
15
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfRepetition.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfGrammarGenerator } from "../GbnfGrammarGenerator.js";
|
||||
export declare class GbnfRepetition extends GbnfTerminal {
|
||||
readonly value: GbnfTerminal;
|
||||
readonly separator?: GbnfTerminal;
|
||||
readonly minRepetitions: number;
|
||||
readonly maxRepetitions: number | null;
|
||||
constructor({ value, separator, minRepetitions, maxRepetitions }: {
|
||||
value: GbnfTerminal;
|
||||
separator?: GbnfTerminal;
|
||||
minRepetitions?: number;
|
||||
maxRepetitions?: number | null;
|
||||
});
|
||||
getGrammar(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
}
|
||||
86
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfRepetition.js
generated
vendored
Normal file
86
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfRepetition.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfGrammar } from "./GbnfGrammar.js";
|
||||
import { grammarNoValue } from "./gbnfConsts.js";
|
||||
export class GbnfRepetition extends GbnfTerminal {
|
||||
value;
|
||||
separator;
|
||||
minRepetitions;
|
||||
maxRepetitions;
|
||||
constructor({ value, separator, minRepetitions = 0, maxRepetitions }) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.separator = separator;
|
||||
this.minRepetitions = Math.floor(minRepetitions);
|
||||
this.maxRepetitions = maxRepetitions == null ? null : Math.floor(maxRepetitions);
|
||||
if (this.minRepetitions < 0)
|
||||
this.minRepetitions = 0;
|
||||
if (this.maxRepetitions != null && this.maxRepetitions < 0)
|
||||
this.maxRepetitions = 0;
|
||||
if (this.maxRepetitions != null && this.maxRepetitions < this.minRepetitions)
|
||||
this.maxRepetitions = this.minRepetitions;
|
||||
}
|
||||
getGrammar(grammarGenerator) {
|
||||
if (this.maxRepetitions === 0)
|
||||
return grammarNoValue;
|
||||
const resolvedValue = this.value.resolve(grammarGenerator);
|
||||
const resolvedSeparator = this.separator?.resolve(grammarGenerator);
|
||||
if (this.minRepetitions === 0 && this.maxRepetitions == 1)
|
||||
return new GbnfGrammar(["(", resolvedValue, ")?"]).getGrammar();
|
||||
else if (this.minRepetitions === 1 && this.maxRepetitions === 1)
|
||||
return resolvedValue;
|
||||
else if (this.minRepetitions === this.maxRepetitions) {
|
||||
if (resolvedSeparator == null)
|
||||
return new GbnfGrammar(["(", resolvedValue, "){" + String(this.minRepetitions) + "}"]).getGrammar();
|
||||
if (this.minRepetitions === 2)
|
||||
return new GbnfGrammar([resolvedValue, resolvedSeparator, resolvedValue]).getGrammar();
|
||||
return new GbnfGrammar([
|
||||
resolvedValue, "(", resolvedSeparator, resolvedValue, "){" + String(this.minRepetitions - 1) + "}"
|
||||
]).getGrammar();
|
||||
}
|
||||
else if (this.minRepetitions === 0 && this.maxRepetitions == null) {
|
||||
if (resolvedSeparator == null)
|
||||
return new GbnfGrammar(["(", resolvedValue, ")*"]).getGrammar();
|
||||
return new GbnfGrammar([
|
||||
"(", resolvedValue, "(", resolvedSeparator, resolvedValue, ")*", ")?"
|
||||
]).getGrammar();
|
||||
}
|
||||
else if (this.minRepetitions === 1 && this.maxRepetitions == null) {
|
||||
if (resolvedSeparator == null)
|
||||
return new GbnfGrammar(["(", resolvedValue, ")+"]).getGrammar();
|
||||
return new GbnfGrammar([
|
||||
resolvedValue, "(", resolvedSeparator, resolvedValue, ")*"
|
||||
]).getGrammar();
|
||||
}
|
||||
else if (this.maxRepetitions == null) {
|
||||
if (resolvedSeparator == null)
|
||||
return new GbnfGrammar(["(", resolvedValue, "){" + String(this.minRepetitions) + ",}"]).getGrammar();
|
||||
return new GbnfGrammar([
|
||||
resolvedValue, "(", resolvedSeparator, resolvedValue, "){" + String(this.minRepetitions - 1) + ",}"
|
||||
]).getGrammar();
|
||||
}
|
||||
if (resolvedSeparator == null)
|
||||
return new GbnfGrammar(["(", resolvedValue, "){" + String(this.minRepetitions) + "," + String(this.maxRepetitions) + "}"]).getGrammar();
|
||||
if (this.minRepetitions === 0) {
|
||||
if (this.maxRepetitions === 2)
|
||||
return new GbnfGrammar([
|
||||
"(", resolvedValue, "(", resolvedSeparator, resolvedValue, ")?", ")?"
|
||||
]).getGrammar();
|
||||
return new GbnfGrammar([
|
||||
"(", resolvedValue, "(", resolvedSeparator, resolvedValue, "){0," + String(this.maxRepetitions - 1) + "}", ")?"
|
||||
]).getGrammar();
|
||||
}
|
||||
else if (this.minRepetitions === 1) {
|
||||
if (this.maxRepetitions === 2)
|
||||
return new GbnfGrammar([
|
||||
resolvedValue, "(", resolvedSeparator, resolvedValue, ")?"
|
||||
]).getGrammar();
|
||||
return new GbnfGrammar([
|
||||
resolvedValue, "(", resolvedSeparator, resolvedValue, "){0," + String(this.maxRepetitions - 1) + "}"
|
||||
]).getGrammar();
|
||||
}
|
||||
return new GbnfGrammar([
|
||||
resolvedValue, "(", resolvedSeparator, resolvedValue, "){" + String(this.minRepetitions - 1) + "," + String(this.maxRepetitions - 1) + "}"
|
||||
]).getGrammar();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfRepetition.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfRepetition.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfRepetition.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfRepetition.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfRepetition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAG/C,MAAM,OAAO,cAAe,SAAQ,YAAY;IAC5B,KAAK,CAAe;IACpB,SAAS,CAAgB;IACzB,cAAc,CAAS;IACvB,cAAc,CAAgB;IAE9C,YAAmB,EAAC,KAAK,EAAE,SAAS,EAAE,cAAc,GAAG,CAAC,EAAE,cAAc,EAEvE;QACG,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QACjD,IAAI,CAAC,cAAc,GAAG,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAEjF,IAAI,IAAI,CAAC,cAAc,GAAG,CAAC;YACvB,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;QAE5B,IAAI,IAAI,CAAC,cAAc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C,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,GAAG,GAAG;aACvG,CAAC,CAAC,UAAU,EAAE,CAAC;QACpB,CAAC;QAED,OAAO,IAAI,WAAW,CAAC;YACnB,aAAa,EAAE,GAAG,EAAE,iBAAiB,EAAE,aAAa,EAAE,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,GAAG,GAAG;SAC7I,CAAC,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;CACJ"}
|
||||
12
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfString.d.ts
generated
vendored
Normal file
12
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfString.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfGrammarGenerator } from "../GbnfGrammarGenerator.js";
|
||||
export declare class GbnfString extends GbnfTerminal {
|
||||
readonly minLength: number;
|
||||
readonly maxLength?: number;
|
||||
constructor({ minLength, maxLength }?: {
|
||||
minLength?: number;
|
||||
maxLength?: number;
|
||||
});
|
||||
getGrammar(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
protected getRuleName(): string;
|
||||
}
|
||||
43
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfString.js
generated
vendored
Normal file
43
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfString.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { reservedRuleNames } from "./gbnfConsts.js";
|
||||
import { GbnfRepetition } from "./GbnfRepetition.js";
|
||||
import { GbnfInsideStringChar } from "./GbnfInsideStringChar.js";
|
||||
export class GbnfString extends GbnfTerminal {
|
||||
minLength;
|
||||
maxLength;
|
||||
constructor({ minLength = 0, maxLength } = {}) {
|
||||
super();
|
||||
this.minLength = Math.floor(minLength ?? 0);
|
||||
this.maxLength = maxLength == null ? undefined : Math.floor(maxLength);
|
||||
if (this.minLength < 0)
|
||||
this.minLength = 0;
|
||||
if (this.maxLength != null && this.maxLength < this.minLength)
|
||||
this.maxLength = this.minLength;
|
||||
}
|
||||
getGrammar(grammarGenerator) {
|
||||
if (this.minLength == 0 && this.maxLength == null)
|
||||
return [
|
||||
'"\\""',
|
||||
new GbnfInsideStringChar().resolve(grammarGenerator) + "*",
|
||||
'"\\""'
|
||||
].join(" ");
|
||||
else if (this.minLength == 0 && this.maxLength == 0)
|
||||
return '"\\"\\""';
|
||||
return [
|
||||
'"\\""',
|
||||
new GbnfRepetition({
|
||||
value: new GbnfInsideStringChar(),
|
||||
minRepetitions: this.minLength,
|
||||
maxRepetitions: this.maxLength
|
||||
}).getGrammar(grammarGenerator),
|
||||
'"\\""'
|
||||
].join(" ");
|
||||
}
|
||||
getRuleName() {
|
||||
return reservedRuleNames.string({
|
||||
minLength: this.minLength,
|
||||
maxLength: this.maxLength
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfString.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfString.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfString.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfString.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAG/D,MAAM,OAAO,UAAW,SAAQ,YAAY;IACxB,SAAS,CAAS;IAClB,SAA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C;YAC5B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC5B,CAAC,CAAC;IACP,CAAC;CACJ"}
|
||||
8
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfStringValue.d.ts
generated
vendored
Normal file
8
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfStringValue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfGrammarGenerator } from "../GbnfGrammarGenerator.js";
|
||||
export declare class GbnfStringValue extends GbnfTerminal {
|
||||
readonly value: string;
|
||||
constructor(value: string);
|
||||
getGrammar(): string;
|
||||
protected generateRuleName(grammarGenerator: GbnfGrammarGenerator): string;
|
||||
}
|
||||
26
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfStringValue.js
generated
vendored
Normal file
26
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfStringValue.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
export class GbnfStringValue extends GbnfTerminal {
|
||||
value;
|
||||
constructor(value) {
|
||||
super();
|
||||
this.value = value;
|
||||
}
|
||||
getGrammar() {
|
||||
return [
|
||||
'"',
|
||||
'\\"',
|
||||
this.value
|
||||
.replaceAll("\\", "\\\\\\\\")
|
||||
.replaceAll("\t", "\\\\t")
|
||||
.replaceAll("\r", "\\\\r")
|
||||
.replaceAll("\n", "\\\\n")
|
||||
.replaceAll('"', "\\\\" + '\\"'),
|
||||
'\\"',
|
||||
'"'
|
||||
].join("");
|
||||
}
|
||||
generateRuleName(grammarGenerator) {
|
||||
return grammarGenerator.generateRuleNameForLiteralValue(this.value);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfStringValue.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfStringValue.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfStringValue.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfStringValue.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfStringValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAIhD,MAAM,OAAO,eAAgB,SAAQ,YAAY;IAC7B,KAAK,CAAS;IAE9B,YAAmB,KAAa;QAC5B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAEe,UAAU;QACtB,OAAO;YACH,GAAG;YACH,KAAK;YACL,IAAI,CAAC,KAAK;iBACL,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC;iBAC5B,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC;iBACzB,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC;iBACzB,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC;iBACzB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;YACpC,KAAK;YACL,GAAG;SACN,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,CAAC;IAEkB,gBAAgB,CAAC,gBAAsC;QACtE,OAAO,gBAAgB,CAAC,+BAA+B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxE,CAAC;CACJ"}
|
||||
6
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfVerbatimText.d.ts
generated
vendored
Normal file
6
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfVerbatimText.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
export declare class GbnfVerbatimText extends GbnfTerminal {
|
||||
readonly value: string;
|
||||
constructor(value: string);
|
||||
getGrammar(): string;
|
||||
}
|
||||
21
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfVerbatimText.js
generated
vendored
Normal file
21
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfVerbatimText.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
export class GbnfVerbatimText extends GbnfTerminal {
|
||||
value;
|
||||
constructor(value) {
|
||||
super();
|
||||
this.value = value;
|
||||
}
|
||||
getGrammar() {
|
||||
return [
|
||||
'"',
|
||||
this.value
|
||||
.replaceAll("\\", "\\\\")
|
||||
.replaceAll('"', '\\"')
|
||||
.replaceAll("\t", "\\t")
|
||||
.replaceAll("\r", "\\r")
|
||||
.replaceAll("\n", "\\n"),
|
||||
'"'
|
||||
].join("");
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfVerbatimText.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfVerbatimText.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfVerbatimText.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfVerbatimText.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfVerbatimText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAGhD,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IAC9B,KAAK,CAAS;IAE9B,YAAmB,KAAa;QAC5B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAEe,UAAU;QACtB,OAAO;YACH,GAAG;YACH,IAAI,CAAC,KAAK;iBACL,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC;iBACxB,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC;iBACtB,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC;iBACvB,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC;iBACvB,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC;YAC5B,GAAG;SACN,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,CAAC;CACJ"}
|
||||
13
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfWhitespace.d.ts
generated
vendored
Normal file
13
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfWhitespace.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfJsonScopeState } from "../utils/GbnfJsonScopeState.js";
|
||||
export declare class GbnfWhitespace extends GbnfTerminal {
|
||||
readonly scopeState: GbnfJsonScopeState;
|
||||
readonly newLine: "before" | "after" | false;
|
||||
constructor(scopeState: GbnfJsonScopeState, { newLine }?: {
|
||||
newLine?: "before" | "after" | false;
|
||||
});
|
||||
getGrammar(): string;
|
||||
protected getGrammarFromResolve(): string;
|
||||
private _getGrammar;
|
||||
protected getRuleName(): string;
|
||||
}
|
||||
67
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfWhitespace.js
generated
vendored
Normal file
67
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfWhitespace.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { reservedRuleNames } from "./gbnfConsts.js";
|
||||
import { GbnfVerbatimText } from "./GbnfVerbatimText.js";
|
||||
export class GbnfWhitespace extends GbnfTerminal {
|
||||
scopeState;
|
||||
newLine;
|
||||
constructor(scopeState, { newLine = "before" } = {}) {
|
||||
super();
|
||||
this.scopeState = scopeState;
|
||||
this.newLine = newLine;
|
||||
}
|
||||
getGrammar() {
|
||||
return this._getGrammar();
|
||||
}
|
||||
getGrammarFromResolve() {
|
||||
return this._getGrammar(false);
|
||||
}
|
||||
_getGrammar(wrap = true) {
|
||||
if (this.scopeState.settings.allowNewLines && this.newLine !== false) {
|
||||
const values = [
|
||||
...(this.newLine === "before"
|
||||
? ["[\\n]"]
|
||||
: []),
|
||||
...(this.scopeState.currentNestingScope === 0
|
||||
? []
|
||||
: [
|
||||
or([
|
||||
verbatimTextRepetition(" ", this.scopeState.currentNestingScope * this.scopeState.settings.scopePadSpaces),
|
||||
verbatimTextRepetition("\t", this.scopeState.currentNestingScope)
|
||||
])
|
||||
]),
|
||||
...(this.newLine === "after"
|
||||
? ["[\\n]"]
|
||||
: [])
|
||||
];
|
||||
return or([
|
||||
values.join(" "),
|
||||
"[ ]?"
|
||||
], wrap);
|
||||
}
|
||||
return "[ ]?";
|
||||
}
|
||||
getRuleName() {
|
||||
return reservedRuleNames.whitespace({
|
||||
newLine: this.scopeState.settings.allowNewLines
|
||||
? this.newLine
|
||||
: false,
|
||||
scopeSpaces: this.scopeState.settings.scopePadSpaces,
|
||||
nestingScope: this.scopeState.currentNestingScope
|
||||
});
|
||||
}
|
||||
}
|
||||
function or(definitions, wrap = true) {
|
||||
if (!wrap)
|
||||
return definitions.join(" | ");
|
||||
return "(" + definitions.join(" | ") + ")";
|
||||
}
|
||||
function verbatimTextRepetition(text, count) {
|
||||
const textRepetitionGrammar = new GbnfVerbatimText(text.repeat(count)).getGrammar();
|
||||
if (count <= 1)
|
||||
return textRepetitionGrammar;
|
||||
const textRepetitionGrammarWithRepetition = new GbnfVerbatimText(text).getGrammar() + "{" + count + "}";
|
||||
if (textRepetitionGrammarWithRepetition.length < textRepetitionGrammar.length)
|
||||
return textRepetitionGrammarWithRepetition;
|
||||
return textRepetitionGrammar;
|
||||
}
|
||||
//# sourceMappingURL=GbnfWhitespace.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfWhitespace.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/GbnfWhitespace.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfWhitespace.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson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AE/C,OAAO,qBAAqB,CAAC;AACjC,CAAC"}
|
||||
30
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/gbnfConsts.d.ts
generated
vendored
Normal file
30
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/gbnfConsts.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
export declare const grammarNoValue = "\"\"";
|
||||
export declare const reservedRuleNames: {
|
||||
readonly null: "null-rule";
|
||||
readonly boolean: "boolean-rule";
|
||||
readonly number: {
|
||||
readonly fractional: "fractional-number-rule";
|
||||
readonly integer: "integer-number-rule";
|
||||
};
|
||||
readonly stringChar: "string-char-rule";
|
||||
readonly string: ({ minLength, maxLength }: {
|
||||
minLength: number;
|
||||
maxLength?: number;
|
||||
}) => string;
|
||||
readonly formatString: (format: string) => string;
|
||||
readonly whitespace: ({ newLine, nestingScope, scopeSpaces }: {
|
||||
newLine?: "before" | "after" | false;
|
||||
nestingScope: number;
|
||||
scopeSpaces: number;
|
||||
}) => string;
|
||||
readonly commaWhitespace: ({ newLine, nestingScope, scopeSpaces }: {
|
||||
newLine?: "before" | "after" | false;
|
||||
nestingScope: number;
|
||||
scopeSpaces: number;
|
||||
}) => string;
|
||||
readonly anyJson: ({ allowNewLines, nestingScope, scopeSpaces }: {
|
||||
allowNewLines: boolean;
|
||||
nestingScope: number;
|
||||
scopeSpaces: number;
|
||||
}) => string;
|
||||
};
|
||||
72
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/gbnfConsts.js
generated
vendored
Normal file
72
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/gbnfConsts.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
export const grammarNoValue = '""';
|
||||
export const reservedRuleNames = {
|
||||
null: "null-rule",
|
||||
boolean: "boolean-rule",
|
||||
number: {
|
||||
fractional: "fractional-number-rule",
|
||||
integer: "integer-number-rule"
|
||||
},
|
||||
stringChar: "string-char-rule",
|
||||
string({ minLength, maxLength }) {
|
||||
if (minLength === 0 && maxLength == null)
|
||||
return "string-rule";
|
||||
else if (maxLength == null)
|
||||
return [
|
||||
"string-",
|
||||
minLength,
|
||||
"-rule"
|
||||
].join("");
|
||||
return [
|
||||
"string-",
|
||||
minLength,
|
||||
"-",
|
||||
maxLength,
|
||||
"-rule"
|
||||
].join("");
|
||||
},
|
||||
formatString(format) {
|
||||
return "string-format-" + format + "-rule";
|
||||
},
|
||||
whitespace({ newLine, nestingScope, scopeSpaces }) {
|
||||
if (!newLine)
|
||||
return "whitespace-no-new-lines-rule";
|
||||
return [
|
||||
"whitespace-",
|
||||
newLine === "before"
|
||||
? "b"
|
||||
: newLine === "after"
|
||||
? "a"
|
||||
: "n",
|
||||
"-" + nestingScope,
|
||||
"-" + scopeSpaces,
|
||||
"-rule"
|
||||
].join("");
|
||||
},
|
||||
commaWhitespace({ newLine, nestingScope, scopeSpaces }) {
|
||||
if (!newLine)
|
||||
return "comma-whitespace-no-new-lines-rule";
|
||||
return [
|
||||
"comma-whitespace-",
|
||||
newLine === "before"
|
||||
? "b"
|
||||
: newLine === "after"
|
||||
? "a"
|
||||
: "n",
|
||||
"-" + nestingScope,
|
||||
"-" + scopeSpaces,
|
||||
"-rule"
|
||||
].join("");
|
||||
},
|
||||
anyJson({ allowNewLines, nestingScope, scopeSpaces }) {
|
||||
return [
|
||||
"any-json-",
|
||||
!allowNewLines
|
||||
? "s-"
|
||||
: "",
|
||||
nestingScope,
|
||||
"-" + scopeSpaces,
|
||||
"-rule"
|
||||
].join("");
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=gbnfConsts.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/gbnfConsts.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/terminals/gbnfConsts.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"gbnfConsts.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/gbnfConsts.ts"],"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QAAQ;gBAChB,CAAC,CAAC,GAAG;gBACL,CAAC,CAAC,OAAO,KAAK,OAAO;oBACjB,CAAC,CAAC,GAAG;oBACL,CAAC,CAAC,GAAG;YACb,GAAG,GAAG,YAAY;YAClB,GAAG,GAAG,WAAW;YACjB,OAAO;SACV,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,CAAC;IACD,OAAO,CAAC,EAAC,aAAa,EAAE,YAAY,EAAE,WAAW,EAEhD;QACG,OAAO;YACH,WAAW;YACX,CAAC,aAAa;gBACV,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,EAAE;YACR,YAAY;YACZ,GAAG,GAAG,WAAW;YACjB,OAAO;SACV,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,CAAC;CACK,CAAC"}
|
||||
213
node_modules/node-llama-cpp/dist/utils/gbnfJson/types.d.ts
generated
vendored
Normal file
213
node_modules/node-llama-cpp/dist/utils/gbnfJson/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
export type GbnfJsonSchemaImmutableType = "string" | "number" | "integer" | "boolean" | "null";
|
||||
export type GbnfJsonSchema<Defs extends GbnfJsonDefList<Defs> = Record<any, any>> = GbnfJsonBasicSchema | GbnfJsonConstSchema | GbnfJsonEnumSchema | GbnfJsonOneOfSchema<Defs> | GbnfJsonStringSchema | GbnfJsonObjectSchema<string, Defs> | GbnfJsonArraySchema<Defs> | (keyof Defs extends string ? keyof NoInfer<Defs> extends never ? never : GbnfJsonRefSchema<Defs> : never);
|
||||
export type GbnfJsonDefList<Defs extends GbnfJsonDefList<NoInfer<Defs>> = {}> = {
|
||||
readonly [key: string]: GbnfJsonSchema<NoInfer<Defs>>;
|
||||
};
|
||||
export type GbnfJsonBasicSchema = {
|
||||
readonly type: GbnfJsonSchemaImmutableType | readonly GbnfJsonSchemaImmutableType[];
|
||||
/**
|
||||
* A description of what you expect the model to set this value to.
|
||||
*
|
||||
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
||||
*/
|
||||
readonly description?: string;
|
||||
};
|
||||
export type GbnfJsonConstSchema = {
|
||||
readonly const: string | number | boolean | null;
|
||||
/**
|
||||
* A description of what you expect the model to set this value to.
|
||||
*
|
||||
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
||||
*/
|
||||
readonly description?: string;
|
||||
};
|
||||
export type GbnfJsonEnumSchema = {
|
||||
readonly enum: readonly (string | number | boolean | null)[];
|
||||
/**
|
||||
* A description of what you expect the model to set this value to.
|
||||
*
|
||||
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
||||
*/
|
||||
readonly description?: string;
|
||||
};
|
||||
export type GbnfJsonOneOfSchema<Defs extends GbnfJsonDefList<NoInfer<Defs>> = {}> = {
|
||||
readonly oneOf: readonly GbnfJsonSchema<NoInfer<Defs>>[];
|
||||
/**
|
||||
* A description of what you expect the model to set this value to.
|
||||
*
|
||||
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
||||
*/
|
||||
readonly description?: string;
|
||||
readonly $defs?: Defs;
|
||||
};
|
||||
export type GbnfJsonStringSchema = GbnfJsonBasicStringSchema | GbnfJsonFormatStringSchema;
|
||||
export type GbnfJsonBasicStringSchema = {
|
||||
readonly type: "string";
|
||||
/**
|
||||
* When using `minLength` and/or `maxLength`,
|
||||
* ensure to inform the model as part of the prompt what your expectations are regarding the length of the string.
|
||||
* Not doing this may lead to hallucinations.
|
||||
*/
|
||||
readonly minLength?: number;
|
||||
/**
|
||||
* When using `minLength` and/or `maxLength`,
|
||||
* ensure to inform the model as part of the prompt what your expectations are regarding the length of the string.
|
||||
* Not doing this may lead to hallucinations.
|
||||
*/
|
||||
readonly maxLength?: number;
|
||||
/**
|
||||
* A description of what you expect the model to set this value to.
|
||||
*
|
||||
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
||||
*/
|
||||
readonly description?: string;
|
||||
};
|
||||
export type GbnfJsonFormatStringSchema = {
|
||||
readonly type: "string";
|
||||
readonly format: "date-time" | "time" | "date";
|
||||
/**
|
||||
* A description of what you expect the model to set this value to.
|
||||
*
|
||||
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
||||
*/
|
||||
readonly description?: string;
|
||||
};
|
||||
export type GbnfJsonObjectSchema<Keys extends string = string, Defs extends GbnfJsonDefList<NoInfer<Defs>> = {}> = {
|
||||
readonly type: "object";
|
||||
readonly properties?: {
|
||||
readonly [key in Keys]: GbnfJsonSchema<NoInfer<Defs>>;
|
||||
};
|
||||
/**
|
||||
* Unlike the JSON Schema spec, `additionalProperties` defaults to `false` to avoid breaking existing code.
|
||||
*/
|
||||
readonly additionalProperties?: boolean | GbnfJsonSchema<NoInfer<Defs>>;
|
||||
/**
|
||||
* Make sure you define `additionalProperties` for this to have any effect.
|
||||
*
|
||||
* When using `minProperties` and/or `maxProperties`,
|
||||
* ensure to inform the model as part of the prompt what your expectations are regarding the number of keys in the object.
|
||||
* Not doing this may lead to hallucinations.
|
||||
*/
|
||||
readonly minProperties?: number;
|
||||
/**
|
||||
* Make sure you define `additionalProperties` for this to have any effect.
|
||||
*
|
||||
* When using `minProperties` and/or `maxProperties`,
|
||||
* ensure to inform the model as part of the prompt what your expectations are regarding the number of keys in the object.
|
||||
* Not doing this may lead to hallucinations.
|
||||
*/
|
||||
readonly maxProperties?: number;
|
||||
/**
|
||||
* `required` is always set to all keys in `properties`, and setting it has no effect.
|
||||
*
|
||||
* This limitation is due to how the generation works, and may be fixed in the future.
|
||||
*
|
||||
* This key is part of the type to avoid breaking exiting code (though it was never actually used in the past),
|
||||
* and will be removed in the future.
|
||||
* @deprecated
|
||||
*/
|
||||
readonly required?: readonly Keys[];
|
||||
/**
|
||||
* A description of what you expect the model to set this value to.
|
||||
*
|
||||
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
||||
*/
|
||||
readonly description?: string;
|
||||
readonly $defs?: Defs;
|
||||
};
|
||||
export type GbnfJsonArraySchema<Defs extends GbnfJsonDefList<NoInfer<Defs>> = {}> = {
|
||||
readonly type: "array";
|
||||
readonly items?: GbnfJsonSchema<NoInfer<Defs>>;
|
||||
readonly prefixItems?: readonly GbnfJsonSchema<NoInfer<Defs>>[];
|
||||
/**
|
||||
* When using `minItems` and/or `maxItems`,
|
||||
* ensure to inform the model as part of the prompt what your expectations are regarding the length of the array.
|
||||
* Not doing this may lead to hallucinations.
|
||||
*/
|
||||
readonly minItems?: number;
|
||||
/**
|
||||
* When using `minItems` and/or `maxItems`,
|
||||
* ensure to inform the model as part of the prompt what your expectations are regarding the length of the array.
|
||||
* Not doing this may lead to hallucinations.
|
||||
*/
|
||||
readonly maxItems?: number;
|
||||
/**
|
||||
* A description of what you expect the model to set this value to.
|
||||
*
|
||||
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
||||
*/
|
||||
readonly description?: string;
|
||||
readonly $defs?: Defs;
|
||||
};
|
||||
export type GbnfJsonRefSchema<Defs extends GbnfJsonDefList<NoInfer<Defs>> = {}> = {
|
||||
readonly $ref: keyof NoInfer<Defs> extends never ? never : `#/$defs/${OnlyStringKeys<NoInfer<Defs>>}`;
|
||||
/**
|
||||
* A description of what you expect the model to set this value to.
|
||||
*
|
||||
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
||||
*/
|
||||
readonly description?: string;
|
||||
readonly $defs?: Defs;
|
||||
};
|
||||
/**
|
||||
* Converts a GBNF JSON schema to a TypeScript type
|
||||
*/
|
||||
export type GbnfJsonSchemaToType<T> = 0 extends 1 & T ? any : GbnfJsonSchemaToTSType<T>;
|
||||
export type GbnfJsonSchemaToTSType<T, Defs extends GbnfJsonDefList<NoInfer<Defs>> = {}> = Readonly<GbnfJsonBasicSchema> extends T ? undefined : undefined extends T ? undefined : T extends GbnfJsonBasicStringSchema ? GbnfJsonBasicStringSchemaToType<T> : T extends GbnfJsonFormatStringSchema ? string : T extends GbnfJsonBasicSchema ? GbnfJsonBasicSchemaToType<T["type"]> : T extends GbnfJsonConstSchema ? T["const"] : T extends GbnfJsonEnumSchema ? T["enum"][number] : T extends GbnfJsonOneOfSchema<Record<any, any>> ? GbnfJsonSchemaToTSType<T["oneOf"][number], CombineDefs<NoInfer<Defs>, T["$defs"]>> : T extends GbnfJsonObjectSchema<string, Record<any, any>> ? GbnfJsonObjectSchemaToType<T, NoInfer<Defs>> : T extends GbnfJsonArraySchema<Record<any, any>> ? ArrayTypeToType<T, CombineDefs<NoInfer<Defs>, T["$defs"]>> : T extends GbnfJsonRefSchema<any> ? GbnfJsonRefSchemaToType<T, CombineDefs<NoInfer<Defs>, T["$defs"]>> : undefined;
|
||||
type GbnfJsonBasicStringSchemaToType<T extends GbnfJsonBasicStringSchema> = T["maxLength"] extends 0 ? "" : string;
|
||||
type GbnfJsonBasicSchemaToType<T extends GbnfJsonBasicSchema["type"]> = T extends GbnfJsonSchemaImmutableType ? ImmutableTypeToType<T> : T[number] extends GbnfJsonSchemaImmutableType ? ImmutableTypeToType<T[number]> : never;
|
||||
type ImmutableTypeToType<T extends GbnfJsonSchemaImmutableType> = T extends "string" ? string : T extends "number" ? number : T extends "integer" ? number : T extends "boolean" ? boolean : T extends "null" ? null : never;
|
||||
type ArrayTypeToType<T extends GbnfJsonArraySchema<Record<any, any>>, Defs extends GbnfJsonDefList<Defs> = {}, MinItems extends number = T["minItems"] extends number ? T["prefixItems"] extends readonly GbnfJsonSchema[] ? keyof T["prefixItems"] extends T["minItems"] ? T["prefixItems"]["length"] : T["minItems"] : T["minItems"] : T["prefixItems"] extends readonly GbnfJsonSchema[] ? T["prefixItems"]["length"] : 0> = T["prefixItems"] extends readonly GbnfJsonSchema[] ? (MinItems extends T["prefixItems"]["length"] ? (T["maxItems"] extends MinItems ? [
|
||||
...GbnfJsonOrderedArrayTypes<T["prefixItems"], CombineDefs<Defs, T["$defs"]>>,
|
||||
...IndexRangeWithSkip<MinItems, T["prefixItems"]["length"], T["items"] extends GbnfJsonSchema ? GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>> : GbnfJsonAnyValue>
|
||||
] : [
|
||||
...GbnfJsonOrderedArrayTypes<T["prefixItems"], CombineDefs<Defs, T["$defs"]>>,
|
||||
...(T["items"] extends GbnfJsonSchema ? GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>> : GbnfJsonAnyValue)[]
|
||||
]) : T["maxItems"] extends MinItems ? [
|
||||
...GbnfJsonOrderedArrayTypes<T["prefixItems"], CombineDefs<Defs, T["$defs"]>>,
|
||||
...(T["items"] extends GbnfJsonSchema ? IndexRangeWithSkip<T["maxItems"], T["prefixItems"]["length"], GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>>> : IndexRangeWithSkip<T["maxItems"], T["prefixItems"]["length"], GbnfJsonAnyValue>)
|
||||
] : [
|
||||
...GbnfJsonOrderedArrayTypes<T["prefixItems"], CombineDefs<Defs, T["$defs"]>>,
|
||||
...IndexRangeWithSkip<MinItems, T["prefixItems"]["length"], T["items"] extends GbnfJsonSchema ? GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>> : GbnfJsonAnyValue>,
|
||||
...(T["items"] extends GbnfJsonSchema ? GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>> : GbnfJsonAnyValue)[]
|
||||
]) : T["items"] extends GbnfJsonSchema ? (MinItems extends 0 ? GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>>[] : T["maxItems"] extends MinItems ? IndexRange<T["maxItems"], GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>>> : [
|
||||
...IndexRange<MinItems, GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>>>,
|
||||
...GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>>[]
|
||||
]) : (MinItems extends 0 ? GbnfJsonAnyValue[] : T["maxItems"] extends MinItems ? IndexRange<T["maxItems"], GbnfJsonAnyValue> : [
|
||||
...IndexRange<MinItems, GbnfJsonAnyValue>,
|
||||
...GbnfJsonAnyValue[]
|
||||
]);
|
||||
type GbnfJsonObjectSchemaToType<T extends GbnfJsonObjectSchema<string, Record<any, any>>, Defs extends GbnfJsonDefList<Defs> = {}, Props extends Readonly<Record<string, GbnfJsonSchema>> | undefined = T["properties"], AdditionalProps extends true | false | GbnfJsonSchema | undefined = T["additionalProperties"], PropsMap = Props extends undefined ? {} : {
|
||||
-readonly [P in keyof Props]: GbnfJsonSchemaToTSType<Props[P], CombineDefs<Defs, T["$defs"]>>;
|
||||
}, Res = AdditionalProps extends undefined | false ? PropsMap : AdditionalProps extends true ? PropsMap & {
|
||||
[key: string]: GbnfJsonAnyValue;
|
||||
} : AdditionalProps extends GbnfJsonSchema ? PropsMap & {
|
||||
[key: string]: GbnfJsonSchemaToTSType<AdditionalProps, CombineDefs<Defs, T["$defs"]>>;
|
||||
} : PropsMap> = Res;
|
||||
type GbnfJsonRefSchemaToType<T extends GbnfJsonRefSchema<Defs>, Defs extends GbnfJsonDefList<Defs> = {}> = T["$ref"] extends `#/$defs/${infer Key}` ? Key extends keyof Defs ? GbnfJsonSchemaToTSType<Defs[Key], Defs> : never : never;
|
||||
type GbnfJsonAnyValue = string | number | boolean | null | GbnfJsonAnyValue[] | {
|
||||
[key: string]: GbnfJsonAnyValue;
|
||||
};
|
||||
export declare function isGbnfJsonConstSchema(schema: GbnfJsonSchema): schema is GbnfJsonConstSchema;
|
||||
export declare function isGbnfJsonEnumSchema(schema: GbnfJsonSchema): schema is GbnfJsonEnumSchema;
|
||||
export declare function isGbnfJsonOneOfSchema(schema: GbnfJsonSchema): schema is GbnfJsonOneOfSchema;
|
||||
export declare function isGbnfJsonBasicStringSchema(schema: GbnfJsonSchema): schema is GbnfJsonBasicStringSchema;
|
||||
export declare function isGbnfJsonFormatStringSchema(schema: GbnfJsonSchema): schema is GbnfJsonFormatStringSchema;
|
||||
export declare function isGbnfJsonObjectSchema(schema: GbnfJsonSchema): schema is GbnfJsonObjectSchema;
|
||||
export declare function isGbnfJsonArraySchema(schema: GbnfJsonSchema): schema is GbnfJsonArraySchema;
|
||||
export declare function isGbnfJsonRefSchema(schema: GbnfJsonSchema): schema is GbnfJsonRefSchema<Record<any, any>>;
|
||||
export declare function isGbnfJsonBasicSchemaIncludesType<T extends GbnfJsonSchemaImmutableType>(schema: GbnfJsonBasicSchema, type: T): schema is GbnfJsonBasicSchema & {
|
||||
type: T | (T | GbnfJsonSchemaImmutableType)[];
|
||||
};
|
||||
type OnlyStringKeys<T extends object> = {
|
||||
[K in keyof T]: K extends string ? K : never;
|
||||
}[keyof T];
|
||||
type CombineDefs<Defs1 extends GbnfJsonDefList<Defs1>, Param2 extends Defs1 | Defs2 | undefined, Defs2 extends GbnfJsonDefList<Defs2> = {}> = undefined extends NoInfer<Param2> ? Defs1 : Defs1 & Param2;
|
||||
type IndexRange<Length extends number, FillType = number, Res = _IndexRange<[], Length, FillType>> = Res;
|
||||
type _IndexRange<Value extends FillType[], MaxLength extends number, FillType = number> = Value["length"] extends MaxLength ? Value : _IndexRange<[...Value, FillType], MaxLength, FillType>;
|
||||
type IndexRangeWithSkip<Length extends number, SkipFirst extends number, FillType, Res = _IndexRangeWithSkip<[], IndexRange<SkipFirst>, Length, FillType>> = Res;
|
||||
type _IndexRangeWithSkip<Value extends FillType[], ConditionValue extends number[], MaxLength extends number, FillType> = ConditionValue["length"] extends MaxLength ? Value : _IndexRangeWithSkip<[...Value, FillType], [...ConditionValue, ConditionValue["length"]], MaxLength, FillType>;
|
||||
type GbnfJsonOrderedArrayTypes<T extends readonly GbnfJsonSchema[], Defs extends GbnfJsonDefList<Defs> = {}> = {
|
||||
-readonly [P in keyof T]: GbnfJsonSchemaToTSType<T[P], Defs>;
|
||||
};
|
||||
export {};
|
||||
30
node_modules/node-llama-cpp/dist/utils/gbnfJson/types.js
generated
vendored
Normal file
30
node_modules/node-llama-cpp/dist/utils/gbnfJson/types.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
export function isGbnfJsonConstSchema(schema) {
|
||||
return schema.const !== undefined;
|
||||
}
|
||||
export function isGbnfJsonEnumSchema(schema) {
|
||||
return schema.enum != null;
|
||||
}
|
||||
export function isGbnfJsonOneOfSchema(schema) {
|
||||
return schema.oneOf != null;
|
||||
}
|
||||
export function isGbnfJsonBasicStringSchema(schema) {
|
||||
return schema.type === "string" && schema.format == null;
|
||||
}
|
||||
export function isGbnfJsonFormatStringSchema(schema) {
|
||||
return schema.type === "string" && schema.format != null;
|
||||
}
|
||||
export function isGbnfJsonObjectSchema(schema) {
|
||||
return schema.type === "object";
|
||||
}
|
||||
export function isGbnfJsonArraySchema(schema) {
|
||||
return schema.type === "array";
|
||||
}
|
||||
export function isGbnfJsonRefSchema(schema) {
|
||||
return typeof schema.$ref === "string";
|
||||
}
|
||||
export function isGbnfJsonBasicSchemaIncludesType(schema, type) {
|
||||
if (schema.type instanceof Array)
|
||||
return schema.type.includes(type);
|
||||
return schema.type === type;
|
||||
}
|
||||
//# sourceMappingURL=types.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/types.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/types.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/gbnfJson/types.ts"],"names":[],"mappings":"AAgXA,MAAM,UAAU,qBAAqB,CAAC,MAAsB;IACxD,OAAQ,MAA8B,CAAC,KAAK,KAAK,SAAS,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAAsB;IACvD,OAAQ,MAA6B,CAAC,IAAI,IAAI,IAAI,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAsB;IACxD,OAAQ,MAA8B,CAAC,KAAK,IAAI,IAAI,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,MAAsB;IAC9D,OAAQ,MAAoC,CAAC,IAAI,KAAK,QAAQ,IAAK,MAAqC,CAAC,MAAM,IAAI,IAAI,CAAC;AAC5H,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,MAAsB;IAC/D,OAAQ,MAAqC,CAAC,IAAI,KAAK,QAAQ,IAAK,MAAqC,CAAC,MAAM,IAAI,IAAI,CAAC;AAC7H,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAsB;IACzD,OAAQ,MAA+B,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAsB;IACxD,OAAQ,MAA8B,CAAC,IAAI,KAAK,OAAO,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAsB;IACtD,OAAO,OAAQ,MAA4B,CAAC,IAAI,KAAK,QAAQ,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,iCAAiC,CAC7C,MAA2B,EAAE,IAAO;IAEpC,IAAI,MAAM,CAAC,IAAI,YAAY,KAAK;QAC5B,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEtC,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC;AAChC,CAAC"}
|
||||
10
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/GbnfJsonScopeState.d.ts
generated
vendored
Normal file
10
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/GbnfJsonScopeState.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export type GbnfJsonScopeSettings = {
|
||||
readonly allowNewLines: boolean;
|
||||
readonly scopePadSpaces: number;
|
||||
};
|
||||
export declare class GbnfJsonScopeState {
|
||||
readonly settings: GbnfJsonScopeSettings;
|
||||
readonly currentNestingScope: number;
|
||||
constructor(settings?: GbnfJsonScopeSettings, currentNestingScope?: number);
|
||||
getForNewScope(): GbnfJsonScopeState;
|
||||
}
|
||||
15
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/GbnfJsonScopeState.js
generated
vendored
Normal file
15
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/GbnfJsonScopeState.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
export class GbnfJsonScopeState {
|
||||
settings;
|
||||
currentNestingScope;
|
||||
constructor(settings = {
|
||||
allowNewLines: true,
|
||||
scopePadSpaces: 4
|
||||
}, currentNestingScope = 0) {
|
||||
this.settings = settings;
|
||||
this.currentNestingScope = currentNestingScope;
|
||||
}
|
||||
getForNewScope() {
|
||||
return new GbnfJsonScopeState(this.settings, this.currentNestingScope + 1);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=GbnfJsonScopeState.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/GbnfJsonScopeState.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/GbnfJsonScopeState.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GbnfJsonScopeState.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/utils/GbnfJsonScopeState.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,kBAAkB;IACX,QAAQ,CAAwB;IAChC,mBAAmB,CAAS;IAE5C,YAAmB,WAAkC;QACjD,aAAa,EAAE,IAAI;QACnB,cAAc,EAAE,CAAC;KACpB,EAAE,sBAA8B,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACnD,CAAC;IAEM,cAAc;QACjB,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC;IAC/E,CAAC;CACJ"}
|
||||
7
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/defsScope.d.ts
generated
vendored
Normal file
7
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/defsScope.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { MultiKeyMap } from "lifecycle-utils";
|
||||
import { GbnfJsonSchema } from "../types.js";
|
||||
export declare class DefScopeDefs {
|
||||
defScopeDefs: MultiKeyMap<[string, GbnfJsonSchema], Record<string, GbnfJsonSchema>>;
|
||||
registerDefs(scopeDefs: Record<string, GbnfJsonSchema>): void;
|
||||
}
|
||||
export declare function joinDefs(parent: Record<string, GbnfJsonSchema>, current?: Record<string, GbnfJsonSchema>): Record<string, GbnfJsonSchema>;
|
||||
17
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/defsScope.js
generated
vendored
Normal file
17
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/defsScope.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { MultiKeyMap } from "lifecycle-utils";
|
||||
export class DefScopeDefs {
|
||||
defScopeDefs = new MultiKeyMap();
|
||||
registerDefs(scopeDefs) {
|
||||
for (const [defName, def] of Object.entries(scopeDefs))
|
||||
this.defScopeDefs.set([defName, def], scopeDefs);
|
||||
}
|
||||
}
|
||||
export function joinDefs(parent, current) {
|
||||
if (current == null || Object.keys(current).length === 0)
|
||||
return parent;
|
||||
return {
|
||||
...parent,
|
||||
...current
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=defsScope.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/defsScope.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/defsScope.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"defsScope.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/utils/defsScope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAG5C,MAAM,OAAO,YAAY;IACd,YAAY,GAA0E,IAAI,WAAW,EAAE,CAAC;IAExG,YAAY,CAAC,SAAyC;QACzD,KAAK,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;YAClD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;IACzD,CAAC;CACJ;AAED,MAAM,UAAU,QAAQ,CACpB,MAAsC,EACtC,OAAwC;IAExC,IAAI,OAAO,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC;QACpD,OAAO,MAAM,CAAC;IAElB,OAAO;QACH,GAAG,MAAM;QACT,GAAG,OAAO;KACb,CAAC;AACN,CAAC"}
|
||||
5
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.d.ts
generated
vendored
Normal file
5
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { GbnfTerminal } from "../GbnfTerminal.js";
|
||||
import { GbnfGrammarGenerator } from "../GbnfGrammarGenerator.js";
|
||||
import { GbnfJsonSchema } from "../types.js";
|
||||
import { GbnfJsonScopeState } from "./GbnfJsonScopeState.js";
|
||||
export declare function getGbnfJsonTerminalForGbnfJsonSchema(schema: GbnfJsonSchema, grammarGenerator: GbnfGrammarGenerator, scopeState?: GbnfJsonScopeState, defs?: Record<string, GbnfJsonSchema>): GbnfTerminal;
|
||||
143
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js
generated
vendored
Normal file
143
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
import { GbnfOr } from "../terminals/GbnfOr.js";
|
||||
import { GbnfObjectMap } from "../terminals/GbnfObjectMap.js";
|
||||
import { GbnfStringValue } from "../terminals/GbnfStringValue.js";
|
||||
import { GbnfArray } from "../terminals/GbnfArray.js";
|
||||
import { GbnfString } from "../terminals/GbnfString.js";
|
||||
import { GbnfNumber } from "../terminals/GbnfNumber.js";
|
||||
import { GbnfBoolean } from "../terminals/GbnfBoolean.js";
|
||||
import { GbnfNull } from "../terminals/GbnfNull.js";
|
||||
import { isGbnfJsonArraySchema, isGbnfJsonBasicSchemaIncludesType, isGbnfJsonConstSchema, isGbnfJsonEnumSchema, isGbnfJsonObjectSchema, isGbnfJsonOneOfSchema, isGbnfJsonBasicStringSchema, isGbnfJsonFormatStringSchema, isGbnfJsonRefSchema } from "../types.js";
|
||||
import { getConsoleLogPrefix } from "../../getConsoleLogPrefix.js";
|
||||
import { GbnfAnyJson } from "../terminals/GbnfAnyJson.js";
|
||||
import { GbnfFormatString } from "../terminals/GbnfFormatString.js";
|
||||
import { GbnfRef } from "../terminals/GbnfRef.js";
|
||||
import { getGbnfJsonTerminalForLiteral } from "./getGbnfJsonTerminalForLiteral.js";
|
||||
import { GbnfJsonScopeState } from "./GbnfJsonScopeState.js";
|
||||
import { joinDefs } from "./defsScope.js";
|
||||
const maxNestingScope = 512;
|
||||
export function getGbnfJsonTerminalForGbnfJsonSchema(schema, grammarGenerator, scopeState = new GbnfJsonScopeState(), defs = {}) {
|
||||
if (scopeState.currentNestingScope >= maxNestingScope)
|
||||
throw new Error("Maximum nesting scope exceeded. Ensure that your schema does not have circular references or excessive nesting.");
|
||||
if (isGbnfJsonRefSchema(schema)) {
|
||||
const currentDefs = joinDefs(defs, schema.$defs);
|
||||
grammarGenerator.registerDefs(currentDefs);
|
||||
const ref = schema?.$ref;
|
||||
const referencePrefix = "#/$defs/";
|
||||
if (ref == null || !ref.startsWith(referencePrefix)) {
|
||||
console.warn(getConsoleLogPrefix(true, false), `Reference "${ref}" does not start with "${referencePrefix}". ` +
|
||||
'Using an "any" type instead of a reference.');
|
||||
return new GbnfAnyJson(scopeState);
|
||||
}
|
||||
const defName = ref.slice(referencePrefix.length);
|
||||
const def = currentDefs[defName];
|
||||
if (def == null) {
|
||||
console.warn(getConsoleLogPrefix(true, false), `Reference "${ref}" does not point to an existing definition. ` +
|
||||
'Using an "any" type instead of a reference.');
|
||||
return new GbnfAnyJson(scopeState);
|
||||
}
|
||||
return new GbnfRef({
|
||||
getValueTerminal() {
|
||||
const scopeDefs = grammarGenerator.defScopeDefs.get([defName, def]);
|
||||
return getGbnfJsonTerminalForGbnfJsonSchema(def, grammarGenerator, new GbnfJsonScopeState({
|
||||
allowNewLines: false,
|
||||
scopePadSpaces: scopeState.settings.scopePadSpaces
|
||||
}, 0), scopeDefs ?? {});
|
||||
},
|
||||
def,
|
||||
defName
|
||||
});
|
||||
}
|
||||
else if (isGbnfJsonOneOfSchema(schema)) {
|
||||
const currentDefs = joinDefs(defs, schema.$defs);
|
||||
grammarGenerator.registerDefs(currentDefs);
|
||||
const values = schema.oneOf
|
||||
.map((altSchema) => (getGbnfJsonTerminalForGbnfJsonSchema(altSchema, grammarGenerator, scopeState, currentDefs)));
|
||||
return new GbnfOr(values);
|
||||
}
|
||||
else if (isGbnfJsonConstSchema(schema)) {
|
||||
return getGbnfJsonTerminalForLiteral(schema.const);
|
||||
}
|
||||
else if (isGbnfJsonEnumSchema(schema)) {
|
||||
return new GbnfOr(schema.enum.map((item) => getGbnfJsonTerminalForLiteral(item)));
|
||||
}
|
||||
else if (isGbnfJsonObjectSchema(schema)) {
|
||||
const propertiesEntries = Object.entries(schema.properties ?? {});
|
||||
const currentDefs = joinDefs(defs, schema.$defs);
|
||||
grammarGenerator.registerDefs(currentDefs);
|
||||
let maxProperties = schema.maxProperties;
|
||||
if (schema.properties != null && maxProperties != null && maxProperties < propertiesEntries.length) {
|
||||
console.warn(getConsoleLogPrefix(true, false), `maxProperties (${maxProperties}) must be greater than or equal to ` +
|
||||
`properties object keys number (${propertiesEntries.length}). ` +
|
||||
"Using properties object keys number as maxProperties.");
|
||||
maxProperties = propertiesEntries.length;
|
||||
}
|
||||
return new GbnfObjectMap({
|
||||
fields: propertiesEntries.map(([propName, propSchema]) => {
|
||||
return {
|
||||
required: true,
|
||||
key: new GbnfStringValue(propName),
|
||||
value: getGbnfJsonTerminalForGbnfJsonSchema(propSchema, grammarGenerator, scopeState.getForNewScope(), currentDefs)
|
||||
};
|
||||
}),
|
||||
additionalProperties: (schema.additionalProperties == null || schema.additionalProperties === false)
|
||||
? undefined
|
||||
: schema.additionalProperties === true
|
||||
? new GbnfAnyJson(scopeState.getForNewScope())
|
||||
: getGbnfJsonTerminalForGbnfJsonSchema(schema.additionalProperties, grammarGenerator, scopeState.getForNewScope(), currentDefs),
|
||||
minProperties: schema.minProperties,
|
||||
maxProperties,
|
||||
scopeState
|
||||
});
|
||||
}
|
||||
else if (isGbnfJsonArraySchema(schema)) {
|
||||
const currentDefs = joinDefs(defs, schema.$defs);
|
||||
grammarGenerator.registerDefs(currentDefs);
|
||||
let maxItems = schema.maxItems;
|
||||
if (schema.prefixItems != null && maxItems != null && maxItems < schema.prefixItems.length) {
|
||||
console.warn(getConsoleLogPrefix(true, false), `maxItems (${maxItems}) must be greater than or equal to prefixItems array length (${schema.prefixItems.length}). ` +
|
||||
"Using prefixItems length as maxItems.");
|
||||
maxItems = schema.prefixItems.length;
|
||||
}
|
||||
return new GbnfArray({
|
||||
items: schema.items == null
|
||||
? undefined
|
||||
: getGbnfJsonTerminalForGbnfJsonSchema(schema.items, grammarGenerator, scopeState.getForNewScope(), currentDefs),
|
||||
prefixItems: schema.prefixItems == null
|
||||
? undefined
|
||||
: schema.prefixItems.map((item) => (getGbnfJsonTerminalForGbnfJsonSchema(item, grammarGenerator, scopeState.getForNewScope(), currentDefs))),
|
||||
minItems: schema.minItems,
|
||||
maxItems,
|
||||
scopeState
|
||||
});
|
||||
}
|
||||
else if (isGbnfJsonBasicStringSchema(schema)) {
|
||||
const minLength = Math.max(0, schema.minLength ?? 0);
|
||||
let maxLength = schema.maxLength;
|
||||
if (maxLength != null && maxLength < minLength) {
|
||||
console.warn(getConsoleLogPrefix(true, false), `maxLength (${maxLength}) must be greater than or equal to minLength (${minLength}). ` +
|
||||
"Using minLength as maxLength.");
|
||||
maxLength = minLength;
|
||||
}
|
||||
return new GbnfString({
|
||||
minLength,
|
||||
maxLength
|
||||
});
|
||||
}
|
||||
else if (isGbnfJsonFormatStringSchema(schema))
|
||||
return new GbnfFormatString(schema.format);
|
||||
const terminals = [];
|
||||
if (isGbnfJsonBasicSchemaIncludesType(schema, "string"))
|
||||
terminals.push(new GbnfString());
|
||||
if (isGbnfJsonBasicSchemaIncludesType(schema, "number"))
|
||||
terminals.push(new GbnfNumber({ allowFractional: true }));
|
||||
if (isGbnfJsonBasicSchemaIncludesType(schema, "integer"))
|
||||
terminals.push(new GbnfNumber({ allowFractional: false }));
|
||||
if (isGbnfJsonBasicSchemaIncludesType(schema, "boolean"))
|
||||
terminals.push(new GbnfBoolean());
|
||||
if (isGbnfJsonBasicSchemaIncludesType(schema, "null"))
|
||||
terminals.push(new GbnfNull());
|
||||
if (terminals.length === 0)
|
||||
terminals.push(new GbnfNull());
|
||||
return new GbnfOr(terminals);
|
||||
}
|
||||
//# sourceMappingURL=getGbnfJsonTerminalForGbnfJsonSchema.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.d.ts
generated
vendored
Normal file
5
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { GbnfNull } from "../terminals/GbnfNull.js";
|
||||
import { GbnfBooleanValue } from "../terminals/GbnfBooleanValue.js";
|
||||
import { GbnfNumberValue } from "../terminals/GbnfNumberValue.js";
|
||||
import { GbnfStringValue } from "../terminals/GbnfStringValue.js";
|
||||
export declare function getGbnfJsonTerminalForLiteral(literal: string | number | boolean | null): GbnfStringValue | GbnfNull | GbnfBooleanValue | GbnfNumberValue;
|
||||
16
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.js
generated
vendored
Normal file
16
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { GbnfNull } from "../terminals/GbnfNull.js";
|
||||
import { GbnfBooleanValue } from "../terminals/GbnfBooleanValue.js";
|
||||
import { GbnfNumberValue } from "../terminals/GbnfNumberValue.js";
|
||||
import { GbnfStringValue } from "../terminals/GbnfStringValue.js";
|
||||
export function getGbnfJsonTerminalForLiteral(literal) {
|
||||
if (literal === null)
|
||||
return new GbnfNull();
|
||||
if (typeof literal === "boolean")
|
||||
return new GbnfBooleanValue(literal);
|
||||
if (typeof literal === "number")
|
||||
return new GbnfNumberValue(literal);
|
||||
if (typeof literal === "string")
|
||||
return new GbnfStringValue(literal);
|
||||
throw new Error(`Unrecognized literal type: ${typeof literal}`);
|
||||
}
|
||||
//# sourceMappingURL=getGbnfJsonTerminalForLiteral.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"getGbnfJsonTerminalForLiteral.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAC,gBAAgB,EAAC,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAGhE,MAAM,UAAU,6BAA6B,CAAC,OAAyC;IACnF,IAAI,OAAO,KAAK,IAAI;QAChB,OAAO,IAAI,QAAQ,EAAE,CAAC;IAE1B,IAAI,OAAO,OAAO,KAAK,SAAS;QAC5B,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAEzC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IAExC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IAExC,MAAM,IAAI,KAAK,CAAC,8BAA8B,OAAO,OAAO,EAAE,CAAC,CAAC;AACpE,CAAC"}
|
||||
8
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.d.ts
generated
vendored
Normal file
8
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { GbnfJsonSchema, GbnfJsonSchemaToType } from "../types.js";
|
||||
export declare function validateObjectAgainstGbnfSchema(object: any, schema: unknown): boolean;
|
||||
export declare function validateObjectAgainstGbnfSchema<T extends GbnfJsonSchema>(object: any, schema: T): object is GbnfJsonSchemaToType<T>;
|
||||
export declare class LlamaJsonSchemaValidationError extends Error {
|
||||
readonly object: any;
|
||||
readonly schema: GbnfJsonSchema;
|
||||
constructor(message: string, object: any, schema: GbnfJsonSchema);
|
||||
}
|
||||
242
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js
generated
vendored
Normal file
242
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js
generated
vendored
Normal file
@@ -0,0 +1,242 @@
|
||||
import { isGbnfJsonArraySchema, isGbnfJsonConstSchema, isGbnfJsonEnumSchema, isGbnfJsonObjectSchema, isGbnfJsonOneOfSchema, isGbnfJsonBasicStringSchema, isGbnfJsonFormatStringSchema, isGbnfJsonRefSchema } from "../types.js";
|
||||
import { DefScopeDefs, joinDefs } from "./defsScope.js";
|
||||
export function validateObjectAgainstGbnfSchema(object, schema) {
|
||||
try {
|
||||
return validateObjectWithGbnfSchema(object, schema);
|
||||
}
|
||||
catch (err) {
|
||||
if (err instanceof TechnicalValidationError)
|
||||
throw new LlamaJsonSchemaValidationError(err.message, object, schema);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
export class LlamaJsonSchemaValidationError extends Error {
|
||||
object;
|
||||
schema;
|
||||
constructor(message, object, schema) {
|
||||
super(message);
|
||||
this.object = object;
|
||||
this.schema = schema;
|
||||
}
|
||||
}
|
||||
class TechnicalValidationError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
function validateObjectWithGbnfSchema(object, schema, defs = {}, defScopeDefs = new DefScopeDefs()) {
|
||||
if (isGbnfJsonRefSchema(schema))
|
||||
return validateRef(object, schema, defs, defScopeDefs);
|
||||
else if (isGbnfJsonArraySchema(schema))
|
||||
return validateArray(object, schema, defs, defScopeDefs);
|
||||
else if (isGbnfJsonObjectSchema(schema))
|
||||
return validateObject(object, schema, defs, defScopeDefs);
|
||||
else if (isGbnfJsonOneOfSchema(schema))
|
||||
return validateOneOf(object, schema, defs, defScopeDefs);
|
||||
else if (isGbnfJsonBasicStringSchema(schema))
|
||||
return validateBasicString(object, schema);
|
||||
else if (isGbnfJsonFormatStringSchema(schema))
|
||||
return validateFormatString(object, schema);
|
||||
else if (isGbnfJsonEnumSchema(schema))
|
||||
return validateEnum(object, schema);
|
||||
else if (isGbnfJsonConstSchema(schema))
|
||||
return validateConst(object, schema);
|
||||
if (schema.type instanceof Array) {
|
||||
for (const type of schema.type) {
|
||||
if (validateImmutableType(object, type))
|
||||
return true;
|
||||
}
|
||||
throw new TechnicalValidationError(`Expected one type of [${schema.type.map((type) => JSON.stringify(type)).join(", ")}] but got type "${object === null ? null : typeof object}"`);
|
||||
}
|
||||
if (validateImmutableType(object, schema.type))
|
||||
return true;
|
||||
throw new TechnicalValidationError(`Expected type "${schema.type}" but got "${object === null ? "null" : typeof object}"`);
|
||||
}
|
||||
function validateRef(object, schema, defs = {}, defScopeDefs = new DefScopeDefs()) {
|
||||
const currentDefs = joinDefs(defs, schema.$defs);
|
||||
defScopeDefs.registerDefs(currentDefs);
|
||||
const ref = schema.$ref;
|
||||
const referencePrefix = "#/$defs/";
|
||||
if (ref == null || !ref.startsWith(referencePrefix)) {
|
||||
// if the $ref is invalid, a warning was already shows when the grammar was generated,
|
||||
// so we don't perform validation on the object as it's considered an "any" type
|
||||
return true;
|
||||
}
|
||||
const defName = ref.slice(referencePrefix.length);
|
||||
const def = currentDefs[defName];
|
||||
if (def == null) {
|
||||
// if the $ref points to a non-existing def, a warning was already shows when the grammar was generated,
|
||||
// so we don't perform validation on the object as it's considered an "any" type
|
||||
return true;
|
||||
}
|
||||
const scopeDefs = defScopeDefs.defScopeDefs.get([defName, def]);
|
||||
return validateObjectWithGbnfSchema(object, def, scopeDefs ?? {}, defScopeDefs);
|
||||
}
|
||||
function validateArray(object, schema, defs = {}, defScopeDefs = new DefScopeDefs()) {
|
||||
if (!(object instanceof Array))
|
||||
throw new TechnicalValidationError(`Expected an array but got "${typeof object}"`);
|
||||
const minItems = Math.max(schema.minItems ?? 0, schema.prefixItems?.length ?? 0);
|
||||
const maxItems = schema.maxItems == null
|
||||
? undefined
|
||||
: Math.max(schema.maxItems, minItems);
|
||||
if (object.length < minItems) {
|
||||
if (maxItems != null && minItems === maxItems)
|
||||
throw new TechnicalValidationError(`Expected exactly ${minItems} items but got ${object.length}`);
|
||||
throw new TechnicalValidationError(`Expected at least ${minItems} items but got ${object.length}`);
|
||||
}
|
||||
else if (maxItems != null && object.length > maxItems) {
|
||||
if (minItems === maxItems)
|
||||
throw new TechnicalValidationError(`Expected exactly ${minItems} items but got ${object.length}`);
|
||||
throw new TechnicalValidationError(`Expected at most ${maxItems} items but got ${object.length}`);
|
||||
}
|
||||
let res = true;
|
||||
let index = 0;
|
||||
const currentDefs = joinDefs(defs, schema.$defs);
|
||||
defScopeDefs.registerDefs(currentDefs);
|
||||
if (schema.prefixItems != null) {
|
||||
for (const item of schema.prefixItems) {
|
||||
res &&= validateObjectWithGbnfSchema(object[index], item, currentDefs, defScopeDefs);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
if (schema.items != null) {
|
||||
for (; index < object.length; index++)
|
||||
res &&= validateObjectWithGbnfSchema(object[index], schema.items, currentDefs, defScopeDefs);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
function validateObject(object, schema, defs = {}, defScopeDefs = new DefScopeDefs()) {
|
||||
if (typeof object !== "object" || object === null)
|
||||
throw new TechnicalValidationError(`Expected an object but got "${typeof object}"`);
|
||||
let res = true;
|
||||
const currentDefs = joinDefs(defs, schema.$defs);
|
||||
defScopeDefs.registerDefs(currentDefs);
|
||||
const objectKeys = Object.keys(object);
|
||||
const objectKeysSet = new Set(objectKeys);
|
||||
const schemaKeys = Object.keys(schema.properties ?? {});
|
||||
const schemaKeysSet = new Set(schemaKeys);
|
||||
const minProperties = Math.max(schema.minProperties ?? 0, schemaKeys.length);
|
||||
const maxProperties = schema.maxProperties == null
|
||||
? undefined
|
||||
: Math.max(schema.maxProperties, minProperties);
|
||||
const extraKeys = objectKeys.filter((key) => !schemaKeysSet.has(key));
|
||||
if (extraKeys.length > 0) {
|
||||
if (schema.additionalProperties == null || schema.additionalProperties === false)
|
||||
throw new TechnicalValidationError(`Unexpected keys: ${extraKeys.map((key) => JSON.stringify(key)).join(", ")}`);
|
||||
else if (schema.additionalProperties !== true) {
|
||||
for (const key of extraKeys)
|
||||
res &&= validateObjectWithGbnfSchema(object[key], schema.additionalProperties, currentDefs, defScopeDefs);
|
||||
}
|
||||
}
|
||||
const missingKeys = schemaKeys.filter((key) => !objectKeysSet.has(key));
|
||||
if (missingKeys.length > 0)
|
||||
throw new TechnicalValidationError(`Missing keys: ${missingKeys.map((key) => JSON.stringify(key)).join(", ")}`);
|
||||
for (const key of schemaKeys)
|
||||
res &&= validateObjectWithGbnfSchema(object[key], schema.properties[key], currentDefs, defScopeDefs);
|
||||
if (schema.additionalProperties != null && schema.additionalProperties !== false) {
|
||||
if (objectKeys.length < minProperties) {
|
||||
if (maxProperties != null && minProperties === maxProperties)
|
||||
throw new TechnicalValidationError(`Expected exactly ${minProperties} properties but got ${objectKeys.length}`);
|
||||
throw new TechnicalValidationError(`Expected at least ${minProperties} properties but got ${objectKeys.length}`);
|
||||
}
|
||||
else if (maxProperties != null && objectKeys.length > maxProperties) {
|
||||
if (minProperties === maxProperties)
|
||||
throw new TechnicalValidationError(`Expected exactly ${minProperties} properties but got ${objectKeys.length}`);
|
||||
throw new TechnicalValidationError(`Expected at most ${maxProperties} properties but got ${objectKeys.length}`);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
function validateOneOf(object, schema, defs = {}, defScopeDefs = new DefScopeDefs()) {
|
||||
const currentDefs = joinDefs(defs, schema.$defs);
|
||||
defScopeDefs.registerDefs(currentDefs);
|
||||
for (const item of schema.oneOf) {
|
||||
try {
|
||||
return validateObjectWithGbnfSchema(object, item, currentDefs, defScopeDefs);
|
||||
}
|
||||
catch (err) {
|
||||
if (err instanceof TechnicalValidationError)
|
||||
continue;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
throw new TechnicalValidationError(`Expected one of ${schema.oneOf.length} schemas but got ${JSON.stringify(object)}`);
|
||||
}
|
||||
function validateBasicString(object, schema) {
|
||||
if (typeof object !== "string")
|
||||
throw new TechnicalValidationError(`Expected type "${schema.type}" but got "${object === null ? "null" : typeof object}"`);
|
||||
const minLength = Math.max(0, schema.minLength ?? 0);
|
||||
const maxLength = schema.maxLength == null
|
||||
? undefined
|
||||
: Math.max(schema.maxLength, minLength);
|
||||
if (object.length < minLength) {
|
||||
if (minLength === maxLength)
|
||||
throw new TechnicalValidationError(`Expected exactly ${minLength} characters but got ${object.length}`);
|
||||
throw new TechnicalValidationError(`Expected at least ${minLength} characters but got ${object.length}`);
|
||||
}
|
||||
else if (maxLength != null && object.length > maxLength) {
|
||||
if (minLength === maxLength)
|
||||
throw new TechnicalValidationError(`Expected exactly ${minLength} characters but got ${object.length}`);
|
||||
throw new TechnicalValidationError(`Expected at most ${maxLength} characters but got ${object.length}`);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const dateRegex = /^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/;
|
||||
const timeRegex = /^([01]\d|2[0-3]):[0-5]\d:[0-5]\d(\.\d{3})?(Z|[+-]([01][0-9]|2[0-3])?:[0-5][0-9])$/;
|
||||
const datetimeRegex = /^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])T([01]\d|2[0-3]):[0-5]\d:[0-5]\d(\.\d{3})?(Z|[+-]([01][0-9]|2[0-3])?:[0-5][0-9])$/;
|
||||
function validateFormatString(object, schema) {
|
||||
if (typeof object !== "string")
|
||||
throw new TechnicalValidationError(`Expected type "${schema.type}" but got "${object === null ? "null" : typeof object}"`);
|
||||
if (schema.format === "date") {
|
||||
if (object.match(dateRegex) != null)
|
||||
return true;
|
||||
throw new TechnicalValidationError(`Expected a valid date string but got ${JSON.stringify(object)}`);
|
||||
}
|
||||
else if (schema.format === "time") {
|
||||
if (object.match(timeRegex) != null)
|
||||
return true;
|
||||
throw new TechnicalValidationError(`Expected a valid time string but got ${JSON.stringify(object)}`);
|
||||
}
|
||||
else if (schema.format === "date-time") {
|
||||
if (object.match(datetimeRegex) != null)
|
||||
return true;
|
||||
throw new TechnicalValidationError(`Expected a valid date-time string but got ${JSON.stringify(object)}`);
|
||||
}
|
||||
throw new TechnicalValidationError(`Unknown format "${schema.format}"`);
|
||||
}
|
||||
function validateEnum(object, schema) {
|
||||
for (const value of schema.enum) {
|
||||
if (object === value)
|
||||
return true;
|
||||
}
|
||||
throw new TechnicalValidationError(`Expected one of [${schema.enum.map((item) => JSON.stringify(item)).join(", ")}] but got ${JSON.stringify(object)}`);
|
||||
}
|
||||
function validateConst(object, schema) {
|
||||
if (object === schema.const)
|
||||
return true;
|
||||
throw new TechnicalValidationError(`Expected ${JSON.stringify(schema.const)} but got ${JSON.stringify(object)}`);
|
||||
}
|
||||
function validateImmutableType(value, type) {
|
||||
if (type === "string") {
|
||||
return typeof value === "string";
|
||||
}
|
||||
else if (type === "number") {
|
||||
return typeof value === "number";
|
||||
}
|
||||
else if (type === "integer") {
|
||||
if (typeof value !== "number")
|
||||
return false;
|
||||
return value % 1 === 0;
|
||||
}
|
||||
else if (type === "boolean") {
|
||||
return typeof value === "boolean";
|
||||
}
|
||||
else if (type === "null") {
|
||||
return value === null;
|
||||
}
|
||||
else {
|
||||
void type;
|
||||
}
|
||||
throw new TechnicalValidationError(`Unknown immutable type ${JSON.stringify(type)}`);
|
||||
}
|
||||
//# sourceMappingURL=validateObjectAgainstGbnfSchema.js.map
|
||||
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js.map
generated
vendored
Normal file
1
node_modules/node-llama-cpp/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user