fix: conditionally import test models to resolve Node.js module errors in production (#1163)
This commit is contained in:
parent
9829b99ebe
commit
60b09d170c
1 changed files with 16 additions and 14 deletions
|
|
@ -4,23 +4,25 @@ import {
|
||||||
wrapLanguageModel,
|
wrapLanguageModel,
|
||||||
} from 'ai';
|
} from 'ai';
|
||||||
import { gateway } from '@ai-sdk/gateway';
|
import { gateway } from '@ai-sdk/gateway';
|
||||||
import {
|
import { isTestEnvironment } from '../constants';
|
||||||
|
|
||||||
|
export const myProvider = isTestEnvironment
|
||||||
|
? (() => {
|
||||||
|
const {
|
||||||
artifactModel,
|
artifactModel,
|
||||||
chatModel,
|
chatModel,
|
||||||
reasoningModel,
|
reasoningModel,
|
||||||
titleModel,
|
titleModel,
|
||||||
} from './models.test';
|
} = require('./models.test');
|
||||||
import { isTestEnvironment } from '../constants';
|
return customProvider({
|
||||||
|
|
||||||
export const myProvider = isTestEnvironment
|
|
||||||
? customProvider({
|
|
||||||
languageModels: {
|
languageModels: {
|
||||||
'chat-model': chatModel,
|
'chat-model': chatModel,
|
||||||
'chat-model-reasoning': reasoningModel,
|
'chat-model-reasoning': reasoningModel,
|
||||||
'title-model': titleModel,
|
'title-model': titleModel,
|
||||||
'artifact-model': artifactModel,
|
'artifact-model': artifactModel,
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
|
})()
|
||||||
: customProvider({
|
: customProvider({
|
||||||
languageModels: {
|
languageModels: {
|
||||||
'chat-model': gateway.languageModel('xai/grok-2-vision-1212'),
|
'chat-model': gateway.languageModel('xai/grok-2-vision-1212'),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue