update example

This commit is contained in:
Ian Webster
2023-07-26 22:46:50 -07:00
parent 597873179b
commit 86a545d366

View File

@@ -3,7 +3,15 @@ import promptfoo from '../../dist/src/index.js';
(async () => {
const results = await promptfoo.evaluate({
prompts: ['Rephrase this in French: {{body}}', 'Rephrase this like a pirate: {{body}}'],
providers: ['openai:gpt-3.5-turbo'],
providers: [
'openai:gpt-3.5-turbo',
(prompt) => {
// Call LLM here...
return {
output: '<LLM output>',
};
},
],
tests: [
{
vars: {
@@ -14,6 +22,19 @@ import promptfoo from '../../dist/src/index.js';
vars: {
body: "I'm hungry",
},
assert: [
{
type: 'javascript',
value: (output) => {
const pass = output.includes("J'ai faim");
return {
pass,
score: pass ? 1.0 : 0.0,
reason: pass ? 'Output contained substring' : 'Output did not contain substring',
};
},
},
],
},
],
});