A first integration test of the model call: Workers AI through the AI binding, behind the same `complete(messages)` interface as the sim's fake model. Opt-in (`pnpm test:model`) since it needs `wrangler login` and costs money. Red: src/model.ts doesn't exist yet. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
17 lines
539 B
TypeScript
17 lines
539 B
TypeScript
/** @file The model, called for real through the Workers AI binding. */
|
|
import { env } from "cloudflare:workers";
|
|
import { expect, test } from "vitest";
|
|
|
|
import { makeWorkersAiModel, MODEL } from "../src/model.ts";
|
|
|
|
test("the model counts the rs in strawberry", async () => {
|
|
const model = makeWorkersAiModel(env.AI, MODEL);
|
|
const reply = await model.complete([
|
|
{
|
|
role: "user",
|
|
content: 'How many times does the letter r appear in "strawberry"? Answer with just the number.',
|
|
},
|
|
]);
|
|
expect(reply.trim()).toMatch(/^3\b/);
|
|
});
|