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 3
3
createDataStreamResponse ,
4
4
smoothStream ,
5
5
streamText ,
6
- wrapLanguageModel ,
7
6
} from 'ai' ;
8
7
9
8
import { auth } from '@/app/(auth)/auth' ;
@@ -29,21 +28,6 @@ import { getWeather } from '@/lib/ai/tools/get-weather';
29
28
30
29
export const maxDuration = 60 ;
31
30
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
-
47
31
export async function POST ( request : Request ) {
48
32
const {
49
33
id,
@@ -79,10 +63,18 @@ export async function POST(request: Request) {
79
63
execute : ( dataStream ) => {
80
64
const result = streamText ( {
81
65
model : myProvider . languageModel ( selectedChatModel ) ,
82
- system : systemPrompt ,
66
+ system : systemPrompt ( { selectedChatModel } ) ,
83
67
messages,
84
68
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
+ ] ,
86
78
experimental_transform : smoothStream ( { chunking : 'word' } ) ,
87
79
experimental_generateMessageId : generateUUID ,
88
80
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
34
34
export const regularPrompt =
35
35
'You are a friendly assistant! Keep your responses concise and helpful.' ;
36
36
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
+ } ;
38
48
39
49
export const codePrompt = `
40
50
You 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