@@ -33,87 +33,81 @@ describe("generateContent - tools", function () {
33
33
// eslint-disable-next-line no-restricted-properties
34
34
it ( "non-streaming, tools usage" , async ( ) => {
35
35
const genAI = new GoogleGenerativeAI ( process . env . GEMINI_API_KEY || "" ) ;
36
- const model = genAI . getGenerativeModel (
37
- {
38
- model : "gemini-1.5-flash-latest" ,
39
- tools : [
40
- {
41
- functionDeclarations : [
42
- {
43
- name : "find_movies" ,
44
- description :
45
- "find movie titles currently playing in theaters based on any description, genre, title words, etc." ,
46
- parameters : {
47
- type : SchemaType . OBJECT ,
48
- properties : {
49
- location : {
50
- type : SchemaType . STRING ,
51
- description :
52
- "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616" ,
53
- } ,
54
- description : {
55
- type : SchemaType . STRING ,
56
- description :
57
- "Any kind of description including category or genre, title words, attributes, etc." ,
58
- } ,
36
+ const model = genAI . getGenerativeModel ( {
37
+ model : "gemini-1.5-pro-latest" ,
38
+ tools : [
39
+ {
40
+ functionDeclarations : [
41
+ {
42
+ name : "find_movies" ,
43
+ description :
44
+ "find movie titles currently playing in theaters based on any description, genre, title words, etc." ,
45
+ parameters : {
46
+ type : SchemaType . OBJECT ,
47
+ properties : {
48
+ location : {
49
+ type : SchemaType . STRING ,
50
+ description : "The city and state, e.g. San Francisco, CA" ,
51
+ } ,
52
+ description : {
53
+ type : SchemaType . STRING ,
54
+ description :
55
+ "Any kind of description including category or genre, title words, attributes, etc." ,
59
56
} ,
60
- required : [ "description" ] ,
61
57
} ,
58
+ required : [ "description" ] ,
62
59
} ,
63
- {
64
- name : "find_theaters" ,
65
- description :
66
- "find theaters based on location and optionally movie title which are is currently playing in theaters" ,
67
- parameters : {
68
- type : SchemaType . OBJECT ,
69
- properties : {
70
- location : {
71
- type : SchemaType . STRING ,
72
- description :
73
- "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616" ,
74
- } ,
75
- movie : {
76
- type : SchemaType . STRING ,
77
- description : "Any movie title" ,
78
- } ,
60
+ } ,
61
+ {
62
+ name : "find_theaters" ,
63
+ description :
64
+ "find theaters based on location and optionally movie title which are is currently playing in theaters" ,
65
+ parameters : {
66
+ type : SchemaType . OBJECT ,
67
+ properties : {
68
+ location : {
69
+ type : SchemaType . STRING ,
70
+ description : "The city and state, e.g. San Francisco, CA" ,
71
+ } ,
72
+ movie : {
73
+ type : SchemaType . STRING ,
74
+ description : "Any movie title" ,
79
75
} ,
80
- required : [ "location" ] ,
81
76
} ,
77
+ required : [ "location" ] ,
82
78
} ,
83
- {
84
- name : "get_showtimes" ,
85
- description :
86
- "Find the start times for movies playing in a specific theater" ,
87
- parameters : {
88
- type : SchemaType . OBJECT ,
89
- properties : {
90
- location : {
91
- type : SchemaType . STRING ,
92
- description :
93
- "The city and state, e.g. San Francisco, CA or a zip code e.g. 95616" ,
94
- } ,
95
- movie : {
96
- type : SchemaType . STRING ,
97
- description : "Any movie title" ,
98
- } ,
99
- theater : {
100
- type : SchemaType . STRING ,
101
- description : "Name of the theater" ,
102
- } ,
103
- date : {
104
- type : SchemaType . STRING ,
105
- description : "Date for requested showtime" ,
106
- } ,
79
+ } ,
80
+ {
81
+ name : "get_showtimes" ,
82
+ description :
83
+ "Find the start times for movies playing in a specific theater" ,
84
+ parameters : {
85
+ type : SchemaType . OBJECT ,
86
+ properties : {
87
+ location : {
88
+ type : SchemaType . STRING ,
89
+ description : "The city and state, e.g. San Francisco, CA" ,
90
+ } ,
91
+ movie : {
92
+ type : SchemaType . STRING ,
93
+ description : "Any movie title" ,
94
+ } ,
95
+ theater : {
96
+ type : SchemaType . STRING ,
97
+ description : "Name of the theater" ,
98
+ } ,
99
+ date : {
100
+ type : SchemaType . STRING ,
101
+ description : "Date for requested showtime" ,
107
102
} ,
108
- required : [ "location" , "movie" , "theater" , "date" ] ,
109
103
} ,
104
+ required : [ "location" , "movie" , "theater" , "date" ] ,
110
105
} ,
111
- ] ,
112
- } ,
113
- ] ,
114
- } ,
115
- { apiVersion : "v1beta" } ,
116
- ) ;
106
+ } ,
107
+ ] ,
108
+ } ,
109
+ ] ,
110
+ } ) ;
117
111
118
112
const src1 = {
119
113
role : "user" ,
@@ -183,30 +177,27 @@ describe("generateContent - tools", function () {
183
177
} ) ;
184
178
it ( "streaming, tools usage" , async ( ) => {
185
179
const genAI = new GoogleGenerativeAI ( process . env . GEMINI_API_KEY || "" ) ;
186
- const model = genAI . getGenerativeModel (
187
- {
188
- model : "gemini-1.5-flash-latest" ,
189
- tools : [
190
- {
191
- functionDeclarations : [
192
- {
193
- name : "getTemperature" ,
194
- description :
195
- "Get current temperature in degrees Celsius in a given city" ,
196
- parameters : {
197
- type : SchemaType . OBJECT ,
198
- properties : {
199
- city : { type : SchemaType . STRING } ,
200
- } ,
201
- required : [ "city" ] ,
180
+ const model = genAI . getGenerativeModel ( {
181
+ model : "gemini-1.5-pro-latest" ,
182
+ tools : [
183
+ {
184
+ functionDeclarations : [
185
+ {
186
+ name : "getTemperature" ,
187
+ description :
188
+ "Get current temperature in degrees Celsius in a given city" ,
189
+ parameters : {
190
+ type : SchemaType . OBJECT ,
191
+ properties : {
192
+ city : { type : SchemaType . STRING } ,
202
193
} ,
194
+ required : [ "city" ] ,
203
195
} ,
204
- ] ,
205
- } ,
206
- ] ,
207
- } ,
208
- { apiVersion : "v1beta" } ,
209
- ) ;
196
+ } ,
197
+ ] ,
198
+ } ,
199
+ ] ,
200
+ } ) ;
210
201
211
202
const src1 : Content = {
212
203
role : "user" ,
@@ -259,7 +250,6 @@ describe("generateContent - tools", function () {
259
250
contents : [ src1 , src2 , fn1 , src3 , fn1 ] ,
260
251
} ) ;
261
252
const response = await result . response ;
262
- console . log ( response . text ( ) ) ;
263
253
expect ( response . text ( ) ) . to . match ( / ( \b s a m e \b | \b y e s \b ) / i) ;
264
254
} ) ;
265
255
} ) ;
0 commit comments