-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.Net Simplify configuration by ServiceId on Multi Model Scenarios. #6416
Merged
markwallace-microsoft
merged 22 commits into
microsoft:main
from
RogerBarreto:features/service-id-settings
Jun 19, 2024
Merged
.Net Simplify configuration by ServiceId on Multi Model Scenarios. #6416
markwallace-microsoft
merged 22 commits into
microsoft:main
from
RogerBarreto:features/service-id-settings
Jun 19, 2024
Conversation
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
markwallace-microsoft
added
.NET
Issue or Pull requests regarding .NET code
kernel
Issues or pull requests impacting the core kernel
kernel.core
labels
May 27, 2024
dotnet/src/SemanticKernel.Abstractions/AI/PromptExecutionSettings.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Abstractions/Functions/KernelArguments.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Abstractions/PromptTemplate/PromptTemplateConfig.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.UnitTests/Functions/OrderedAIServiceSelectorTests.cs
Outdated
Show resolved
Hide resolved
Some general feedback
|
Good point, I added all possible combinations of samples with PreConfigured and per Invocation and simplified a bit more the samples to 2 lines max. |
dotnet/src/SemanticKernel.Abstractions/Functions/KernelArguments.cs
Outdated
Show resolved
Hide resolved
dmytrostruk
reviewed
May 29, 2024
dotnet/src/SemanticKernel.Abstractions/Functions/KernelArguments.cs
Outdated
Show resolved
Hide resolved
dmytrostruk
reviewed
May 29, 2024
dotnet/samples/Concepts/ChatCompletion/Connectors_WithMultipleLLMs.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/Concepts/ChatCompletion/Connectors_WithMultipleLLMs.cs
Outdated
Show resolved
Hide resolved
dmytrostruk
approved these changes
Jun 4, 2024
dotnet/src/SemanticKernel.Abstractions/Functions/KernelArguments.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/Concepts/ChatCompletion/Connectors_WithMultipleLLMs.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/Concepts/ChatCompletion/Connectors_WithMultipleLLMs.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/Concepts/ChatCompletion/Connectors_WithMultipleLLMs.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/Concepts/ChatCompletion/Connectors_WithMultipleLLMs.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/Concepts/ChatCompletion/Connectors_WithMultipleLLMs.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/Concepts/ChatCompletion/Connectors_WithMultipleLLMs.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Abstractions/Functions/KernelArguments.cs
Outdated
Show resolved
Hide resolved
dotnet/src/SemanticKernel.Abstractions/Functions/KernelArguments.cs
Outdated
Show resolved
Hide resolved
markwallace-microsoft
approved these changes
Jun 19, 2024
github-merge-queue
bot
removed this pull request from the merge queue due to failed status checks
Jun 19, 2024
LudoCorporateShark
pushed a commit
to LudoCorporateShark/semantic-kernel
that referenced
this pull request
Aug 25, 2024
…icrosoft#6416) ### Motivation and Context Setting multiple execution settings is not simple and demands creating a dictionary on the caller side to set directly into the `ExecutionSettings` setter property. This change adds a `ServiceId` property to the execution settings which will be used during the initialization and deserialization to set the expected `Key` in the dictionary as well as the setting for filtering and executing a service specific function invocation. With this change were also added new constructors for `PromptTemplateConfig`, `KernelArguments` accepting multiple `PromptExecutionSettings` as well as added multiple for `Kernel.CreateFunctionFromPrompt` and `KernelFunctionFromPrompt.Create` ### ServiceId Settings Before: ```csharp KernelArguments arguments = []; arguments.ExecutionSettings = new Dictionary<string, PromptExecutionSettings>() { { serviceId, new PromptExecutionSettings() } }; var result = await kernel.InvokePromptAsync(prompt, arguments); ``` After: ```csharp var result = await kernel.InvokePromptAsync(prompt, new(new PromptExecutionSettings { ServiceId = serviceId })); ``` ### ModelIds Settings Before: ```csharp string[] modelIds = ["model1", "model2", ...]; var modelSettings = new Dictionary<string, PromptExecutionSettings>(); foreach (var modelId in modelIds) { modelSettings.Add(modelId, new PromptExecutionSettings() { ModelId = modelId }); } var promptConfig = new PromptTemplateConfig(prompt) { Name = "HelloAI", ExecutionSettings = modelSettings }; var function = kernel.CreateFunctionFromPrompt(promptConfig); ``` After: ```csharp string[] modelIds = ["model1", "model2", ...]; var function = kernel.CreateFunctionFromPrompt(prompt, modelIds.Select((modelId, index) => new PromptExecutionSettings { ServiceId = $"service-{index}", ModelId = modelId })); ``` The same can be done for ServiceId settings: ```csharp string[] serviceIds = ["service1", "service2"... ]; var function = kernel.CreateFunctionFromPrompt(prompt, serviceIds.Select(serviceId => new PromptExecutionSettings { ServiceId = serviceId })); ``` --------- Co-authored-by: Mark Wallace <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
kernel.core
kernel
Issues or pull requests impacting the core kernel
.NET
Issue or Pull requests regarding .NET code
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Setting multiple execution settings is not simple and demands creating a dictionary on the caller side to set directly into the
ExecutionSettings
setter property.This change adds a
ServiceId
property to the execution settings which will be used during the initialization and deserialization to set the expectedKey
in the dictionary as well as the setting for filtering and executing a service specific function invocation.With this change were also added new constructors for
PromptTemplateConfig
,KernelArguments
accepting multiplePromptExecutionSettings
as well as added multiple forKernel.CreateFunctionFromPrompt
andKernelFunctionFromPrompt.Create
ServiceId Settings
Before:
After:
ModelIds Settings
Before:
After:
The same can be done for ServiceId settings: