feat: switch prompts based on selected chat model (#754)
This commit is contained in:
parent
c61d4f91d4
commit
711da0b94b
2 changed files with 21 additions and 19 deletions
|
|
@ -3,7 +3,6 @@ import {
|
|||
createDataStreamResponse,
|
||||
smoothStream,
|
||||
streamText,
|
||||
wrapLanguageModel,
|
||||
} from 'ai';
|
||||
|
||||
import { auth } from '@/app/(auth)/auth';
|
||||
|
|
@ -29,21 +28,6 @@ import { getWeather } from '@/lib/ai/tools/get-weather';
|
|||
|
||||
export const maxDuration = 60;
|
||||
|
||||
type AllowedTools =
|
||||
| 'createDocument'
|
||||
| 'updateDocument'
|
||||
| 'requestSuggestions'
|
||||
| 'getWeather';
|
||||
|
||||
const blocksTools: AllowedTools[] = [
|
||||
'createDocument',
|
||||
'updateDocument',
|
||||
'requestSuggestions',
|
||||
];
|
||||
|
||||
const weatherTools: AllowedTools[] = ['getWeather'];
|
||||
const allTools: AllowedTools[] = [...blocksTools, ...weatherTools];
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const {
|
||||
id,
|
||||
|
|
@ -79,10 +63,18 @@ export async function POST(request: Request) {
|
|||
execute: (dataStream) => {
|
||||
const result = streamText({
|
||||
model: myProvider.languageModel(selectedChatModel),
|
||||
system: systemPrompt,
|
||||
system: systemPrompt({ selectedChatModel }),
|
||||
messages,
|
||||
maxSteps: 5,
|
||||
experimental_activeTools: allTools,
|
||||
experimental_activeTools:
|
||||
selectedChatModel === 'chat-model-reasoning'
|
||||
? []
|
||||
: [
|
||||
'getWeather',
|
||||
'createDocument',
|
||||
'updateDocument',
|
||||
'requestSuggestions',
|
||||
],
|
||||
experimental_transform: smoothStream({ chunking: 'word' }),
|
||||
experimental_generateMessageId: generateUUID,
|
||||
tools: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue