Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
dluc authored Nov 13, 2024
2 parents 8d07edd + 23b2782 commit 8c07732
Show file tree
Hide file tree
Showing 111 changed files with 3,409 additions and 3,196 deletions.
1 change: 1 addition & 0 deletions .github/_typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extend-exclude = [
"GPT3TokenizerTests.cs",
"CodeTokenizerTests.cs",
"test_code_tokenizer.py",
"CopilotChat.sln.DotSettings"
]

[default.extend-words]
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ dotnet/.config
*.user
*.userosscache
*.sln.docstates
webapi/data/*.json
__dev/

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
305 changes: 305 additions & 0 deletions CopilotChat.sln.DotSettings

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<Project>
<PropertyGroup>
<!-- C# lang version, https://learn.microsoft.com/dotnet/csharp/whats-new -->
<LangVersion>12</LangVersion>

<!-- https://learn.microsoft.com/dotnet/core/tools/global-json#rollforward -->
<RollForward>LatestMajor</RollForward>

<!-- https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/nullable-value-types -->
<Nullable>enable</Nullable>

<!-- https://devblogs.microsoft.com/dotnet/welcome-to-csharp-10 -->
<ImplicitUsings>enable</ImplicitUsings>

<IsPackable>false</IsPackable>
<AnalysisMode>All</AnalysisMode>
<NoWarn>CA1812,CA2234,CS1570,CS1572,CS1573,CS1574,CA1056,CA1716,CA1724,SKEXP0003,SKEXP0011,SKEXP0021,SKEXP0026,SKEXP0042,SKEXP0050,SKEXP0052,SKEXP0053,SKEXP0060,KMEXP02,SKEXP0040</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.CodeAnalysis.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.Formatting.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
102 changes: 102 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.2" />
<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.45.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.1" />
<PackageVersion Include="Microsoft.Identity.Client" Version="4.66.2" />
<PackageVersion Include="Microsoft.Identity.Web" Version="2.21.1" />
<PackageVersion Include="SharpToken" Version="2.0.3" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.9.0" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="Tesseract" Version="5.2.0" />
</ItemGroup>
<ItemGroup>
<!-- Make sure the app is thoroughly tested after any Microsoft.Azure.Functions.* package updates. -->
<PackageVersion Include="Microsoft.Azure.Functions.Worker" Version="1.23.0" />
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.OpenApi" Version="1.5.1" />
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.18.1" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.SemanticKernel" Version="1.28.0" />
<PackageVersion Include="Microsoft.SemanticKernel.Abstractions" Version="1.28.0" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.AzureAISearch" Version="1.28.0-preview" />
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.Qdrant" Version="1.28.0-preview" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.SemanticKernel.Plugins.Core" Version="1.28.0-alpha" />
<PackageVersion Include="Microsoft.SemanticKernel.Plugins.Memory" Version="1.28.0-alpha" />
<PackageVersion Include="Microsoft.SemanticKernel.Plugins.MsGraph" Version="1.28.0-alpha" />
<PackageVersion Include="Microsoft.SemanticKernel.Plugins.OpenApi" Version="1.28.0-alpha" />
<PackageVersion Include="Microsoft.SemanticKernel.Plugins.Web" Version="1.28.0-alpha" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.KernelMemory.AI.AzureOpenAI" Version="0.92.241112.1" />
<PackageVersion Include="Microsoft.KernelMemory.AI.Ollama" Version="0.92.241112.1" />
<PackageVersion Include="Microsoft.KernelMemory.AI.OpenAI" Version="0.92.241112.1" />
<PackageVersion Include="Microsoft.KernelMemory.Abstractions" Version="0.92.241112.1" />
<PackageVersion Include="Microsoft.KernelMemory.Core" Version="0.92.241112.1" />
<PackageVersion Include="Microsoft.KernelMemory.DataFormats.AzureAIDocIntel" Version="0.92.241112.1" />
<PackageVersion Include="Microsoft.KernelMemory.DocumentStorage.AzureBlobs" Version="0.92.241112.1" />
<PackageVersion Include="Microsoft.KernelMemory.MemoryDb.AzureAISearch" Version="0.92.241112.1" />
<PackageVersion Include="Microsoft.KernelMemory.MemoryDb.Postgres" Version="0.92.241112.1" />
<PackageVersion Include="Microsoft.KernelMemory.MemoryDb.Qdrant" Version="0.92.241112.1" />
<PackageVersion Include="Microsoft.KernelMemory.MemoryDb.SQLServer" Version="0.92.241112.1" />
<PackageVersion Include="Microsoft.KernelMemory.Orchestration.AzureQueues" Version="0.92.241112.1" />
<PackageVersion Include="Microsoft.KernelMemory.Orchestration.RabbitMQ" Version="0.92.241112.1" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageVersion>
<PackageVersion Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageVersion>
</ItemGroup>
<!-- Code Analysis -->
<ItemGroup>
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.11.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Roslynator.Analyzers" Version="4.12.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Roslynator.CodeAnalysis.Analyzers" Version="4.12.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.12.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.12.19">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ You will need the following items to run the sample:
.\Install.ps1
```

> NOTE: This script will install `Chocolatey`, `dotnet-7.0-sdk`, `nodejs`, and `yarn`.
> NOTE: This script will install `Chocolatey`, `dotnet-8.0-sdk`, `nodejs`, and `yarn`.
> NOTE: If you receive an error that the script is not digitally signed or cannot execute on the system, you may need to [change the execution policy](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.3#change-the-execution-policy) (see list of [policies](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.3#powershell-execution-policies) and [scopes](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.3#execution-policy-scope)) or [unblock the script](https://learn.microsoft.com/powershell/module/microsoft.powershell.security/get-executionpolicy?view=powershell-7.3#example-4-unblock-a-script-to-run-it-without-changing-the-execution-policy).
Expand Down Expand Up @@ -111,7 +111,7 @@ You will need the following items to run the sample:
./install-apt.sh
```

> NOTE: This script uses `apt` to install `dotnet-sdk-7.0`, `nodejs`, and `yarn`.
> NOTE: This script uses `apt` to install `dotnet-sdk-8.0`, `nodejs`, and `yarn`.

**macOS**

Expand Down Expand Up @@ -362,7 +362,7 @@ Backend authentication via Azure AD must be enabled. Detailed instructions for e
# Update and install dotnet
sudo apt update;
sudo apt install --assume-yes dotnet-sdk-7.0;
sudo apt install --assume-yes dotnet-sdk-8.0;
```
# A note on branches
Expand Down
3 changes: 3 additions & 0 deletions integration-tests/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[**/**.cs]
resharper_inconsistent_naming_highlighting = none
dotnet_diagnostic.IDE1006.severity = none # No need for Async suffix on test names
39 changes: 18 additions & 21 deletions integration-tests/ChatCopilotIntegrationTest.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.

using System;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Identity.Client;
using Xunit;
Expand All @@ -15,6 +11,7 @@ namespace ChatCopilotIntegrationTests;
/// Base class for Chat Copilot integration tests
/// </summary>
[Trait("Category", "Integration Tests")]
#pragma warning disable CA1051
public abstract class ChatCopilotIntegrationTest : IDisposable
{
protected const string BaseUrlSettingName = "BaseServerUrl";
Expand All @@ -24,25 +21,25 @@ public abstract class ChatCopilotIntegrationTest : IDisposable
protected const string PasswordSettingName = "TestPassword";
protected const string ScopesSettingName = "Scopes";

protected readonly HttpClient _httpClient;
protected readonly IConfigurationRoot configuration;
protected readonly HttpClient HTTPClient;
protected readonly IConfigurationRoot Configuration;

protected ChatCopilotIntegrationTest()
{
// Load configuration
this.configuration = new ConfigurationBuilder()
this.Configuration = new ConfigurationBuilder()
.AddJsonFile(path: "testsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile(path: "testsettings.development.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.AddUserSecrets<HealthzTests>()
.Build();

string? baseUrl = this.configuration[BaseUrlSettingName];
string? baseUrl = this.Configuration[BaseUrlSettingName];
Assert.False(string.IsNullOrEmpty(baseUrl));
Assert.True(baseUrl.EndsWith('/'));

this._httpClient = new HttpClient();
this._httpClient.BaseAddress = new Uri(baseUrl);
this.HTTPClient = new HttpClient();
this.HTTPClient.BaseAddress = new Uri(baseUrl);
}

public void Dispose()
Expand All @@ -55,28 +52,28 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
this._httpClient.Dispose();
this.HTTPClient.Dispose();
}
}

protected async Task SetUpAuth()
protected async Task SetUpAuthAsync()
{
string accesstoken = await this.GetUserTokenByPassword();
string accesstoken = await this.GetUserTokenByPasswordAsync();
Assert.True(!string.IsNullOrEmpty(accesstoken));

this._httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accesstoken);
this.HTTPClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accesstoken);
}

protected async Task<string> GetUserTokenByPassword()
protected async Task<string> GetUserTokenByPasswordAsync()
{
IPublicClientApplication app = PublicClientApplicationBuilder.Create(this.configuration[ClientIdSettingName])
.WithAuthority(this.configuration[AuthoritySettingName])
.Build();
IPublicClientApplication app = PublicClientApplicationBuilder.Create(this.Configuration[ClientIdSettingName])
.WithAuthority(this.Configuration[AuthoritySettingName])
.Build();

string? scopeString = this.configuration[ScopesSettingName];
string? scopeString = this.Configuration[ScopesSettingName];
Assert.NotNull(scopeString);

string[] scopes = scopeString.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
string[] scopes = scopeString.Split([',', ' '], StringSplitOptions.RemoveEmptyEntries);

var accounts = await app.GetAccountsAsync();

Expand All @@ -88,7 +85,7 @@ protected async Task<string> GetUserTokenByPassword()
}
else
{
result = await app.AcquireTokenByUsernamePassword(scopes, this.configuration[UsernameSettingName], this.configuration[PasswordSettingName]).ExecuteAsync();
result = await app.AcquireTokenByUsernamePassword(scopes, this.Configuration[UsernameSettingName], this.Configuration[PasswordSettingName]).ExecuteAsync();
}

return result?.AccessToken ?? string.Empty;
Expand Down
31 changes: 16 additions & 15 deletions integration-tests/ChatCopilotIntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<UserSecretsId>81136671-a63f-4f20-bd0e-a65b2561999a</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<ProjectReference Include="..\webapi\CopilotChatWebApi.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\webapi\CopilotChatWebApi.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="testsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
Loading

0 comments on commit 8c07732

Please sign in to comment.