From 60b09d170c7db143d0a95765cdad41cb315da29d Mon Sep 17 00:00:00 2001 From: josh <144584931+dancer@users.noreply.github.com> Date: Mon, 8 Sep 2025 16:08:57 +0100 Subject: [PATCH] fix: conditionally import test models to resolve Node.js module errors in production (#1163) --- lib/ai/providers.ts | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/ai/providers.ts b/lib/ai/providers.ts index 48f9b2d..edeade7 100644 --- a/lib/ai/providers.ts +++ b/lib/ai/providers.ts @@ -4,23 +4,25 @@ import { wrapLanguageModel, } from 'ai'; import { gateway } from '@ai-sdk/gateway'; -import { - artifactModel, - chatModel, - reasoningModel, - titleModel, -} from './models.test'; import { isTestEnvironment } from '../constants'; export const myProvider = isTestEnvironment - ? customProvider({ - languageModels: { - 'chat-model': chatModel, - 'chat-model-reasoning': reasoningModel, - 'title-model': titleModel, - 'artifact-model': artifactModel, - }, - }) + ? (() => { + const { + artifactModel, + chatModel, + reasoningModel, + titleModel, + } = require('./models.test'); + return customProvider({ + languageModels: { + 'chat-model': chatModel, + 'chat-model-reasoning': reasoningModel, + 'title-model': titleModel, + 'artifact-model': artifactModel, + }, + }); + })() : customProvider({ languageModels: { 'chat-model': gateway.languageModel('xai/grok-2-vision-1212'),