const TdPrompt = require('@tdprompt/td-prompt.js');
const GeminiClient = require('@tdprompt/genkit-client.js');
const GenkitModels = require('@tdprompt/genkit-models.js');
(new TdPrompt(apiModels)).benchmark(function (params) {
describe(`Restaurant orders agent - evaluating ${params?.model}`, function () {
let geminiClient, prompt, json;
before(async function () {
prompt = await readFile(path.join('.', 'src', 'prompt', `prompt-init-specs.md`), 'utf8');
prompt = ejs.compile(prompt)
geminiClient = new GeminiClient(params.apiKey);
geminiClient.apiModel = params.model
json = {}
});
describe('order creation', function () {
it('must send the prompt message to the LLM API', async function () {
const result = await geminiClient.send(prompt({
incomingMessage: `
I want a pepperoni pizza, add pepper on top, with a cocacola and a sprite with no ice,
also a side of nuggets and a chicken tenders,
2 ice creams, 3 chocolate ice cream add topping and sprinkles,
and 3 Caesar salads no salt
`,
}), this);
assert.ok(result?.text);
const response = jsonrepair(result.text);
assert.ok(response);
json = JSON.parse(response);
assert.ok(json?.data);
assert.ok(json?.resume);
});
it('must create an order with 8 items', async function () {
let expected = 8
assert.equal(json?.data?.customer, undefined);
assert.equal(json?.data?.phoneNumber, undefined);
assert.equal(json?.data?.menuItems?.length, expected, `the order must have ${expected} menu items`);
});
});
});
});