-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.Net: Plans using FunctionRunner + RequestSettings (#3264)
### Motivation and Context Plans now fully utilize Kernel.RunAsync thru FunctionRunner interface, this will allow Plan steps to trigger Pre/Post Hooks defined in the Kernel that the Plan was ran. Option to override the RequestSettings in the Kernel.RunAsync call. This is was required while running Plan steps that by default will use the current Plan settings. One more step towards using RunAsync as the main entry point + Pre/Post hooks phase 2. Resolves Partially #2324 ### Description - Kernel.RunAsync optionally accepts `AIRequestSettings` - PlanSteps now run in the Kernel and can trigger Pre/Post Hooks ### Contribution Checklist - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
- Loading branch information
1 parent
ba40209
commit 0c1b669
Showing
10 changed files
with
97 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
dotnet/src/SemanticKernel.Abstractions/Orchestration/FunctionRunnerExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.SemanticKernel.Orchestration; | ||
|
||
/// <summary> | ||
/// Function runner extensions. | ||
/// </summary> | ||
public static class FunctionRunnerExtensions | ||
{ | ||
/// <summary> | ||
/// Execute a function using the resources loaded in the context. | ||
/// </summary> | ||
/// <param name="functionRunner">Target function runner</param> | ||
/// <param name="skFunction">Target function to run</param> | ||
/// <param name="variables">Input to process</param> | ||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param> | ||
/// <returns>Result of the function composition</returns> | ||
public static Task<FunctionResult> RunAsync( | ||
this IFunctionRunner functionRunner, | ||
ISKFunction skFunction, | ||
ContextVariables? variables = null, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
return functionRunner.RunAsync(skFunction, variables, null, cancellationToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters