2025-03-11 14:39:36 -07:00
|
|
|
import { simulateReadableStream } from 'ai';
|
2025-03-04 17:25:46 -08:00
|
|
|
import { MockLanguageModelV1 } from 'ai/test';
|
2025-03-11 14:39:36 -07:00
|
|
|
import { getResponseChunksByPrompt } from '@/tests/prompts/utils';
|
2025-03-04 17:25:46 -08:00
|
|
|
|
|
|
|
|
export const chatModel = new MockLanguageModelV1({
|
|
|
|
|
doGenerate: async () => ({
|
|
|
|
|
rawCall: { rawPrompt: null, rawSettings: {} },
|
|
|
|
|
finishReason: 'stop',
|
|
|
|
|
usage: { promptTokens: 10, completionTokens: 20 },
|
|
|
|
|
text: `Hello, world!`,
|
|
|
|
|
}),
|
|
|
|
|
doStream: async ({ prompt }) => ({
|
|
|
|
|
stream: simulateReadableStream({
|
2025-03-11 15:33:18 -07:00
|
|
|
chunkDelayInMs: 50,
|
|
|
|
|
initialDelayInMs: 100,
|
2025-03-04 17:25:46 -08:00
|
|
|
chunks: getResponseChunksByPrompt(prompt),
|
|
|
|
|
}),
|
|
|
|
|
rawCall: { rawPrompt: null, rawSettings: {} },
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const reasoningModel = new MockLanguageModelV1({
|
|
|
|
|
doGenerate: async () => ({
|
|
|
|
|
rawCall: { rawPrompt: null, rawSettings: {} },
|
|
|
|
|
finishReason: 'stop',
|
|
|
|
|
usage: { promptTokens: 10, completionTokens: 20 },
|
|
|
|
|
text: `Hello, world!`,
|
|
|
|
|
}),
|
2025-03-09 21:02:19 -07:00
|
|
|
doStream: async ({ prompt }) => ({
|
2025-03-04 17:25:46 -08:00
|
|
|
stream: simulateReadableStream({
|
2025-03-11 15:33:18 -07:00
|
|
|
chunkDelayInMs: 50,
|
|
|
|
|
initialDelayInMs: 500,
|
2025-03-09 21:02:19 -07:00
|
|
|
chunks: getResponseChunksByPrompt(prompt, true),
|
2025-03-04 17:25:46 -08:00
|
|
|
}),
|
|
|
|
|
rawCall: { rawPrompt: null, rawSettings: {} },
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const titleModel = new MockLanguageModelV1({
|
|
|
|
|
doGenerate: async () => ({
|
|
|
|
|
rawCall: { rawPrompt: null, rawSettings: {} },
|
|
|
|
|
finishReason: 'stop',
|
|
|
|
|
usage: { promptTokens: 10, completionTokens: 20 },
|
|
|
|
|
text: `This is a test title`,
|
|
|
|
|
}),
|
|
|
|
|
doStream: async () => ({
|
|
|
|
|
stream: simulateReadableStream({
|
2025-03-11 15:33:18 -07:00
|
|
|
chunkDelayInMs: 50,
|
|
|
|
|
initialDelayInMs: 100,
|
2025-03-04 17:25:46 -08:00
|
|
|
chunks: [
|
|
|
|
|
{ type: 'text-delta', textDelta: 'This is a test title' },
|
|
|
|
|
{
|
|
|
|
|
type: 'finish',
|
|
|
|
|
finishReason: 'stop',
|
|
|
|
|
logprobs: undefined,
|
|
|
|
|
usage: { completionTokens: 10, promptTokens: 3 },
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}),
|
|
|
|
|
rawCall: { rawPrompt: null, rawSettings: {} },
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const artifactModel = new MockLanguageModelV1({
|
|
|
|
|
doGenerate: async () => ({
|
|
|
|
|
rawCall: { rawPrompt: null, rawSettings: {} },
|
|
|
|
|
finishReason: 'stop',
|
|
|
|
|
usage: { promptTokens: 10, completionTokens: 20 },
|
|
|
|
|
text: `Hello, world!`,
|
|
|
|
|
}),
|
2025-03-11 14:39:36 -07:00
|
|
|
doStream: async ({ prompt }) => ({
|
2025-03-04 17:25:46 -08:00
|
|
|
stream: simulateReadableStream({
|
2025-03-11 15:33:18 -07:00
|
|
|
chunkDelayInMs: 50,
|
|
|
|
|
initialDelayInMs: 100,
|
2025-03-11 14:39:36 -07:00
|
|
|
chunks: getResponseChunksByPrompt(prompt),
|
2025-03-04 17:25:46 -08:00
|
|
|
}),
|
|
|
|
|
rawCall: { rawPrompt: null, rawSettings: {} },
|
|
|
|
|
}),
|
|
|
|
|
});
|