Skip to content

Commit

Permalink
Update Chat-Copilot to Semantic Kernel Beta4 and Kernel-Memory (micro…
Browse files Browse the repository at this point in the history
…soft#581)

### Motivation and Context

<!-- Thank you for your contribution to the chat-copilot repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

Updating chat-copilot to semantic-kernel 1.0.0-beta4 and also updating
semantic-memory reference to kernel-memory (which also references SK
1.0.0-beta4).


### Description

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

Updated breaking changes for both code and configuration:


https://github.com/microsoft/semantic-kernel/releases/tag/dotnet-1.0.0-beta4

https://github.com/microsoft/kernel-memory/pkgs/nuget/Microsoft.KernelMemory.Core/144845992


![image](https://github.com/microsoft/chat-copilot/assets/66376200/e83401ce-1a71-49e4-afa3-c6f261fda6b8)

![image](https://github.com/microsoft/chat-copilot/assets/66376200/1134a00e-6f4d-4411-a893-f27b62f1b207)

### Contribution Checklist

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

- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [Contribution
Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
  • Loading branch information
crickman authored Nov 8, 2023
1 parent 05e133e commit c970dc0
Show file tree
Hide file tree
Showing 40 changed files with 394 additions and 405 deletions.
3 changes: 2 additions & 1 deletion CopilotChat.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChatCopilotIntegrationTests", "integration-tests\ChatCopilotIntegrationTests.csproj", "{0CD2CD95-536B-455F-B74A-772A455FA607}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CopilotChatShared", "shared\CopilotChatShared.csproj", "{94F12185-FAF9-43E3-B153-28A1708AC918}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebSearcher", "plugins\web-searcher\WebSearcher.csproj", "{F83C857D-3080-4DEA-B3D1-978E2BC64BFB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginShared", "plugins\shared\PluginShared.csproj", "{9D03913A-21FF-4D0A-9883-95C4B3D6F65A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginShared", "plugins\shared\PluginShared.csproj", "{9D03913A-21FF-4D0A-9883-95C4B3D6F65A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
4 changes: 2 additions & 2 deletions memorypipeline/CopilotChatMemoryPipeline.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.SemanticKernel" Version="0.24.230918.1-preview" />
<PackageReference Include="Microsoft.SemanticMemory.Core" Version="0.4.231023.1-preview" />
<PackageReference Include="Microsoft.KernelMemory.Core" Version="0.7.231106.1-preview" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.0.0-beta4" />
</ItemGroup>

</Project>
8 changes: 4 additions & 4 deletions memorypipeline/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticMemory;
using Microsoft.SemanticMemory.Diagnostics;
using Microsoft.KernelMemory;
using Microsoft.KernelMemory.Diagnostics;

// ********************************************************
// ************** SETUP ***********************************
// ********************************************************

var builder = WebApplication.CreateBuilder();

ISemanticMemoryClient memory =
new MemoryClientBuilder(builder.Services)
IKernelMemory memory =
new KernelMemoryBuilder(builder.Services)
.FromAppSettings()
.WithCustomOcr(builder.Configuration)
.Build();
Expand Down
4 changes: 2 additions & 2 deletions memorypipeline/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
//
// Semantic Memory configuration - https://github.com/microsoft/semantic-memory
// Kernel Memory configuration - https://github.com/microsoft/kernel-memory
// - ContentStorageType is the storage configuration for memory transfer: "AzureBlobs" or "SimpleFileStorage"
// - TextGeneratorType is the AI completion service configuration: "AzureOpenAIText" or "OpenAI"
// - ImageOcrType is the image OCR configuration: "None" or "AzureFormRecognizer" or "Tesseract"
// - DataIngestion is the configuration section for data ingestion pipelines.
// - Retrieval is the configuration section for memory retrieval.
// - Services is the configuration sections for various memory settings.
//
"SemanticMemory": {
"KernelMemory": {
"ContentStorageType": "SimpleFileStorage",
"TextGeneratorType": "AzureOpenAIText",
"ImageOcrType": "None",
Expand Down
6 changes: 5 additions & 1 deletion plugins/web-searcher/PluginEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ public async Task<HttpResponseData> WebSearch([HttpTrigger(AuthorizationLevel.Fu
return await this.CreateBadRequestResponseAsync(req, "Invalid number of results.");
}

var offset = queries.ContainsKey("Offset") ? int.Parse(queries["Offset"]) : 0;
int offset = 0;
if (queries.TryGetValue("Offset", out var offsetValue))
{
int.TryParse(offsetValue, out offset);
}

var site = queries.ContainsKey("Site") ? queries["Site"].ToString() : string.Empty;
if (string.IsNullOrWhiteSpace(site))
Expand Down
6 changes: 3 additions & 3 deletions plugins/web-searcher/local.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"Host": {
"CORS": "*"
},
"PluginConfig": {
"BingApiKey": ""
}
"PluginConfig": {
"BingApiKey": ""
}
}
8 changes: 4 additions & 4 deletions scripts/Configure.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ $webapiProjectPath = Join-Path "$PSScriptRoot" '../webapi'

Write-Host "Setting 'APIKey' user secret for $AIService..."
if ($AIService -eq $varOpenAI) {
dotnet user-secrets set --project $webapiProjectPath SemanticMemory:Services:OpenAI:APIKey $ApiKey
dotnet user-secrets set --project $webapiProjectPath KernelMemory:Services:OpenAI:APIKey $ApiKey
if ($LASTEXITCODE -ne 0) { exit(1) }
$AIServiceOverrides = @{
OpenAI = @{
Expand All @@ -151,9 +151,9 @@ if ($AIService -eq $varOpenAI) {
};
}
else {
dotnet user-secrets set --project $webapiProjectPath SemanticMemory:Services:AzureOpenAIText:APIKey $ApiKey
dotnet user-secrets set --project $webapiProjectPath KernelMemory:Services:AzureOpenAIText:APIKey $ApiKey
if ($LASTEXITCODE -ne 0) { exit(1) }
dotnet user-secrets set --project $webapiProjectPath SemanticMemory:Services:AzureOpenAIEmbedding:APIKey $ApiKey
dotnet user-secrets set --project $webapiProjectPath KernelMemory:Services:AzureOpenAIEmbedding:APIKey $ApiKey
if ($LASTEXITCODE -ne 0) { exit(1) }
$AIServiceOverrides = @{
AzureOpenAIText = @{
Expand All @@ -180,7 +180,7 @@ $appsettingsOverrides = @{
Planner = @{
Model = $PlannerModel
};
SemanticMemory = @{
KernelMemory = @{
TextGeneratorType = $AIService;
DataIngestion = @{
EmbeddingGeneratorTypes = @($AIService)
Expand Down
8 changes: 4 additions & 4 deletions scripts/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ WEBAPI_PROJECT_PATH="${SCRIPT_DIRECTORY}/../webapi"

echo "Setting 'APIKey' user secret for $AI_SERVICE..."
if [ "$AI_SERVICE" = "$ENV_OPEN_AI" ]; then
dotnet user-secrets set --project $WEBAPI_PROJECT_PATH SemanticMemory:Services:OpenAI:APIKey $API_KEY
dotnet user-secrets set --project $WEBAPI_PROJECT_PATH KernelMemory:Services:OpenAI:APIKey $API_KEY
if [ $? -ne 0 ]; then exit 1; fi
AISERVICE_OVERRIDES="{
\"OpenAI\":
Expand All @@ -168,9 +168,9 @@ if [ "$AI_SERVICE" = "$ENV_OPEN_AI" ]; then
}
}"
else
dotnet user-secrets set --project $WEBAPI_PROJECT_PATH SemanticMemory:Services:AzureOpenAIText:APIKey $API_KEY
dotnet user-secrets set --project $WEBAPI_PROJECT_PATH KernelMemory:Services:AzureOpenAIText:APIKey $API_KEY
if [ $? -ne 0 ]; then exit 1; fi
dotnet user-secrets set --project $WEBAPI_PROJECT_PATH SemanticMemory:Services:AzureOpenAIEmbedding:APIKey $API_KEY
dotnet user-secrets set --project $WEBAPI_PROJECT_PATH KernelMemory:Services:AzureOpenAIEmbedding:APIKey $API_KEY
if [ $? -ne 0 ]; then exit 1; fi
AISERVICE_OVERRIDES="{
\"AzureOpenAIText\": {
Expand All @@ -197,7 +197,7 @@ APPSETTINGS_OVERRIDES="{
\"Planner\": {
\"Model\": \"${PLANNER_MODEL}\"
},
\"SemanticMemory\": {
\"KernelMemory\": {
\"TextGeneratorType\": \"${AI_SERVICE}\",
\"DataIngestion\": {
\"EmbeddingGeneratorTypes\": [\"${AI_SERVICE}\"]
Expand Down
Loading

0 comments on commit c970dc0

Please sign in to comment.