feat: v1 — persistent shell, model gateway, artifact improvements (#1462)
This commit is contained in:
parent
3651670fb9
commit
f9652b452a
161 changed files with 5166 additions and 8009 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import type { LanguageModelV3GenerateResult } from "@ai-sdk/provider";
|
||||
import { simulateReadableStream } from "ai";
|
||||
import { MockLanguageModelV3 } from "ai/test";
|
||||
import { getResponseChunksByPrompt } from "@/tests/prompts/utils";
|
||||
|
|
@ -7,13 +8,24 @@ const mockUsage = {
|
|||
outputTokens: { total: 20, text: 20, reasoning: 0 },
|
||||
};
|
||||
|
||||
const mockFinishReason = { unified: "stop" as const, raw: undefined };
|
||||
|
||||
const mockGenerateResult: LanguageModelV3GenerateResult = {
|
||||
finishReason: mockFinishReason,
|
||||
usage: mockUsage,
|
||||
content: [{ type: "text", text: "Hello, world!" }],
|
||||
warnings: [],
|
||||
};
|
||||
|
||||
const titleGenerateResult: LanguageModelV3GenerateResult = {
|
||||
finishReason: mockFinishReason,
|
||||
usage: mockUsage,
|
||||
content: [{ type: "text", text: "This is a test title" }],
|
||||
warnings: [],
|
||||
};
|
||||
|
||||
export const chatModel = new MockLanguageModelV3({
|
||||
doGenerate: async () => ({
|
||||
finishReason: "stop",
|
||||
usage: mockUsage,
|
||||
content: [{ type: "text", text: "Hello, world!" }],
|
||||
warnings: [],
|
||||
}),
|
||||
doGenerate: mockGenerateResult,
|
||||
doStream: async ({ prompt }) => ({
|
||||
stream: simulateReadableStream({
|
||||
chunkDelayInMs: 500,
|
||||
|
|
@ -24,12 +36,7 @@ export const chatModel = new MockLanguageModelV3({
|
|||
});
|
||||
|
||||
export const reasoningModel = new MockLanguageModelV3({
|
||||
doGenerate: async () => ({
|
||||
finishReason: "stop",
|
||||
usage: mockUsage,
|
||||
content: [{ type: "text", text: "Hello, world!" }],
|
||||
warnings: [],
|
||||
}),
|
||||
doGenerate: mockGenerateResult,
|
||||
doStream: async ({ prompt }) => ({
|
||||
stream: simulateReadableStream({
|
||||
chunkDelayInMs: 500,
|
||||
|
|
@ -40,42 +47,21 @@ export const reasoningModel = new MockLanguageModelV3({
|
|||
});
|
||||
|
||||
export const titleModel = new MockLanguageModelV3({
|
||||
doGenerate: async () => ({
|
||||
finishReason: "stop",
|
||||
usage: mockUsage,
|
||||
content: [{ type: "text", text: "This is a test title" }],
|
||||
warnings: [],
|
||||
}),
|
||||
doGenerate: titleGenerateResult,
|
||||
doStream: async () => ({
|
||||
stream: simulateReadableStream({
|
||||
chunkDelayInMs: 500,
|
||||
initialDelayInMs: 1000,
|
||||
chunks: [
|
||||
{ id: "1", type: "text-start" },
|
||||
{ id: "1", type: "text-delta", delta: "This is a test title" },
|
||||
{ id: "1", type: "text-end" },
|
||||
{ id: "1", type: "text-start" as const },
|
||||
{ id: "1", type: "text-delta" as const, delta: "This is a test title" },
|
||||
{ id: "1", type: "text-end" as const },
|
||||
{
|
||||
type: "finish",
|
||||
finishReason: "stop",
|
||||
type: "finish" as const,
|
||||
finishReason: mockFinishReason,
|
||||
usage: mockUsage,
|
||||
},
|
||||
],
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
export const artifactModel = new MockLanguageModelV3({
|
||||
doGenerate: async () => ({
|
||||
finishReason: "stop",
|
||||
usage: mockUsage,
|
||||
content: [{ type: "text", text: "Hello, world!" }],
|
||||
warnings: [],
|
||||
}),
|
||||
doStream: async ({ prompt }) => ({
|
||||
stream: simulateReadableStream({
|
||||
chunkDelayInMs: 50,
|
||||
initialDelayInMs: 100,
|
||||
chunks: getResponseChunksByPrompt(prompt),
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue