From f50773e05a961c1c62107c22248e385ed6fb79fd Mon Sep 17 00:00:00 2001 From: Matt Pocock Date: Mon, 2 Dec 2024 12:15:35 +0000 Subject: [PATCH] Changed banner temporarily --- packages/evalite-vitest/src/reporter.ts | 8 +++- packages/example/src/basics.eval.ts | 36 +++++++++++++++ packages/example/src/index.eval.ts | 59 ------------------------- 3 files changed, 42 insertions(+), 61 deletions(-) create mode 100644 packages/example/src/basics.eval.ts delete mode 100644 packages/example/src/index.eval.ts diff --git a/packages/evalite-vitest/src/reporter.ts b/packages/evalite-vitest/src/reporter.ts index 14e212b..91eed35 100644 --- a/packages/evalite-vitest/src/reporter.ts +++ b/packages/evalite-vitest/src/reporter.ts @@ -26,9 +26,13 @@ export default class EvaliteReporter extends BasicReporter { this.ctx = ctx; this.start = performance.now(); + // this.ctx.logger.log( + // ` ${c.magenta(c.bold("EVALITE"))} ${c.dim("running on")} ` + + // c.cyan(`http://localhost:${c.bold(DEFAULT_SERVER_PORT)}/`) + // ); + this.ctx.logger.log(""); this.ctx.logger.log( - ` ${c.magenta(c.bold("EVALITE"))} ${c.dim("running on")} ` + - c.cyan(`http://localhost:${c.bold(DEFAULT_SERVER_PORT)}/`) + ` ${c.magenta(c.bold("EVALITE"))} ${c.dim("running...")}` ); this.ctx.logger.log(""); diff --git a/packages/example/src/basics.eval.ts b/packages/example/src/basics.eval.ts new file mode 100644 index 0000000..50d0fb2 --- /dev/null +++ b/packages/example/src/basics.eval.ts @@ -0,0 +1,36 @@ +import { openai } from "@ai-sdk/openai"; +import { generateText } from "ai"; +import { evalite, Levenshtein } from "evalite-vitest"; + +evalite("Test basics", { + data: async () => [ + { + input: `What's the capital of France?`, + expected: `Lille.`, + }, + { + input: `What's the capital of Germany?`, + expected: `Berlin.`, + }, + { + input: `What's the capital of Italy?`, + expected: `Rome.`, + }, + { + input: `What's the capital of the United States?`, + expected: `Washington, D.C.`, + }, + ], + task: async (input) => { + const result = await generateText({ + model: openai("gpt-3.5-turbo"), + system: ` + Answer the question concisely, in as few words as possible. + `, + prompt: input, + }); + + return result.text; + }, + scorers: [Levenshtein], +}); diff --git a/packages/example/src/index.eval.ts b/packages/example/src/index.eval.ts deleted file mode 100644 index efbde14..0000000 --- a/packages/example/src/index.eval.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { openai } from "@ai-sdk/openai"; -import { generateText } from "ai"; -import { evalite, Levenshtein } from "evalite-vitest"; - -evalite("Add 'world' to end of phrase", { - // Replace with your dataset - data: async () => [ - { - input: "Hello", - expected: "Hello World", - }, - { - input: "Hello Mr", - expected: "Hello Mr World", - }, - { - input: "World", - expected: "World World", - }, - { - input: "World World World World", - expected: "World World World World World", - }, - { - input: "", - expected: "World", - }, - ], - // Replace with your LLM call - task: async (input) => { - const result = await generateText({ - model: openai("gpt-3.5-turbo"), - system: ` - Add "World" to the end of the input. - When an empty prompt is encountered, return "World". - - Interesting - Interesting World - - - World - World World - - - - World - - - This is the best place in the - This is the best place in the World - - `, - prompt: input, - }); - - return result.text; - }, - scorers: [Levenshtein], -});