7
7
using Microsoft . SemanticKernel ;
8
8
using Microsoft . SemanticKernel . ChatCompletion ;
9
9
using SemanticKernel . IntegrationTests . TestSettings ;
10
+ using xRetry ;
10
11
using Xunit ;
11
12
12
13
using ChatMessageContent = Microsoft . SemanticKernel . ChatMessageContent ;
@@ -142,7 +143,7 @@ public async Task ConnectorAgnosticFunctionCallingModelClassesCanBeUsedForManual
142
143
Assert . Contains ( "rain" , messageContent . Content , StringComparison . InvariantCultureIgnoreCase ) ;
143
144
}
144
145
145
- [ Fact ( Skip = "For manual verification only" ) ]
146
+ [ RetryFact ( Skip = "For manual verification only" ) ]
146
147
public async Task ConnectorAgnosticFunctionCallingModelClassesCanPassFunctionExceptionToConnectorAsync ( )
147
148
{
148
149
// Arrange
@@ -158,7 +159,6 @@ public async Task ConnectorAgnosticFunctionCallingModelClassesCanPassFunctionExc
158
159
159
160
// Act
160
161
var messageContent = await completionService . GetChatMessageContentAsync ( chatHistory , settings , kernel ) ;
161
-
162
162
var functionCalls = FunctionCallContent . GetFunctionCalls ( messageContent ) . ToArray ( ) ;
163
163
164
164
while ( functionCalls . Length != 0 )
@@ -215,7 +215,7 @@ public async Task ConnectorAgnosticFunctionCallingModelClassesSupportSimulatedFu
215
215
Assert . Contains ( "tornado" , messageContent . Content , StringComparison . InvariantCultureIgnoreCase ) ;
216
216
}
217
217
218
- [ Fact ( Skip = "For manual verification only" ) ]
218
+ [ RetryFact ( Skip = "For manual verification only" ) ]
219
219
public async Task ConnectorAgnosticFunctionCallingModelClassesCanBeUsedForAutoFunctionCallingAsync ( )
220
220
{
221
221
// Arrange
@@ -236,7 +236,7 @@ public async Task ConnectorAgnosticFunctionCallingModelClassesCanBeUsedForAutoFu
236
236
Assert . Equal ( AuthorRole . User , userMessage . Role ) ;
237
237
238
238
// LLM requested the functions to call.
239
- var getParallelFunctionCallRequestMessage = chatHistory [ 1 ] ;
239
+ var getParallelFunctionCallRequestMessage = chatHistory . First ( m => m . Items . Any ( i => i is FunctionCallContent ) ) ;
240
240
Assert . Equal ( AuthorRole . Assistant , getParallelFunctionCallRequestMessage . Role ) ;
241
241
242
242
// Parallel Function Calls in the same request
@@ -250,16 +250,16 @@ public async Task ConnectorAgnosticFunctionCallingModelClassesCanBeUsedForAutoFu
250
250
getWeatherForCityFunctionCallRequest = functionCalls [ 0 ] ;
251
251
252
252
// Connector invoked the Get_Weather_For_City function and added result to chat history.
253
- getWeatherForCityFunctionCallResultMessage = chatHistory [ 2 ] ;
253
+ getWeatherForCityFunctionCallResultMessage = chatHistory . First ( m => m . Items . Any ( i => i is FunctionResultContent ) ) ;
254
254
255
- Assert . Equal ( "HelperFunctions-Get_Weather_For_City " , getWeatherForCityFunctionCallRequest . FunctionName ) ;
255
+ Assert . Equal ( "HelperFunctions_Get_Weather_For_City " , getWeatherForCityFunctionCallRequest . FunctionName ) ;
256
256
Assert . NotNull ( getWeatherForCityFunctionCallRequest . Id ) ;
257
257
258
258
Assert . Equal ( AuthorRole . Tool , getWeatherForCityFunctionCallResultMessage . Role ) ;
259
259
Assert . Single ( getWeatherForCityFunctionCallResultMessage . Items . OfType < FunctionResultContent > ( ) ) ; // Current function calling model adds TextContent item representing the result of the function call.
260
260
261
261
var getWeatherForCityFunctionCallResult = getWeatherForCityFunctionCallResultMessage . Items . OfType < FunctionResultContent > ( ) . Single ( ) ;
262
- Assert . Equal ( "HelperFunctions-Get_Weather_For_City " , getWeatherForCityFunctionCallResult . FunctionName ) ;
262
+ Assert . Equal ( "HelperFunctions_Get_Weather_For_City " , getWeatherForCityFunctionCallResult . FunctionName ) ;
263
263
Assert . Equal ( getWeatherForCityFunctionCallRequest . Id , getWeatherForCityFunctionCallResult . CallId ) ;
264
264
Assert . NotNull ( getWeatherForCityFunctionCallResult . Result ) ;
265
265
}
@@ -318,12 +318,12 @@ private Kernel CreateAndInitializeKernel(bool importHelperPlugin = false)
318
318
319
319
Assert . NotNull ( config ) ;
320
320
Assert . NotNull ( config . Endpoint ) ;
321
- Assert . NotNull ( config . ModelId ) ;
321
+ Assert . NotNull ( config . ModelId ?? "llama3.2" ) ;
322
322
323
323
var kernelBuilder = base . CreateKernelBuilder ( ) ;
324
324
325
325
kernelBuilder . AddOllamaChatCompletion (
326
- modelId : config . ModelId ,
326
+ modelId : config . ModelId ?? "llama3.2" ,
327
327
endpoint : new Uri ( config . Endpoint ) ) ;
328
328
329
329
var kernel = kernelBuilder . Build ( ) ;
@@ -332,7 +332,7 @@ private Kernel CreateAndInitializeKernel(bool importHelperPlugin = false)
332
332
{
333
333
kernel . ImportPluginFromFunctions ( "HelperFunctions" ,
334
334
[
335
- kernel . CreateFunctionFromMethod ( ( ) => DateTime . UtcNow . ToString ( "R" ) , "GetCurrentUtcTime " , "Retrieves the current time in UTC." ) ,
335
+ kernel . CreateFunctionFromMethod ( ( ) => DateTime . UtcNow . ToString ( "R" ) , "Get_Current_Utc_Time " , "Retrieves the current time in UTC." ) ,
336
336
kernel . CreateFunctionFromMethod ( ( string cityName ) =>
337
337
{
338
338
return cityName switch
0 commit comments