fix: replace test models with lightweight mocks to resolve module errors (#1164)
This commit is contained in:
parent
60b09d170c
commit
73dae0d10f
2 changed files with 39 additions and 1 deletions
38
lib/ai/models.mock.ts
Normal file
38
lib/ai/models.mock.ts
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
import { type LanguageModel } from 'ai';
|
||||||
|
|
||||||
|
const createMockModel = (): LanguageModel => {
|
||||||
|
return {
|
||||||
|
specificationVersion: 'v2',
|
||||||
|
provider: 'mock',
|
||||||
|
modelId: 'mock-model',
|
||||||
|
defaultObjectGenerationMode: 'tool',
|
||||||
|
supportedUrls: [],
|
||||||
|
supportsImageUrls: false,
|
||||||
|
supportsStructuredOutputs: false,
|
||||||
|
doGenerate: async () => ({
|
||||||
|
rawCall: { rawPrompt: null, rawSettings: {} },
|
||||||
|
finishReason: 'stop',
|
||||||
|
usage: { inputTokens: 10, outputTokens: 20, totalTokens: 30 },
|
||||||
|
content: [{ type: 'text', text: 'Hello, world!' }],
|
||||||
|
warnings: [],
|
||||||
|
}),
|
||||||
|
doStream: async () => ({
|
||||||
|
stream: new ReadableStream({
|
||||||
|
start(controller) {
|
||||||
|
controller.enqueue({
|
||||||
|
type: 'text-delta',
|
||||||
|
id: 'mock-id',
|
||||||
|
delta: 'Mock response',
|
||||||
|
});
|
||||||
|
controller.close();
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
rawCall: { rawPrompt: null, rawSettings: {} },
|
||||||
|
}),
|
||||||
|
} as unknown as LanguageModel;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const chatModel = createMockModel();
|
||||||
|
export const reasoningModel = createMockModel();
|
||||||
|
export const titleModel = createMockModel();
|
||||||
|
export const artifactModel = createMockModel();
|
||||||
|
|
@ -13,7 +13,7 @@ export const myProvider = isTestEnvironment
|
||||||
chatModel,
|
chatModel,
|
||||||
reasoningModel,
|
reasoningModel,
|
||||||
titleModel,
|
titleModel,
|
||||||
} = require('./models.test');
|
} = require('./models.mock');
|
||||||
return customProvider({
|
return customProvider({
|
||||||
languageModels: {
|
languageModels: {
|
||||||
'chat-model': chatModel,
|
'chat-model': chatModel,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue