@@ -16,15 +16,17 @@ namespace SemanticKernel.IntegrationTests.Connectors.Google.Gemini;
16
16
17
17
public sealed class GeminiFunctionCallingTests ( ITestOutputHelper output ) : TestsBase ( output )
18
18
{
19
- [ RetryTheory ]
20
- [ InlineData ( ServiceType . GoogleAI , Skip = "This test is for manual verification." ) ]
21
- [ InlineData ( ServiceType . VertexAI , Skip = "This test is for manual verification." ) ]
22
- public async Task ChatGenerationEnabledFunctionsShouldReturnFunctionToCallAsync ( ServiceType serviceType )
19
+ private const string SkipMessage = "This test is for manual verification." ;
20
+
21
+ [ RetryTheory ( Skip = SkipMessage ) ]
22
+ [ InlineData ( ServiceType . GoogleAI , true ) ]
23
+ [ InlineData ( ServiceType . VertexAI , false ) ]
24
+ public async Task ChatGenerationEnabledFunctionsShouldReturnFunctionToCallAsync ( ServiceType serviceType , bool isBeta )
23
25
{
24
26
// Arrange
25
27
var kernel = new Kernel ( ) ;
26
28
kernel . ImportPluginFromType < CustomerPlugin > ( nameof ( CustomerPlugin ) ) ;
27
- var sut = this . GetChatService ( serviceType ) ;
29
+ var sut = this . GetChatService ( serviceType , isBeta ) ;
28
30
var chatHistory = new ChatHistory ( ) ;
29
31
chatHistory . AddUserMessage ( "Hello, could you show me list of customers?" ) ;
30
32
var executionSettings = new GeminiPromptExecutionSettings ( )
@@ -44,15 +46,15 @@ public async Task ChatGenerationEnabledFunctionsShouldReturnFunctionToCallAsync(
44
46
item . FullyQualifiedName == $ "{ nameof ( CustomerPlugin ) } { GeminiFunction . NameSeparator } { nameof ( CustomerPlugin . GetCustomers ) } ") ;
45
47
}
46
48
47
- [ RetryTheory ]
48
- [ InlineData ( ServiceType . GoogleAI , Skip = "This test is for manual verification." ) ]
49
- [ InlineData ( ServiceType . VertexAI , Skip = "This test is for manual verification." ) ]
50
- public async Task ChatStreamingEnabledFunctionsShouldReturnFunctionToCallAsync ( ServiceType serviceType )
49
+ [ RetryTheory ( Skip = SkipMessage ) ]
50
+ [ InlineData ( ServiceType . GoogleAI , true ) ]
51
+ [ InlineData ( ServiceType . VertexAI , false ) ]
52
+ public async Task ChatStreamingEnabledFunctionsShouldReturnFunctionToCallAsync ( ServiceType serviceType , bool isBeta )
51
53
{
52
54
// Arrange
53
55
var kernel = new Kernel ( ) ;
54
56
kernel . ImportPluginFromType < CustomerPlugin > ( nameof ( CustomerPlugin ) ) ;
55
- var sut = this . GetChatService ( serviceType ) ;
57
+ var sut = this . GetChatService ( serviceType , isBeta ) ;
56
58
var chatHistory = new ChatHistory ( ) ;
57
59
chatHistory . AddUserMessage ( "Hello, could you show me list of customers?" ) ;
58
60
var executionSettings = new GeminiPromptExecutionSettings ( )
@@ -74,15 +76,15 @@ public async Task ChatStreamingEnabledFunctionsShouldReturnFunctionToCallAsync(S
74
76
item . FullyQualifiedName == $ "{ nameof ( CustomerPlugin ) } { GeminiFunction . NameSeparator } { nameof ( CustomerPlugin . GetCustomers ) } ") ;
75
77
}
76
78
77
- [ RetryTheory ]
78
- [ InlineData ( ServiceType . GoogleAI , Skip = "This test is for manual verification." ) ]
79
- [ InlineData ( ServiceType . VertexAI , Skip = "This test is for manual verification." ) ]
80
- public async Task ChatGenerationAutoInvokeShouldCallOneFunctionAndReturnResponseAsync ( ServiceType serviceType )
79
+ [ RetryTheory ( Skip = SkipMessage ) ]
80
+ [ InlineData ( ServiceType . GoogleAI , true ) ]
81
+ [ InlineData ( ServiceType . VertexAI , false ) ]
82
+ public async Task ChatGenerationAutoInvokeShouldCallOneFunctionAndReturnResponseAsync ( ServiceType serviceType , bool isBeta )
81
83
{
82
84
// Arrange
83
85
var kernel = new Kernel ( ) ;
84
86
kernel . ImportPluginFromType < CustomerPlugin > ( "CustomerPlugin" ) ;
85
- var sut = this . GetChatService ( serviceType ) ;
87
+ var sut = this . GetChatService ( serviceType , isBeta ) ;
86
88
var chatHistory = new ChatHistory ( ) ;
87
89
chatHistory . AddUserMessage ( "Hello, could you show me list of customers?" ) ;
88
90
var executionSettings = new GeminiPromptExecutionSettings ( )
@@ -101,15 +103,15 @@ public async Task ChatGenerationAutoInvokeShouldCallOneFunctionAndReturnResponse
101
103
Assert . Contains ( "Steve Smith" , response . Content , StringComparison . OrdinalIgnoreCase ) ;
102
104
}
103
105
104
- [ RetryTheory ]
105
- [ InlineData ( ServiceType . GoogleAI , Skip = "This test is for manual verification." ) ]
106
- [ InlineData ( ServiceType . VertexAI , Skip = "This test is for manual verification." ) ]
107
- public async Task ChatStreamingAutoInvokeShouldCallOneFunctionAndReturnResponseAsync ( ServiceType serviceType )
106
+ [ RetryTheory ( Skip = SkipMessage ) ]
107
+ [ InlineData ( ServiceType . GoogleAI , true ) ]
108
+ [ InlineData ( ServiceType . VertexAI , false ) ]
109
+ public async Task ChatStreamingAutoInvokeShouldCallOneFunctionAndReturnResponseAsync ( ServiceType serviceType , bool isBeta )
108
110
{
109
111
// Arrange
110
112
var kernel = new Kernel ( ) ;
111
113
kernel . ImportPluginFromType < CustomerPlugin > ( "CustomerPlugin" ) ;
112
- var sut = this . GetChatService ( serviceType ) ;
114
+ var sut = this . GetChatService ( serviceType , isBeta ) ;
113
115
var chatHistory = new ChatHistory ( ) ;
114
116
chatHistory . AddUserMessage ( "Hello, could you show me list of customers?" ) ;
115
117
var executionSettings = new GeminiPromptExecutionSettings ( )
@@ -130,15 +132,15 @@ public async Task ChatStreamingAutoInvokeShouldCallOneFunctionAndReturnResponseA
130
132
Assert . Contains ( "Steve Smith" , content , StringComparison . OrdinalIgnoreCase ) ;
131
133
}
132
134
133
- [ RetryTheory ]
134
- [ InlineData ( ServiceType . GoogleAI , Skip = "This test is for manual verification." ) ]
135
- [ InlineData ( ServiceType . VertexAI , Skip = "This test is for manual verification." ) ]
136
- public async Task ChatGenerationAutoInvokeShouldCallTwoFunctionsAndReturnResponseAsync ( ServiceType serviceType )
135
+ [ RetryTheory ( Skip = SkipMessage ) ]
136
+ [ InlineData ( ServiceType . GoogleAI , true ) ]
137
+ [ InlineData ( ServiceType . VertexAI , false ) ]
138
+ public async Task ChatGenerationAutoInvokeShouldCallTwoFunctionsAndReturnResponseAsync ( ServiceType serviceType , bool isBeta )
137
139
{
138
140
// Arrange
139
141
var kernel = new Kernel ( ) ;
140
142
kernel . ImportPluginFromType < CustomerPlugin > ( "CustomerPlugin" ) ;
141
- var sut = this . GetChatService ( serviceType ) ;
143
+ var sut = this . GetChatService ( serviceType , isBeta ) ;
142
144
var chatHistory = new ChatHistory ( ) ;
143
145
chatHistory . AddUserMessage ( "Hello, could you show me list of customers first and next return age of Anna customer?" ) ;
144
146
var executionSettings = new GeminiPromptExecutionSettings ( )
@@ -155,15 +157,15 @@ public async Task ChatGenerationAutoInvokeShouldCallTwoFunctionsAndReturnRespons
155
157
Assert . Contains ( "28" , response . Content , StringComparison . OrdinalIgnoreCase ) ;
156
158
}
157
159
158
- [ RetryTheory ]
159
- [ InlineData ( ServiceType . GoogleAI , Skip = "This test is for manual verification." ) ]
160
- [ InlineData ( ServiceType . VertexAI , Skip = "This test is for manual verification." ) ]
161
- public async Task ChatStreamingAutoInvokeShouldCallTwoFunctionsAndReturnResponseAsync ( ServiceType serviceType )
160
+ [ RetryTheory ( Skip = SkipMessage ) ]
161
+ [ InlineData ( ServiceType . GoogleAI , true ) ]
162
+ [ InlineData ( ServiceType . VertexAI , false ) ]
163
+ public async Task ChatStreamingAutoInvokeShouldCallTwoFunctionsAndReturnResponseAsync ( ServiceType serviceType , bool isBeta )
162
164
{
163
165
// Arrange
164
166
var kernel = new Kernel ( ) ;
165
167
kernel . ImportPluginFromType < CustomerPlugin > ( "CustomerPlugin" ) ;
166
- var sut = this . GetChatService ( serviceType ) ;
168
+ var sut = this . GetChatService ( serviceType , isBeta ) ;
167
169
var chatHistory = new ChatHistory ( ) ;
168
170
chatHistory . AddUserMessage ( "Hello, could you show me list of customers first and next return age of Anna customer?" ) ;
169
171
var executionSettings = new GeminiPromptExecutionSettings ( )
@@ -182,16 +184,16 @@ public async Task ChatStreamingAutoInvokeShouldCallTwoFunctionsAndReturnResponse
182
184
Assert . Contains ( "28" , content , StringComparison . OrdinalIgnoreCase ) ;
183
185
}
184
186
185
- [ RetryTheory ]
186
- [ InlineData ( ServiceType . GoogleAI , Skip = "This test is for manual verification." ) ]
187
- [ InlineData ( ServiceType . VertexAI , Skip = "This test is for manual verification." ) ]
188
- public async Task ChatGenerationAutoInvokeShouldCallFunctionsMultipleTimesAndReturnResponseAsync ( ServiceType serviceType )
187
+ [ RetryTheory ( Skip = SkipMessage ) ]
188
+ [ InlineData ( ServiceType . GoogleAI , true ) ]
189
+ [ InlineData ( ServiceType . VertexAI , false ) ]
190
+ public async Task ChatGenerationAutoInvokeShouldCallFunctionsMultipleTimesAndReturnResponseAsync ( ServiceType serviceType , bool isBeta )
189
191
{
190
192
// Arrange
191
193
var kernel = new Kernel ( ) ;
192
194
kernel . ImportPluginFromType < CustomerPlugin > ( "CustomerPlugin" ) ;
193
195
kernel . ImportPluginFromType < MathPlugin > ( "MathPlugin" ) ;
194
- var sut = this . GetChatService ( serviceType ) ;
196
+ var sut = this . GetChatService ( serviceType , isBeta ) ;
195
197
var chatHistory = new ChatHistory ( ) ;
196
198
chatHistory . AddUserMessage (
197
199
"Get list of customers and next get customers ages and at the end calculate the sum of ages of all customers." ) ;
@@ -209,16 +211,16 @@ public async Task ChatGenerationAutoInvokeShouldCallFunctionsMultipleTimesAndRet
209
211
Assert . Contains ( "105" , response . Content , StringComparison . OrdinalIgnoreCase ) ;
210
212
}
211
213
212
- [ RetryTheory ]
213
- [ InlineData ( ServiceType . GoogleAI , Skip = "This test is for manual verification." ) ]
214
- [ InlineData ( ServiceType . VertexAI , Skip = "This test is for manual verification." ) ]
215
- public async Task ChatStreamingAutoInvokeShouldCallFunctionsMultipleTimesAndReturnResponseAsync ( ServiceType serviceType )
214
+ [ RetryTheory ( Skip = SkipMessage ) ]
215
+ [ InlineData ( ServiceType . GoogleAI , true ) ]
216
+ [ InlineData ( ServiceType . VertexAI , false ) ]
217
+ public async Task ChatStreamingAutoInvokeShouldCallFunctionsMultipleTimesAndReturnResponseAsync ( ServiceType serviceType , bool isBeta )
216
218
{
217
219
// Arrange
218
220
var kernel = new Kernel ( ) ;
219
221
kernel . ImportPluginFromType < CustomerPlugin > ( "CustomerPlugin" ) ;
220
222
kernel . ImportPluginFromType < MathPlugin > ( "MathPlugin" ) ;
221
- var sut = this . GetChatService ( serviceType ) ;
223
+ var sut = this . GetChatService ( serviceType , isBeta ) ;
222
224
var chatHistory = new ChatHistory ( ) ;
223
225
chatHistory . AddUserMessage (
224
226
"Get list of customers and next get customers ages and at the end calculate the sum of ages of all customers." ) ;
@@ -238,14 +240,14 @@ public async Task ChatStreamingAutoInvokeShouldCallFunctionsMultipleTimesAndRetu
238
240
Assert . Contains ( "105" , content , StringComparison . OrdinalIgnoreCase ) ;
239
241
}
240
242
241
- [ RetryTheory ]
242
- [ InlineData ( ServiceType . GoogleAI , Skip = "This test is for manual verification." ) ]
243
- [ InlineData ( ServiceType . VertexAI , Skip = "This test is for manual verification." ) ]
244
- public async Task ChatGenerationAutoInvokeNullablePropertiesWorksAsync ( ServiceType serviceType )
243
+ [ RetryTheory ( Skip = SkipMessage ) ]
244
+ [ InlineData ( ServiceType . GoogleAI , true ) ]
245
+ [ InlineData ( ServiceType . VertexAI , false ) ]
246
+ public async Task ChatGenerationAutoInvokeNullablePropertiesWorksAsync ( ServiceType serviceType , bool isBeta )
245
247
{
246
248
var kernel = new Kernel ( ) ;
247
249
kernel . ImportPluginFromType < NullableTestPlugin > ( ) ;
248
- var sut = this . GetChatService ( serviceType ) ;
250
+ var sut = this . GetChatService ( serviceType , isBeta ) ;
249
251
250
252
var executionSettings = new GeminiPromptExecutionSettings ( )
251
253
{
@@ -260,16 +262,16 @@ public async Task ChatGenerationAutoInvokeNullablePropertiesWorksAsync(ServiceTy
260
262
Assert . NotNull ( response ) ;
261
263
}
262
264
263
- [ RetryTheory ]
264
- [ InlineData ( ServiceType . GoogleAI , Skip = "This test is for manual verification." ) ]
265
- [ InlineData ( ServiceType . VertexAI , Skip = "This test is for manual verification." ) ]
266
- public async Task ChatGenerationAutoInvokeTwoPluginsShouldGetDateAndReturnTasksByDateParamAndReturnResponseAsync ( ServiceType serviceType )
265
+ [ RetryTheory ( Skip = SkipMessage ) ]
266
+ [ InlineData ( ServiceType . GoogleAI , true ) ]
267
+ [ InlineData ( ServiceType . VertexAI , false ) ]
268
+ public async Task ChatGenerationAutoInvokeTwoPluginsShouldGetDateAndReturnTasksByDateParamAndReturnResponseAsync ( ServiceType serviceType , bool isBeta )
267
269
{
268
270
// Arrange
269
271
var kernel = new Kernel ( ) ;
270
272
kernel . ImportPluginFromType < TaskPlugin > ( nameof ( TaskPlugin ) ) ;
271
273
kernel . ImportPluginFromType < DatePlugin > ( nameof ( DatePlugin ) ) ;
272
- var sut = this . GetChatService ( serviceType ) ;
274
+ var sut = this . GetChatService ( serviceType , isBeta ) ;
273
275
var chatHistory = new ChatHistory ( ) ;
274
276
chatHistory . AddUserMessage ( "How many tasks I have to do today? Show me count of tasks for today and date." ) ;
275
277
var executionSettings = new GeminiPromptExecutionSettings ( )
@@ -286,16 +288,16 @@ public async Task ChatGenerationAutoInvokeTwoPluginsShouldGetDateAndReturnTasksB
286
288
Assert . Contains ( "5" , response . Content , StringComparison . OrdinalIgnoreCase ) ;
287
289
}
288
290
289
- [ RetryTheory ]
290
- [ InlineData ( ServiceType . GoogleAI , Skip = "This test is for manual verification." ) ]
291
- [ InlineData ( ServiceType . VertexAI , Skip = "This test is for manual verification." ) ]
292
- public async Task ChatStreamingAutoInvokeTwoPluginsShouldGetDateAndReturnTasksByDateParamAndReturnResponseAsync ( ServiceType serviceType )
291
+ [ RetryTheory ( Skip = SkipMessage ) ]
292
+ [ InlineData ( ServiceType . GoogleAI , true ) ]
293
+ [ InlineData ( ServiceType . VertexAI , false ) ]
294
+ public async Task ChatStreamingAutoInvokeTwoPluginsShouldGetDateAndReturnTasksByDateParamAndReturnResponseAsync ( ServiceType serviceType , bool isBeta )
293
295
{
294
296
// Arrange
295
297
var kernel = new Kernel ( ) ;
296
298
kernel . ImportPluginFromType < TaskPlugin > ( nameof ( TaskPlugin ) ) ;
297
299
kernel . ImportPluginFromType < DatePlugin > ( nameof ( DatePlugin ) ) ;
298
- var sut = this . GetChatService ( serviceType ) ;
300
+ var sut = this . GetChatService ( serviceType , isBeta ) ;
299
301
var chatHistory = new ChatHistory ( ) ;
300
302
chatHistory . AddUserMessage ( "How many tasks I have to do today? Show me count of tasks for today and date." ) ;
301
303
var executionSettings = new GeminiPromptExecutionSettings ( )
@@ -314,18 +316,18 @@ public async Task ChatStreamingAutoInvokeTwoPluginsShouldGetDateAndReturnTasksBy
314
316
Assert . Contains ( "5" , content , StringComparison . OrdinalIgnoreCase ) ;
315
317
}
316
318
317
- [ RetryTheory ]
318
- [ InlineData ( ServiceType . GoogleAI , Skip = "This test is for manual verification." ) ]
319
- [ InlineData ( ServiceType . VertexAI , Skip = "This test is for manual verification." ) ]
320
- public async Task ChatGenerationAutoInvokeShouldCallFunctionWithEnumParameterAndReturnResponseAsync ( ServiceType serviceType )
319
+ [ RetryTheory ( Skip = SkipMessage ) ]
320
+ [ InlineData ( ServiceType . GoogleAI , true ) ]
321
+ [ InlineData ( ServiceType . VertexAI , false ) ]
322
+ public async Task ChatGenerationAutoInvokeShouldCallFunctionWithEnumParameterAndReturnResponseAsync ( ServiceType serviceType , bool isBeta )
321
323
{
322
324
// Arrange
323
325
var kernel = new Kernel ( ) ;
324
326
var timeProvider = new FakeTimeProvider ( ) ;
325
327
timeProvider . SetUtcNow ( new DateTimeOffset ( new DateTime ( 2024 , 4 , 24 ) ) ) ; // Wednesday
326
328
var timePlugin = new TimePlugin ( timeProvider ) ;
327
329
kernel . ImportPluginFromObject ( timePlugin , nameof ( TimePlugin ) ) ;
328
- var sut = this . GetChatService ( serviceType ) ;
330
+ var sut = this . GetChatService ( serviceType , isBeta ) ;
329
331
var chatHistory = new ChatHistory ( ) ;
330
332
chatHistory . AddUserMessage ( "When was last friday? Show the date in format DD.MM.YYYY for example: 15.07.2019" ) ;
331
333
var executionSettings = new GeminiPromptExecutionSettings ( )
@@ -342,18 +344,18 @@ public async Task ChatGenerationAutoInvokeShouldCallFunctionWithEnumParameterAnd
342
344
Assert . Contains ( "19.04.2024" , response . Content , StringComparison . OrdinalIgnoreCase ) ;
343
345
}
344
346
345
- [ RetryTheory ]
346
- [ InlineData ( ServiceType . GoogleAI , Skip = "This test is for manual verification." ) ]
347
- [ InlineData ( ServiceType . VertexAI , Skip = "This test is for manual verification." ) ]
348
- public async Task ChatStreamingAutoInvokeShouldCallFunctionWithEnumParameterAndReturnResponseAsync ( ServiceType serviceType )
347
+ [ RetryTheory ( Skip = SkipMessage ) ]
348
+ [ InlineData ( ServiceType . GoogleAI , true ) ]
349
+ [ InlineData ( ServiceType . VertexAI , false ) ]
350
+ public async Task ChatStreamingAutoInvokeShouldCallFunctionWithEnumParameterAndReturnResponseAsync ( ServiceType serviceType , bool isBeta )
349
351
{
350
352
// Arrange
351
353
var kernel = new Kernel ( ) ;
352
354
var timeProvider = new FakeTimeProvider ( ) ;
353
355
timeProvider . SetUtcNow ( new DateTimeOffset ( new DateTime ( 2024 , 4 , 24 ) ) ) ; // Wednesday
354
356
var timePlugin = new TimePlugin ( timeProvider ) ;
355
357
kernel . ImportPluginFromObject ( timePlugin , nameof ( TimePlugin ) ) ;
356
- var sut = this . GetChatService ( serviceType ) ;
358
+ var sut = this . GetChatService ( serviceType , isBeta ) ;
357
359
var chatHistory = new ChatHistory ( ) ;
358
360
chatHistory . AddUserMessage ( "When was last friday? Show the date in format DD.MM.YYYY for example: 15.07.2019" ) ;
359
361
var executionSettings = new GeminiPromptExecutionSettings ( )
0 commit comments