First upload version 0.0.1
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user