fix: conditionally import test models to resolve Node.js module errors in production (#1163)

This commit is contained in:
josh 2025-09-08 16:08:57 +01:00 committed by GitHub
parent 9829b99ebe
commit 60b09d170c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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'),