🎄 merry christmas: ai sdk v6 beta + tool approval (#1361)

This commit is contained in:
josh 2025-12-19 23:24:24 +00:00 committed by GitHub
parent 6e5b883cf2
commit 4d3ba8d9fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 429 additions and 202 deletions

View file

@ -1,12 +1,16 @@
import { simulateReadableStream } from "ai";
import { MockLanguageModelV2 } from "ai/test";
import { MockLanguageModelV3 } from "ai/test";
import { getResponseChunksByPrompt } from "@/tests/prompts/utils";
export const chatModel = new MockLanguageModelV2({
const mockUsage = {
inputTokens: { total: 10, noCache: 10, cacheRead: 0, cacheWrite: 0 },
outputTokens: { total: 20, text: 20, reasoning: 0 },
};
export const chatModel = new MockLanguageModelV3({
doGenerate: async () => ({
rawCall: { rawPrompt: null, rawSettings: {} },
finishReason: "stop",
usage: { inputTokens: 10, outputTokens: 20, totalTokens: 30 },
usage: mockUsage,
content: [{ type: "text", text: "Hello, world!" }],
warnings: [],
}),
@ -16,15 +20,13 @@ export const chatModel = new MockLanguageModelV2({
initialDelayInMs: 1000,
chunks: getResponseChunksByPrompt(prompt),
}),
rawCall: { rawPrompt: null, rawSettings: {} },
}),
});
export const reasoningModel = new MockLanguageModelV2({
export const reasoningModel = new MockLanguageModelV3({
doGenerate: async () => ({
rawCall: { rawPrompt: null, rawSettings: {} },
finishReason: "stop",
usage: { inputTokens: 10, outputTokens: 20, totalTokens: 30 },
usage: mockUsage,
content: [{ type: "text", text: "Hello, world!" }],
warnings: [],
}),
@ -34,15 +36,13 @@ export const reasoningModel = new MockLanguageModelV2({
initialDelayInMs: 1000,
chunks: getResponseChunksByPrompt(prompt, true),
}),
rawCall: { rawPrompt: null, rawSettings: {} },
}),
});
export const titleModel = new MockLanguageModelV2({
export const titleModel = new MockLanguageModelV3({
doGenerate: async () => ({
rawCall: { rawPrompt: null, rawSettings: {} },
finishReason: "stop",
usage: { inputTokens: 10, outputTokens: 20, totalTokens: 30 },
usage: mockUsage,
content: [{ type: "text", text: "This is a test title" }],
warnings: [],
}),
@ -57,19 +57,17 @@ export const titleModel = new MockLanguageModelV2({
{
type: "finish",
finishReason: "stop",
usage: { inputTokens: 3, outputTokens: 10, totalTokens: 13 },
usage: mockUsage,
},
],
}),
rawCall: { rawPrompt: null, rawSettings: {} },
}),
});
export const artifactModel = new MockLanguageModelV2({
export const artifactModel = new MockLanguageModelV3({
doGenerate: async () => ({
rawCall: { rawPrompt: null, rawSettings: {} },
finishReason: "stop",
usage: { inputTokens: 10, outputTokens: 20, totalTokens: 30 },
usage: mockUsage,
content: [{ type: "text", text: "Hello, world!" }],
warnings: [],
}),
@ -79,6 +77,5 @@ export const artifactModel = new MockLanguageModelV2({
initialDelayInMs: 100,
chunks: getResponseChunksByPrompt(prompt),
}),
rawCall: { rawPrompt: null, rawSettings: {} },
}),
});