Skip to content

Commit

Permalink
.Net: OrderedAIServiceSelector logic should change as specified in is…
Browse files Browse the repository at this point in the history
…sue 4234 (#4265)

### Motivation and Context

Closes #4234 

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [ ] The code builds clean without any errors or warnings
- [ ] 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
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
  • Loading branch information
markwallace-microsoft committed Dec 14, 2023
1 parent 2321dd5 commit 2584d42
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public bool TrySelectAIService<T>(
else
{
PromptExecutionSettings? defaultExecutionSettings = null;
// Search by service id first
foreach (var keyValue in executionSettings)
{
var settings = keyValue.Value;
Expand All @@ -52,6 +53,13 @@ public bool TrySelectAIService<T>(
return true;
}
}
}

// Search by model id next
foreach (var keyValue in executionSettings)
{
var settings = keyValue.Value;
var serviceId = keyValue.Key;
if (!string.IsNullOrEmpty(settings.ModelId))
{
service = this.GetServiceByModelId<T>(kernel, settings.ModelId!);
Expand All @@ -63,6 +71,7 @@ public bool TrySelectAIService<T>(
}
}

// Search for default service id last
if (defaultExecutionSettings is not null)
{
service = GetAnyService(kernel);
Expand Down

0 comments on commit 2584d42

Please sign in to comment.