You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d014534
Browse filesBrowse the repository at this point in the historyBrowse files
### Motivation and Context
This PR adds the `FunctionChoiceBehaviorOptions.AllowParallelCalls`
option and updates {Azure} OpenAI AI connectors to support it. This
option instructs the AI model to generate multiple function calls in a
single response when set to true.
_"This is especially useful if executing the given functions takes a
long time. For example, the model may call functions to get the weather
in three different locations at the same time, which will result in a
message with three function calls in the tool_calls array."_ **Source**
- [Configuring parallel function
calling](https://platform.openai.com/docs/guides/function-calling/configuring-parallel-function-calling)
Closes: #6636
Copy file name to clipboardExpand all lines: dotnet/samples/Concepts/FunctionCalling/FunctionCalling.cs
+67Lines changed: 67 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,19 @@ namespace FunctionCalling;
46
46
/// * The <see cref="FunctionChoiceBehaviorOptions.AllowConcurrentInvocation"/> option enables concurrent invocation of functions by SK.
47
47
/// By default, this option is set to false, meaning that functions are invoked sequentially. Concurrent invocation is only possible if the AI model can
48
48
/// call or select multiple functions for invocation in a single request; otherwise, there is no distinction between sequential and concurrent invocation.
49
+
/// * The <see cref="FunctionChoiceBehaviorOptions.AllowParallelCalls"/> option instructs the AI model to call multiple functions in one request if the model supports parallel function calls.
50
+
/// By default, this option is set to null, meaning that the AI model default value will be used.
49
51
///
52
+
/// The following table summarizes the effects of different combinations of these options:
53
+
///
54
+
/// | AllowParallelCalls | AllowConcurrentInvocation | AI function call requests | Concurrent Invocation |
@@ -458,6 +470,61 @@ public async Task RunNonStreamingChatCompletionApiWithConcurrentFunctionInvocati
458
470
// Expected output: Good morning! The current UTC time is 07:47 on October 22, 2024. Here are the latest news headlines: 1. Squirrel Steals Show - Discover the unexpected star of a recent event. 2. Dog Wins Lottery - Unbelievably, a lucky canine has hit the jackpot.
459
471
}
460
472
473
+
[Fact]
474
+
/// <summary>
475
+
/// This example demonstrates usage of the non-streaming chat completion API with <see cref="FunctionChoiceBehavior.Auto"/> that
476
+
/// advertises all kernel functions to the AI model and instructs the model to call multiple functions in parallel.
"Good morning! What’s the current time and latest news headlines?",
491
+
settings,
492
+
kernel);
493
+
494
+
// Assert
495
+
Console.WriteLine(result);
496
+
497
+
// Expected output: Good morning! The current UTC time is 07:47 on October 22, 2024. Here are the latest news headlines: 1. Squirrel Steals Show - Discover the unexpected star of a recent event. 2. Dog Wins Lottery - Unbelievably, a lucky canine has hit the jackpot.
498
+
}
499
+
500
+
[Fact]
501
+
/// <summary>
502
+
/// This example demonstrates usage of the non-streaming chat completion API with <see cref="FunctionChoiceBehavior.Auto"/> that
503
+
/// advertises all kernel functions to the AI model, instructs the model to call multiple functions in parallel, and invokes them concurrently.
"Good morning! What’s the current time and latest news headlines?",
519
+
settings,
520
+
kernel);
521
+
522
+
// Assert
523
+
Console.WriteLine(result);
524
+
525
+
// Expected output: Good morning! The current UTC time is 07:47 on October 22, 2024. Here are the latest news headlines: 1. Squirrel Steals Show - Discover the unexpected star of a recent event. 2. Dog Wins Lottery - Unbelievably, a lucky canine has hit the jackpot.
#pragma warning restore OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
Copy file name to clipboardExpand all lines: dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletion_AutoFunctionChoiceBehaviorTests.cs
+47Lines changed: 47 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -350,6 +350,53 @@ public async Task SpecifiedInCodeInstructsConnectorToInvokeKernelFunctionsAutoma
350
350
Assert.True(requestIndexLog.All((item)=>item==0));// Assert that all functions called by the AI model were executed within the same initial request.
0 commit comments