@@ -62,12 +62,21 @@ describe('GenerativeModel', () => {
62
62
it ( 'passes params through to generateContent' , async ( ) => {
63
63
const genModel = new GenerativeModel ( fakeVertexAI , {
64
64
model : 'my-model' ,
65
- tools : [ { functionDeclarations : [ { name : 'myfunc' } ] } ] ,
65
+ tools : [
66
+ {
67
+ functionDeclarations : [
68
+ {
69
+ name : 'myfunc' ,
70
+ description : 'mydesc'
71
+ }
72
+ ]
73
+ }
74
+ ] ,
66
75
toolConfig : { functionCallingConfig : { mode : FunctionCallingMode . NONE } } ,
67
76
systemInstruction : { role : 'system' , parts : [ { text : 'be friendly' } ] }
68
77
} ) ;
69
78
expect ( genModel . tools ?. length ) . to . equal ( 1 ) ;
70
- expect ( genModel . toolConfig ?. functionCallingConfig . mode ) . to . equal (
79
+ expect ( genModel . toolConfig ?. functionCallingConfig ? .mode ) . to . equal (
71
80
FunctionCallingMode . NONE
72
81
) ;
73
82
expect ( genModel . systemInstruction ?. parts [ 0 ] . text ) . to . equal ( 'be friendly' ) ;
@@ -122,12 +131,21 @@ describe('GenerativeModel', () => {
122
131
it ( 'generateContent overrides model values' , async ( ) => {
123
132
const genModel = new GenerativeModel ( fakeVertexAI , {
124
133
model : 'my-model' ,
125
- tools : [ { functionDeclarations : [ { name : 'myfunc' } ] } ] ,
134
+ tools : [
135
+ {
136
+ functionDeclarations : [
137
+ {
138
+ name : 'myfunc' ,
139
+ description : 'mydesc'
140
+ }
141
+ ]
142
+ }
143
+ ] ,
126
144
toolConfig : { functionCallingConfig : { mode : FunctionCallingMode . NONE } } ,
127
145
systemInstruction : { role : 'system' , parts : [ { text : 'be friendly' } ] }
128
146
} ) ;
129
147
expect ( genModel . tools ?. length ) . to . equal ( 1 ) ;
130
- expect ( genModel . toolConfig ?. functionCallingConfig . mode ) . to . equal (
148
+ expect ( genModel . toolConfig ?. functionCallingConfig ? .mode ) . to . equal (
131
149
FunctionCallingMode . NONE
132
150
) ;
133
151
expect ( genModel . systemInstruction ?. parts [ 0 ] . text ) . to . equal ( 'be friendly' ) ;
@@ -139,7 +157,13 @@ describe('GenerativeModel', () => {
139
157
) ;
140
158
await genModel . generateContent ( {
141
159
contents : [ { role : 'user' , parts : [ { text : 'hello' } ] } ] ,
142
- tools : [ { functionDeclarations : [ { name : 'otherfunc' } ] } ] ,
160
+ tools : [
161
+ {
162
+ functionDeclarations : [
163
+ { name : 'otherfunc' , description : 'otherdesc' }
164
+ ]
165
+ }
166
+ ] ,
143
167
toolConfig : { functionCallingConfig : { mode : FunctionCallingMode . AUTO } } ,
144
168
systemInstruction : { role : 'system' , parts : [ { text : 'be formal' } ] }
145
169
} ) ;
@@ -162,12 +186,14 @@ describe('GenerativeModel', () => {
162
186
it ( 'passes params through to chat.sendMessage' , async ( ) => {
163
187
const genModel = new GenerativeModel ( fakeVertexAI , {
164
188
model : 'my-model' ,
165
- tools : [ { functionDeclarations : [ { name : 'myfunc' } ] } ] ,
189
+ tools : [
190
+ { functionDeclarations : [ { name : 'myfunc' , description : 'mydesc' } ] }
191
+ ] ,
166
192
toolConfig : { functionCallingConfig : { mode : FunctionCallingMode . NONE } } ,
167
193
systemInstruction : { role : 'system' , parts : [ { text : 'be friendly' } ] }
168
194
} ) ;
169
195
expect ( genModel . tools ?. length ) . to . equal ( 1 ) ;
170
- expect ( genModel . toolConfig ?. functionCallingConfig . mode ) . to . equal (
196
+ expect ( genModel . toolConfig ?. functionCallingConfig ? .mode ) . to . equal (
171
197
FunctionCallingMode . NONE
172
198
) ;
173
199
expect ( genModel . systemInstruction ?. parts [ 0 ] . text ) . to . equal ( 'be friendly' ) ;
@@ -222,12 +248,14 @@ describe('GenerativeModel', () => {
222
248
it ( 'startChat overrides model values' , async ( ) => {
223
249
const genModel = new GenerativeModel ( fakeVertexAI , {
224
250
model : 'my-model' ,
225
- tools : [ { functionDeclarations : [ { name : 'myfunc' } ] } ] ,
251
+ tools : [
252
+ { functionDeclarations : [ { name : 'myfunc' , description : 'mydesc' } ] }
253
+ ] ,
226
254
toolConfig : { functionCallingConfig : { mode : FunctionCallingMode . NONE } } ,
227
255
systemInstruction : { role : 'system' , parts : [ { text : 'be friendly' } ] }
228
256
} ) ;
229
257
expect ( genModel . tools ?. length ) . to . equal ( 1 ) ;
230
- expect ( genModel . toolConfig ?. functionCallingConfig . mode ) . to . equal (
258
+ expect ( genModel . toolConfig ?. functionCallingConfig ? .mode ) . to . equal (
231
259
FunctionCallingMode . NONE
232
260
) ;
233
261
expect ( genModel . systemInstruction ?. parts [ 0 ] . text ) . to . equal ( 'be friendly' ) ;
@@ -239,7 +267,13 @@ describe('GenerativeModel', () => {
239
267
) ;
240
268
await genModel
241
269
. startChat ( {
242
- tools : [ { functionDeclarations : [ { name : 'otherfunc' } ] } ] ,
270
+ tools : [
271
+ {
272
+ functionDeclarations : [
273
+ { name : 'otherfunc' , description : 'otherdesc' }
274
+ ]
275
+ }
276
+ ] ,
243
277
toolConfig : {
244
278
functionCallingConfig : { mode : FunctionCallingMode . AUTO }
245
279
} ,
0 commit comments