Skip to content

Commit

Permalink
Add llama.cpp grammar example.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrammel committed Dec 30, 2023
1 parent c0de604 commit 9d21679
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { MistralInstructPrompt, generateText, llamacpp } from "modelfusion";

async function main() {
const text = await generateText(
llamacpp
.TextGenerator({
maxGenerationTokens: 512,
temperature: 0,
// simple list grammar:
grammar: `root ::= ("- " item)+
item ::= [^\\n]+ "\\n"`,
})
.withTextPromptTemplate(MistralInstructPrompt.text()),

"List 5 ingredients for a lasagna:\n\n"
);

console.log(text);
}

main().catch(console.error);

1 comment on commit 9d21679

@vercel
Copy link

@vercel vercel bot commented on 9d21679 Dec 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.