File tree Expand file tree Collapse file tree 2 files changed +21
-19
lines changed
Expand file tree Collapse file tree 2 files changed +21
-19
lines changed Original file line number Diff line number Diff line change 33 createDataStreamResponse ,
44 smoothStream ,
55 streamText ,
6- wrapLanguageModel ,
76} from 'ai' ;
87
98import { auth } from '@/app/(auth)/auth' ;
@@ -29,21 +28,6 @@ import { getWeather } from '@/lib/ai/tools/get-weather';
2928
3029export const maxDuration = 60 ;
3130
32- type AllowedTools =
33- | 'createDocument'
34- | 'updateDocument'
35- | 'requestSuggestions'
36- | 'getWeather' ;
37-
38- const blocksTools : AllowedTools [ ] = [
39- 'createDocument' ,
40- 'updateDocument' ,
41- 'requestSuggestions' ,
42- ] ;
43-
44- const weatherTools : AllowedTools [ ] = [ 'getWeather' ] ;
45- const allTools : AllowedTools [ ] = [ ...blocksTools , ...weatherTools ] ;
46-
4731export async function POST ( request : Request ) {
4832 const {
4933 id,
@@ -79,10 +63,18 @@ export async function POST(request: Request) {
7963 execute : ( dataStream ) => {
8064 const result = streamText ( {
8165 model : myProvider . languageModel ( selectedChatModel ) ,
82- system : systemPrompt ,
66+ system : systemPrompt ( { selectedChatModel } ) ,
8367 messages,
8468 maxSteps : 5 ,
85- experimental_activeTools : allTools ,
69+ experimental_activeTools :
70+ selectedChatModel === 'chat-model-reasoning'
71+ ? [ ]
72+ : [
73+ 'getWeather' ,
74+ 'createDocument' ,
75+ 'updateDocument' ,
76+ 'requestSuggestions' ,
77+ ] ,
8678 experimental_transform : smoothStream ( { chunking : 'word' } ) ,
8779 experimental_generateMessageId : generateUUID ,
8880 tools : {
Original file line number Diff line number Diff line change @@ -34,7 +34,17 @@ Do not update document right after creating it. Wait for user feedback or reques
3434export const regularPrompt =
3535 'You are a friendly assistant! Keep your responses concise and helpful.' ;
3636
37- export const systemPrompt = `${ regularPrompt } \n\n${ blocksPrompt } ` ;
37+ export const systemPrompt = ( {
38+ selectedChatModel,
39+ } : {
40+ selectedChatModel : string ;
41+ } ) => {
42+ if ( selectedChatModel === 'chat-model-reasoning' ) {
43+ return regularPrompt ;
44+ } else {
45+ return `${ regularPrompt } \n\n${ blocksPrompt } ` ;
46+ }
47+ } ;
3848
3949export const codePrompt = `
4050You are a Python code generator that creates self-contained, executable code snippets. When writing code:
You can’t perform that action at this time.
0 commit comments