-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
examples/basic/src/model-provider/llamacpp/llamacpp-generate-text-grammar-example.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
9d21679
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
modelfusion – ./
modelfusion-git-main-lgrammel.vercel.app
modelfusion.dev
www.modelfusion.dev
modelfusion-lgrammel.vercel.app