Skip to content

Commit

Permalink
Added traces to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpocock committed Dec 5, 2024
1 parent 5989329 commit 2c55cfe
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
7 changes: 2 additions & 5 deletions packages/example/src/content-generation.eval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createScorer, evalite } from "evalite";
import { createStorage } from "unstorage";
import fsDriver from "unstorage/drivers/fs";
import { cacheModel } from "./cache-model";
import { traceAISDKModel } from "evalite/ai-sdk";

const storage = createStorage({
driver: (fsDriver as any)({
Expand All @@ -23,18 +24,14 @@ evalite("Content generation", {
{
input: 'Write a tweet about "TypeScript is a superset of JavaScript."',
},
{
input:
"Write a short article about whether TypeScript is a linter or not. Use markdown formatting.",
},
{
input: `Write an article about TypeScript's basic types, like string and number.`,
},
];
},
task: async (input) => {
const result = await generateText({
model: cacheModel(openai("gpt-4o-mini"), storage),
model: traceAISDKModel(cacheModel(openai("gpt-4o-mini"), storage)),
prompt: input,
system: `
You are a helpful social media assistant.
Expand Down
3 changes: 2 additions & 1 deletion packages/example/src/example.2.eval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createStorage } from "unstorage";
import fsDriver from "unstorage/drivers/fs";
import { Factuality, Levenshtein } from "autoevals";
import { cacheModel } from "./cache-model.js";
import { traceAISDKModel } from "evalite/ai-sdk";

const storage = createStorage({
driver: (fsDriver as any)({
Expand Down Expand Up @@ -41,7 +42,7 @@ evalite("Test Capitals 2", {
],
task: async (input) => {
const result = await generateText({
model: cacheModel(openai("gpt-3.5-turbo"), storage),
model: traceAISDKModel(cacheModel(openai("gpt-3.5-turbo"), storage)),
system: `
Answer the question concisely, in as few words as possible.
`,
Expand Down
3 changes: 2 additions & 1 deletion packages/example/src/example.eval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createStorage } from "unstorage";
import fsDriver from "unstorage/drivers/fs";
import { Factuality, Levenshtein } from "autoevals";
import { cacheModel } from "./cache-model.js";
import { traceAISDKModel } from "evalite/ai-sdk";

const storage = createStorage({
driver: (fsDriver as any)({
Expand Down Expand Up @@ -53,7 +54,7 @@ evalite("Test Capitals", {
],
task: async (input) => {
const result = await generateText({
model: cacheModel(openai("gpt-3.5-turbo"), storage),
model: traceAISDKModel(cacheModel(openai("gpt-3.5-turbo"), storage)),
system: `
Answer the question concisely. Answer in as few words as possible.
Remove full stops from the end of the output.
Expand Down
5 changes: 3 additions & 2 deletions packages/example/src/word-counter.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { openai } from "@ai-sdk/openai";
import { generateText } from "ai";
import { evalite, numericDifference } from "evalite";
import { NumericDiff } from "autoevals";
import { evalite } from "evalite";

evalite("Sentence counter", {
// Replace with your dataset
Expand Down Expand Up @@ -91,5 +92,5 @@ evalite("Sentence counter", {

return Number(wordCountResult.text);
},
scorers: [numericDifference],
scorers: [NumericDiff],
});

0 comments on commit 2c55cfe

Please sign in to comment.