-
Notifications
You must be signed in to change notification settings - Fork 4.6k
CopilotChat: Options pattern and best practices #588
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
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
ee40c30
Refactoring configuration
adrianwyatt d736a88
Refactoring configuration
adrianwyatt 0b9dd6b
Rename SK Chatbot to Copilot
adrianwyatt 2f88e28
Refactoring configuration
adrianwyatt 541861e
Refactoring configuration
adrianwyatt 84f4257
Merge remote-tracking branch 'origin/main' into options
adrianwyatt 4296818
Fix build break
adrianwyatt d80788b
Fix markdown link to importdocument readme
adrianwyatt d0e213f
Merge branch 'main' into options
dluc d9c95ba
Update samples/apps/copilot-chat-app/webapi/Config/AuthorizationOptio…
adrianwyatt 7c2ec61
Update samples/apps/copilot-chat-app/webapi/Config/AzureSpeechOptions.cs
adrianwyatt a2789f0
Minor changes from PR feedback
adrianwyatt 4e6956d
Merge branch 'options' of https://github.com/adrianwyatt/semantic-ker…
adrianwyatt cdcb39f
Merge remote-tracking branch 'origin/main' into options
adrianwyatt 2c6a9e8
Updated pattern for configuration validation.
adrianwyatt 6facae4
dotnet format
adrianwyatt a7c4054
Merge branch 'main' into options
adrianwyatt 2504df4
Remove warning from launchsettings URL override
adrianwyatt 5da4ddd
Merge branch 'main' into options
adrianwyatt 064abe2
dotnet format
adrianwyatt 59a60e3
Merge branch 'main' into options
adrianwyatt 88f9dcf
Merge branch 'options' of https://github.com/adrianwyatt/semantic-ker…
adrianwyatt 77c2079
Merge branch 'main' into options
adrianwyatt 2cf5516
Merge remote-tracking branch 'origin/main' into options
adrianwyatt 1abf58a
Update samples/apps/copilot-chat-app/webapi/Config/ChatStoreOptions.cs
adrianwyatt 017793e
Update samples/apps/copilot-chat-app/webapi/Config/ChatStoreOptions.cs
adrianwyatt 28b04c4
Minor updates from pr comments
adrianwyatt 6217c18
Merge branch 'options' of https://github.com/adrianwyatt/semantic-ker…
adrianwyatt b54e3cf
Merge branch 'main' into options
adrianwyatt 1c24cdd
Merge remote-tracking branch 'origin/main' into options
adrianwyatt 02c579c
build break
adrianwyatt 234e4c1
Merge remote-tracking branch 'origin/main' into options
adrianwyatt fe7214d
Updates from PR comments
adrianwyatt 5880d2e
Merge branch 'main' into options
adrianwyatt 4cce6a8
Updates from PR comments
adrianwyatt f49147e
Fixes from merge
adrianwyatt a315c12
Merge branch 'main' into options
adrianwyatt 6bb6c30
dotnet format
adrianwyatt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
45 changes: 0 additions & 45 deletions
45
samples/apps/copilot-chat-app/webapi/Config/AIServiceConfig.cs
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
samples/apps/copilot-chat-app/webapi/Config/AIServiceOptions.cs
This file contains hidden or 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,53 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| using System.ComponentModel.DataAnnotations; | ||
|
|
||
| namespace SemanticKernel.Service.Config; | ||
|
|
||
| /// <summary> | ||
| /// Configuration options for AI services, such as Azure OpenAI and OpenAI. | ||
| /// </summary> | ||
| public sealed class AIServiceOptions | ||
| { | ||
| public const string CompletionPropertyName = "Completion"; | ||
| public const string EmbeddingPropertyName = "Embedding"; | ||
|
|
||
| public enum AIServiceType | ||
| { | ||
| AzureOpenAI, | ||
| OpenAI | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Label used for referencing the AI service in Semantic Kernel. | ||
| /// </summary> | ||
| [Required, NotEmptyOrWhitespace] | ||
| public string Label { get; set; } = string.Empty; | ||
|
|
||
| /// <summary> | ||
| /// Type of AI service. | ||
| /// </summary> | ||
| [Required] | ||
| public AIServiceType AIService { get; set; } = AIServiceType.AzureOpenAI; | ||
|
|
||
| /// <summary> | ||
| /// Azure OpenAI deployment name or OpenAI model name. | ||
| /// </summary> | ||
| [Required, NotEmptyOrWhitespace] | ||
| public string DeploymentOrModelId { get; set; } = string.Empty; | ||
|
|
||
| /// <summary> | ||
| /// (Azure OpenAI only) Azure OpenAI endpoint. | ||
| /// </summary> | ||
| [RequiredOnPropertyValue(nameof(AIService), AIServiceType.AzureOpenAI)] | ||
| [NotEmptyOrWhitespace] | ||
| public string Endpoint { get; set; } = string.Empty; | ||
|
|
||
| /// <summary> | ||
| /// Key to access the AI service. | ||
| /// </summary> | ||
| [Required, NotEmptyOrWhitespace] | ||
| public string Key { get; set; } = string.Empty; | ||
|
|
||
| // TODO support OpenAI's orgID | ||
| } | ||
68 changes: 68 additions & 0 deletions
68
samples/apps/copilot-chat-app/webapi/Config/AuthorizationOptions.cs
This file contains hidden or 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,68 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| using System.ComponentModel.DataAnnotations; | ||
| using Microsoft.Identity.Web; | ||
|
|
||
| namespace SemanticKernel.Service.Config; | ||
|
|
||
| /// <summary> | ||
| /// Configuration options for authorizing to the service. | ||
| /// </summary> | ||
| public class AuthorizationOptions | ||
| { | ||
| public const string PropertyName = "Authorization"; | ||
|
|
||
| public enum AuthorizationType | ||
| { | ||
| None, | ||
| ApiKey, | ||
| AzureAd | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Type of authorization. | ||
| /// </summary> | ||
| public AuthorizationType Type { get; set; } = AuthorizationType.None; | ||
|
|
||
| /// <summary> | ||
| /// When <see cref="Type"/> is <see cref="AuthorizationType.ApiKey"/>, this is the API key to use. | ||
| /// </summary> | ||
| [Required, NotEmptyOrWhitespace] | ||
| public string ApiKey { get; set; } = string.Empty; | ||
|
|
||
| /// <summary> | ||
| /// When <see cref="Type"/> is <see cref="AuthorizationType.AzureAd"/>, these are the Azure AD options to use. | ||
| /// </summary> | ||
| [RequiredOnPropertyValue(nameof(Type), AuthorizationType.AzureAd)] | ||
| public AzureAdOptions? AzureAd { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Configuration options for Azure Active Directory (AAD) authorization. | ||
| /// </summary> | ||
| public class AzureAdOptions | ||
| { | ||
| /// <summary> | ||
| /// AAD instance url, i.e., https://login.microsoftonline.com/ | ||
| /// </summary> | ||
| [Required, NotEmptyOrWhitespace] | ||
| public string Instance { get; set; } = string.Empty; | ||
|
|
||
| /// <summary> | ||
| /// Tenant (directory) ID | ||
| /// </summary> | ||
| [Required, NotEmptyOrWhitespace] | ||
| public string TenantId { get; set; } = string.Empty; | ||
|
|
||
| /// <summary> | ||
| /// Application (client) ID | ||
| /// </summary> | ||
| [Required, NotEmptyOrWhitespace] | ||
| public string ClientId { get; set; } = string.Empty; | ||
|
|
||
| /// <summary> | ||
| /// Required scopes. | ||
| /// </summary> | ||
| [Required] | ||
| public string? Scopes { get; set; } = string.Empty; | ||
| } | ||
| } |
20 changes: 0 additions & 20 deletions
20
samples/apps/copilot-chat-app/webapi/Config/AzureSpeechConfig.cs
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
samples/apps/copilot-chat-app/webapi/Config/AzureSpeechOptions.cs
This file contains hidden or 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,25 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| using System.ComponentModel.DataAnnotations; | ||
|
|
||
| namespace SemanticKernel.Service.Config; | ||
|
|
||
| /// <summary> | ||
| /// Configuration options for Azure speech recognition. | ||
| /// </summary> | ||
| public sealed class AzureSpeechOptions | ||
| { | ||
| public const string PropertyName = "AzureSpeech"; | ||
|
|
||
| /// <summary> | ||
| /// Location of the Azure speech service to use (e.g. "South Central US") | ||
| /// </summary> | ||
| [Required, NotEmptyOrWhitespace] | ||
| public string? Region { get; set; } = string.Empty; | ||
|
|
||
| /// <summary> | ||
| /// Key to access the Azure speech service. | ||
| /// </summary> | ||
| [Required, NotEmptyOrWhitespace] | ||
| public string Key { get; set; } = string.Empty; | ||
| } |
12 changes: 9 additions & 3 deletions
12
...chat-app/webapi/Config/BotSchemaConfig.cs → ...hat-app/webapi/Config/BotSchemaOptions.cs
This file contains hidden or 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 |
|---|---|---|
| @@ -1,19 +1,25 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| using System.ComponentModel.DataAnnotations; | ||
|
|
||
| namespace SemanticKernel.Service.Config; | ||
|
|
||
| /// <summary> | ||
| /// Configuration settings for the bot file schema that is supported by this application. | ||
| /// Configuration options for the bot file schema that is supported by this application. | ||
| /// </summary> | ||
| public class BotSchemaConfig | ||
| public class BotSchemaOptions | ||
| { | ||
| public const string PropertyName = "BotSchema"; | ||
|
|
||
| /// <summary> | ||
| /// The name of the schema. | ||
| /// </summary> | ||
| [Required, NotEmptyOrWhitespace] | ||
| public string Name { get; set; } = string.Empty; | ||
|
|
||
| /// <summary> | ||
| /// The version of the schema. | ||
| /// </summary> | ||
| public int Version { get; set; } = -1; | ||
| [Range(0, int.MaxValue)] | ||
| public int Version { get; set; } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.