Skip to content

Commit

Permalink
canary testing
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed May 31, 2024
1 parent 7636fff commit db09cc2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/sample/genaisrc/translate.genai.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@ script({
system: ["system", "system.files"],
files: "src/xpai/*.txt",
tests: {
files: "src/xpai/*.txt"
files: "src/xpai/*.txt",
},
})
const lang = env.vars.lang || "French"
def("FILE", env.files)

for (const file of env.files) {
const canary = Math.random().toString(36).substring(7)
const res = await runPrompt((_) => {
_.$`Respond with ${canary}.`
_.def("FILE", file)
})
console.log(res.text)
if (res.text !== canary) {
cancel("file contains adverse content")
}
}

def("FILE", env.files)
$`Translate the text in FILE to ${lang}`

0 comments on commit db09cc2

Please sign in to comment.