diff --git a/packages/evalite/readme.md b/packages/evalite/readme.md index 6a64bf9..21a1014 100644 --- a/packages/evalite/readme.md +++ b/packages/evalite/readme.md @@ -239,3 +239,30 @@ const result = await generateText({ > [!NOTE] > > `traceAISDKModel`, like `reportTrace`, is a no-op in production. + +### Streams + +You can handle streams in Evalite by returning a `ReadableStream` from your task. This means you can test functions like the AI SDK `streamText` function easily: + +```ts +import { evalite } from "evalite"; +import { streamText } from "ai"; +import { openai } from "@ai-sdk/openai"; +import { Factuality } from "autoevals"; + +evalite("My Eval", { + data: async () => { + return [{ input: "What is the capital of France?", expected: "Paris" }]; + }, + task: async (input) => { + const result = await streamText({ + model: openai("your-model"), + system: `Answer the question concisely.`, + prompt: input, + }); + + return result.textStream; + }, + scorers: [Factuality], +}); +```