mirror of
https://github.com/promptfoo/promptfoo.git
synced 2023-08-15 01:10:51 +03:00
update example
This commit is contained in:
@@ -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',
|
||||
};
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user