Skip to content
Source
Sign inSign up

textGenerationOperations.test.ts

28 lines1.1 KB

1import { assert, it } from "@effect/vitest";
2import { ProviderInstanceId, TextGenerationError } from "@t3tools/contracts";
3import * as Effect from "effect/Effect";
4​
5import { decodeJsonReply, fromRunner } from "./textGenerationOperations.ts";
6​
7// regression: #23726 a reply that echoes the schema key replaced the seed title with "title"
8it.effect("fails a thread title reply that is only the schema key", () =>
9 Effect.gen(function* () {
10 const textGeneration = fromRunner("Stub", (request) =>
11 decodeJsonReply(request, "Stub", '{"title":"title","needsRefinement":false}'),
12 );
13​
14 const outcome = yield* textGeneration
15 .generateThreadTitle({
16 cwd: process.cwd(),
17 message: "$implement Issue #140",
18 modelSelection: {
19 instanceId: ProviderInstanceId.make("pi"),
20 model: "anthropic/claude-haiku-4-5",
21 },
22 })
23 .pipe(Effect.match({ onFailure: (error) => error, onSuccess: (result) => result }));
24​
25 assert.instanceOf(outcome, TextGenerationError);
26 assert.strictEqual(outcome.operation, "generateThreadTitle");
27 }),
28);