chatbot-template/lib/ai/providers.ts

35 lines
1,003 B
TypeScript
Raw Normal View History

2025-03-04 17:25:46 -08:00
import {
customProvider,
extractReasoningMiddleware,
wrapLanguageModel,
2025-03-17 16:54:40 -07:00
} from 'ai';
import { gateway } from '@ai-sdk/gateway';
2025-03-04 17:25:46 -08:00
import {
artifactModel,
chatModel,
reasoningModel,
titleModel,
2025-03-17 16:54:40 -07:00
} from './models.test';
import { isTestEnvironment } from '../constants';
2025-03-04 17:25:46 -08:00
export const myProvider = isTestEnvironment
? customProvider({
languageModels: {
2025-03-17 16:58:22 -07:00
'chat-model': chatModel,
2025-03-17 16:54:40 -07:00
'chat-model-reasoning': reasoningModel,
'title-model': titleModel,
'artifact-model': artifactModel,
2025-03-04 17:25:46 -08:00
},
})
: customProvider({
languageModels: {
'chat-model': gateway.languageModel('xai/grok-2-vision-1212'),
2025-03-17 16:54:40 -07:00
'chat-model-reasoning': wrapLanguageModel({
model: gateway.languageModel('xai/grok-3-mini'),
2025-03-17 16:54:40 -07:00
middleware: extractReasoningMiddleware({ tagName: 'think' }),
2025-03-04 17:25:46 -08:00
}),
'title-model': gateway.languageModel('xai/grok-2-1212'),
'artifact-model': gateway.languageModel('xai/grok-2-1212'),
2025-03-04 17:25:46 -08:00
},
});