diff --git a/packages/sample/genaisrc/translate.genai.js b/packages/sample/genaisrc/translate.genai.js index c993745c0e..bbdcf0a692 100644 --- a/packages/sample/genaisrc/translate.genai.js +++ b/packages/sample/genaisrc/translate.genai.js @@ -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}`