Skip to content

Commit

Permalink
Fix typos and code style (microsoft#741)
Browse files Browse the repository at this point in the history
* Fix filename containing a space (`ApiKeyAuthenticationHandler .cs`)
* Fix typos
* Fix code style
* Add missing rule for local constants
* Add commented code to automate code style checks. These don't work
with .NET Standard 2.0, so we'll need some extra research.
* Fix one incorrect ILogger naming
* Add some TODOs about unused code
* Fix xmldocs
  • Loading branch information
dluc committed May 1, 2023
1 parent b7529a2 commit db9acbf
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ApiKeyAuthenticationHandler : AuthenticationHandler<ApiKeyAuthentic
public const string AuthenticationScheme = "ApiKey";
public const string ApiKeyHeaderName = "x-api-key";

// TODO: not used?
private readonly IOptionsMonitor<ApiKeyAuthenticationSchemeOptions> _options;

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions samples/apps/copilot-chat-app/webapi/Config/PlannerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ public class PlannerOptions
/// <summary>
/// A list of skills to exclude from the plan creation request.
/// </summary>
public HashSet<string> ExcludedSkills { get; set; } = new() { };
public HashSet<string> ExcludedSkills { get; set; } = new();

/// <summary>
/// A list of functions to exclude from the plan creation request.
/// </summary>
public HashSet<string> ExcludedFunctions { get; set; } = new() { };
public HashSet<string> ExcludedFunctions { get; set; } = new();

/// <summary>
/// A list of functions to include in the plan creation request.
/// </summary>
public HashSet<string> IncludedFunctions { get; set; } = new() { };
public HashSet<string> IncludedFunctions { get; set; } = new();

/// <summary>
/// The maximum number of tokens to allow in a plan.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
using Microsoft.SemanticKernel.Memory;
using SemanticKernel.Service.Config;
using SemanticKernel.Service.Model;
using SemanticKernel.Service.Skills;
using SemanticKernel.Service.Storage;

namespace SemanticKernel.Service.Controllers;

[ApiController]
public class BotController : ControllerBase
{
private readonly ILogger<SemanticKernelController> _logger;
private readonly ILogger<BotController> _logger;
private readonly IMemoryStore _memoryStore;
private readonly ChatSessionRepository _chatRepository;
private readonly ChatMessageRepository _chatMessageRepository;
Expand All @@ -32,7 +31,7 @@ public class BotController : ControllerBase
IMemoryStore memoryStore,
ChatSessionRepository chatRepository,
ChatMessageRepository chatMessageRepository,
ILogger<SemanticKernelController> logger)
ILogger<BotController> logger)
{
this._logger = logger;
this._memoryStore = memoryStore;
Expand Down Expand Up @@ -177,7 +176,7 @@ public class BotController : ControllerBase
private async Task<Bot> CreateBotAsync(
IKernel kernel,
ChatSessionRepository chatRepository,
ChatMessageRepository chatMessageRepository,
ChatMessageRepository chatMessageRepository, // TODO: unused
BotSchemaOptions botSchemaOptions,
AIServiceOptions embeddingOptions,
Guid chatId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class ChatHistoryController : ControllerBase
var initialBotMessage = this._promptSettings.InitialBotMessage;
await this.SaveResponseAsync(initialBotMessage, newChat.Id);

this._logger.LogDebug("Created chat session with id {0} for user {1}.", newChat.Id, userId);
this._logger.LogDebug("Created chat session with id {0} for user {1}", newChat.Id, userId);
return this.CreatedAtAction(nameof(this.GetChatSessionByIdAsync), new { chatId = newChat.Id }, newChat);
}

Expand Down Expand Up @@ -91,7 +91,7 @@ public async Task<IActionResult> GetChatSessionByIdAsync(Guid chatId)
/// <summary>
/// Get all chat sessions associated with a user. Return an empty list if no chats are found.
/// The regex pattern that is used to match the user id will match the following format:
/// - 2 period separated groups of one or more hyphen-delimitated alphanumeric strings.
/// - 2 period separated groups of one or more hyphen-delimited alphanumeric strings.
/// The pattern matches two GUIDs in canonical textual representation separated by a period.
/// </summary>
/// <param name="userId">The user id.</param>
Expand Down Expand Up @@ -160,9 +160,9 @@ public async Task<IActionResult> GetAllChatSessionsAsync(string userId)
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> EditChatSessionAsync([FromBody] ChatSession chatParameters)
{
var chatId = chatParameters.Id;
string chatId = chatParameters.Id;

var chat = await this._chatSessionRepository.FindByIdAsync(chatId.ToString());
ChatSession? chat = await this._chatSessionRepository.FindByIdAsync(chatId);
if (chat == null)
{
return this.NotFound($"Chat of id {chatId} not found.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ private enum SupportedFileType
Pdf,
};

private readonly IServiceProvider _serviceProvider;
private readonly IServiceProvider _serviceProvider; // TODO: unused
private readonly ILogger<DocumentImportController> _logger;
private readonly PromptSettings _promptSettings;
private readonly PromptSettings _promptSettings; // TODO: unused
private readonly DocumentMemoryOptions _options;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion samples/apps/copilot-chat-app/webapi/Model/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

using Microsoft.SemanticKernel.Memory;
using SemanticKernel.Service.Config;
using SemanticKernel.Service.Skills;

namespace SemanticKernel.Service.Model;

Expand Down
2 changes: 1 addition & 1 deletion samples/apps/copilot-chat-app/webapi/Skills/ChatSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ private bool TryExtractJsonFromPlanResult(string openApiSkillResponse, out strin
catch (JsonException)
{
// Expected if not valid JSON.
this._logger.LogDebug("Unable to extract JSON from planner response. It is likely not JSON formatted.");
this._logger.LogDebug("Unable to extract JSON from planner response, it is likely not JSON formatted");
}

json = string.Empty;
Expand Down

0 comments on commit db9acbf

Please sign in to comment.