Skip to content

Commit

Permalink
Merge branch 'main' into feature-better-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
gitri-ms committed Aug 10, 2023
2 parents 9527350 + 6b6f369 commit ddfbdf6
Show file tree
Hide file tree
Showing 37 changed files with 512 additions and 179 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/copilot-build-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: copilot-build-backend
on:
pull_request:
branches: ["main"]
merge_group:
branches: ["main"]
paths:
- "webapi/**"
workflow_call:
outputs:
artifact:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/copilot-build-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
workflow_dispatch:
pull_request:
branches: ["main"]
paths:
- "webapp/**"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
Empty file modified scripts/deploy/deploy-azure.sh
100644 → 100755
Empty file.
10 changes: 5 additions & 5 deletions scripts/deploy/deploy-webapp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Write-Host "webapiScope: $webapiScope"
# Set ASCII as default encoding for Out-File
$PSDefaultParameterValues['Out-File:Encoding'] = 'ascii'

$envFilePath = "$PSScriptRoot/../webapp/.env"
$envFilePath = "$PSScriptRoot/../../webapp/.env"
Write-Host "Writing environment variables to '$envFilePath'..."
"REACT_APP_BACKEND_URI=https://$webapiUrl/" | Out-File -FilePath $envFilePath
"REACT_APP_AUTH_TYPE=AzureAd" | Out-File -FilePath $envFilePath -Append
Expand All @@ -72,16 +72,16 @@ Write-Host "Writing environment variables to '$envFilePath'..."
"REACT_APP_AAD_API_SCOPE=api://$webapiClientId/$webapiScope" | Out-File -FilePath $envFilePath -Append

Write-Host "Generating SWA config..."
$swaConfig = $(Get-Content "$PSScriptRoot/../webapp/template.swa-cli.config.json" -Raw)
$swaConfig = $(Get-Content "$PSScriptRoot/../../webapp/template.swa-cli.config.json" -Raw)
$swaConfig = $swaConfig.Replace("{{appDevserverUrl}}", "https://$webappUrl")
$swaConfig = $swaConfig.Replace("{{appName}}", "$webappName")
$swaConfig = $swaConfig.Replace("{{resourceGroup}}", "$ResourceGroupName")
$swaConfig = $swaConfig.Replace("{{subscription-id}}", "$Subscription")

$swaConfig | Out-File -FilePath "$PSScriptRoot/../webapp/swa-cli.config.json"
Write-Host $(Get-Content "$PSScriptRoot/../webapp/swa-cli.config.json" -Raw)
$swaConfig | Out-File -FilePath "$PSScriptRoot/../../webapp/swa-cli.config.json"
Write-Host $(Get-Content "$PSScriptRoot/../../webapp/swa-cli.config.json" -Raw)

Push-Location -Path "$PSScriptRoot/../webapp"
Push-Location -Path "$PSScriptRoot/../../webapp"
Write-Host "Installing yarn dependencies..."
yarn install
if ($LASTEXITCODE -ne 0) {
Expand Down
8 changes: 4 additions & 4 deletions scripts/deploy/deploy-webapp.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ echo "WEB_API_CLIENT_ID: $WEB_API_CLIENT_ID"
eval WEB_API_SCOPE=$(az webapp config appsettings list --name $WEB_API_NAME --resource-group $RESOURCE_GROUP | jq '.[] | select(.name=="Authentication:AzureAd:Scopes").value')
echo "WEB_API_SCOPE: $WEB_API_SCOPE"

ENV_FILE_PATH="$SCRIPT_ROOT/../webapp/.env"
ENV_FILE_PATH="$SCRIPT_ROOT/../../webapp/.env"
echo "Writing environment variables to '$ENV_FILE_PATH'..."
echo "REACT_APP_BACKEND_URI=https://$WEB_API_URL/" > $ENV_FILE_PATH
echo "REACT_APP_AUTH_TYPE=AzureAd" >> $ENV_FILE_PATH
Expand All @@ -103,16 +103,16 @@ echo "REACT_APP_AAD_CLIENT_ID=$APPLICATION_ID" >> $ENV_FILE_PATH
echo "REACT_APP_AAD_API_SCOPE=api://$WEB_API_CLIENT_ID/$WEB_API_SCOPE" >> $ENV_FILE_PATH

echo "Writing swa-cli.config.json..."
SWA_CONFIG_FILE_PATH="$SCRIPT_ROOT/../webapp/swa-cli.config.json"
SWA_CONFIG_TEMPLATE_FILE_PATH="$SCRIPT_ROOT/../webapp/template.swa-cli.config.json"
SWA_CONFIG_FILE_PATH="$SCRIPT_ROOT/../../webapp/swa-cli.config.json"
SWA_CONFIG_TEMPLATE_FILE_PATH="$SCRIPT_ROOT/../../webapp/template.swa-cli.config.json"
swaConfig=`cat $SWA_CONFIG_TEMPLATE_FILE_PATH`
swaConfig=$(echo $swaConfig | sed "s/{{appDevserverUrl}}/https:\/\/${WEB_APP_URL}/")
swaConfig=$(echo $swaConfig | sed "s/{{appName}}/$WEB_API_NAME/")
swaConfig=$(echo $swaConfig | sed "s/{{resourceGroup}}/$RESOURCE_GROUP/")
swaConfig=$(echo $swaConfig | sed "s/{{subscription-id}}/$SUBSCRIPTION/")
echo $swaConfig > $SWA_CONFIG_FILE_PATH

pushd "$SCRIPT_ROOT/../webapp"
pushd "$SCRIPT_ROOT/../../webapp"

echo "Installing yarn dependencies..."
yarn install
Expand Down
12 changes: 6 additions & 6 deletions scripts/deploy/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -244,27 +244,27 @@ resource appServiceWebConfig 'Microsoft.Web/sites/config@2022-09-01' = {
value: deployCosmosDB ? cosmosAccount.listConnectionStrings().connectionStrings[0].connectionString : ''
}
{
name: 'MemoriesStore:Type'
name: 'MemoryStore:Type'
value: memoryStore
}
{
name: 'MemoriesStore:Qdrant:Host'
name: 'MemoryStore:Qdrant:Host'
value: memoryStore == 'Qdrant' ? 'https://${appServiceQdrant.properties.defaultHostName}' : ''
}
{
name: 'MemoriesStore:Qdrant:Port'
name: 'MemoryStore:Qdrant:Port'
value: '443'
}
{
name: 'MemoriesStore:AzureCognitiveSearch:UseVectorSearch'
name: 'MemoryStore:AzureCognitiveSearch:UseVectorSearch'
value: 'true'
}
{
name: 'MemoriesStore:AzureCognitiveSearch:Endpoint'
name: 'MemoryStore:AzureCognitiveSearch:Endpoint'
value: memoryStore == 'AzureCognitiveSearch' ? 'https://${azureCognitiveSearch.name}.search.windows.net' : ''
}
{
name: 'MemoriesStore:AzureCognitiveSearch:Key'
name: 'MemoryStore:AzureCognitiveSearch:Key'
value: memoryStore == 'AzureCognitiveSearch' ? azureCognitiveSearch.listAdminKeys().primaryKey : ''
}
{
Expand Down
12 changes: 6 additions & 6 deletions scripts/deploy/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,27 +362,27 @@
"value": "[if(parameters('deployCosmosDB'), listConnectionStrings(resourceId('Microsoft.DocumentDB/databaseAccounts', toLower(format('cosmos-{0}', variables('uniqueName')))), '2023-04-15').connectionStrings[0].connectionString, '')]"
},
{
"name": "MemoriesStore:Type",
"name": "MemoryStore:Type",
"value": "[parameters('memoryStore')]"
},
{
"name": "MemoriesStore:Qdrant:Host",
"name": "MemoryStore:Qdrant:Host",
"value": "[if(equals(parameters('memoryStore'), 'Qdrant'), format('https://{0}', reference(resourceId('Microsoft.Web/sites', format('app-{0}-qdrant', variables('uniqueName'))), '2022-09-01').defaultHostName), '')]"
},
{
"name": "MemoriesStore:Qdrant:Port",
"name": "MemoryStore:Qdrant:Port",
"value": "443"
},
{
"name": "MemoriesStore:AzureCognitiveSearch:UseVectorSearch",
"name": "MemoryStore:AzureCognitiveSearch:UseVectorSearch",
"value": "true"
},
{
"name": "MemoriesStore:AzureCognitiveSearch:Endpoint",
"name": "MemoryStore:AzureCognitiveSearch:Endpoint",
"value": "[if(equals(parameters('memoryStore'), 'AzureCognitiveSearch'), format('https://{0}.search.windows.net', format('acs-{0}', variables('uniqueName'))), '')]"
},
{
"name": "MemoriesStore:AzureCognitiveSearch:Key",
"name": "MemoryStore:AzureCognitiveSearch:Key",
"value": "[if(equals(parameters('memoryStore'), 'AzureCognitiveSearch'), listAdminKeys(resourceId('Microsoft.Search/searchServices', format('acs-{0}', variables('uniqueName'))), '2022-09-01').primaryKey, '')]"
},
{
Expand Down
Empty file modified scripts/deploy/package-webapi.ps1
100644 → 100755
Empty file.
12 changes: 6 additions & 6 deletions webapi/Controllers/ServiceOptionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ public class ServiceOptionsController : ControllerBase
{
private readonly ILogger<ServiceOptionsController> _logger;

private readonly MemoriesStoreOptions _memoriesStoreOptions;
private readonly MemoryStoreOptions _memoryStoreOptions;

public ServiceOptionsController(
ILogger<ServiceOptionsController> logger,
IOptions<MemoriesStoreOptions> memoriesStoreOptions)
IOptions<MemoryStoreOptions> memoryStoreOptions)
{
this._logger = logger;
this._memoriesStoreOptions = memoriesStoreOptions.Value;
this._memoryStoreOptions = memoryStoreOptions.Value;
}

// TODO: [Issue #95] Include all service options in a single response.
Expand All @@ -40,10 +40,10 @@ public IActionResult GetServiceOptions()
return this.Ok(
new ServiceOptionsResponse()
{
MemoriesStore = new MemoriesStoreOptionResponse()
MemoryStore = new MemoryStoreOptionResponse()
{
Types = Enum.GetNames(typeof(MemoriesStoreOptions.MemoriesStoreType)),
SelectedType = this._memoriesStoreOptions.Type.ToString()
Types = Enum.GetNames(typeof(MemoryStoreOptions.MemoryStoreType)),
SelectedType = this._memoryStoreOptions.Type.ToString()
}
}
);
Expand Down
1 change: 1 addition & 0 deletions webapi/CopilotChatWebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PackageReference Include="Azure.AI.FormRecognizer" Version="4.0.0" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.35.2" />
<PackageReference Include="Microsoft.SemanticKernel" Version="0.19.230804.2-preview" />
<PackageReference Include="Microsoft.SemanticKernel.Planning.StepwisePlanner" Version="0.19.230804.2-preview" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.AI.OpenAI" Version="0.19.230804.2-preview" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.Memory.AzureCognitiveSearch" Version="0.19.230804.2-preview" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.Memory.Chroma" Version="0.19.230804.2-preview" />
Expand Down
20 changes: 10 additions & 10 deletions webapi/Extensions/SemanticKernelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
using Microsoft.SemanticKernel.Orchestration;
using Microsoft.SemanticKernel.Skills.Core;
using Microsoft.SemanticKernel.TemplateEngine;
using static CopilotChat.WebApi.Options.MemoriesStoreOptions;
using static CopilotChat.WebApi.Options.MemoryStoreOptions;

namespace CopilotChat.WebApi.Extensions;

Expand Down Expand Up @@ -155,18 +155,18 @@ private static Task RegisterSkillsAsync(IServiceProvider sp, IKernel kernel)
/// </summary>
private static void AddSemanticTextMemory(this IServiceCollection services)
{
MemoriesStoreOptions config = services.BuildServiceProvider().GetRequiredService<IOptions<MemoriesStoreOptions>>().Value;
MemoryStoreOptions config = services.BuildServiceProvider().GetRequiredService<IOptions<MemoryStoreOptions>>().Value;

switch (config.Type)
{
case MemoriesStoreType.Volatile:
case MemoryStoreType.Volatile:
services.AddSingleton<IMemoryStore, VolatileMemoryStore>();
break;

case MemoriesStoreType.Qdrant:
case MemoryStoreType.Qdrant:
if (config.Qdrant == null)
{
throw new InvalidOperationException("MemoriesStore type is Qdrant and Qdrant configuration is null.");
throw new InvalidOperationException("MemoryStore type is Qdrant and Qdrant configuration is null.");
}

services.AddSingleton<IMemoryStore>(sp =>
Expand All @@ -189,10 +189,10 @@ private static void AddSemanticTextMemory(this IServiceCollection services)
});
break;

case MemoriesStoreType.AzureCognitiveSearch:
case MemoryStoreType.AzureCognitiveSearch:
if (config.AzureCognitiveSearch == null)
{
throw new InvalidOperationException("MemoriesStore type is AzureCognitiveSearch and AzureCognitiveSearch configuration is null.");
throw new InvalidOperationException("MemoryStore type is AzureCognitiveSearch and AzureCognitiveSearch configuration is null.");
}

services.AddSingleton<IMemoryStore>(sp =>
Expand All @@ -201,10 +201,10 @@ private static void AddSemanticTextMemory(this IServiceCollection services)
});
break;

case MemoriesStoreOptions.MemoriesStoreType.Chroma:
case MemoryStoreOptions.MemoryStoreType.Chroma:
if (config.Chroma == null)
{
throw new InvalidOperationException("MemoriesStore type is Chroma and Chroma configuration is null.");
throw new InvalidOperationException("MemoryStore type is Chroma and Chroma configuration is null.");
}

services.AddSingleton<IMemoryStore>(sp =>
Expand All @@ -222,7 +222,7 @@ private static void AddSemanticTextMemory(this IServiceCollection services)
break;

default:
throw new InvalidOperationException($"Invalid 'MemoriesStore' type '{config.Type}'.");
throw new InvalidOperationException($"Invalid 'MemoryStore' type '{config.Type}'.");
}

services.AddScoped<ISemanticTextMemory>(sp => new SemanticTextMemory(
Expand Down
4 changes: 2 additions & 2 deletions webapi/Extensions/ServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public static IServiceCollection AddOptions(this IServiceCollection services, Co
.PostConfigure(TrimStringProperties);

// Memory store configuration
services.AddOptions<MemoriesStoreOptions>()
.Bind(configuration.GetSection(MemoriesStoreOptions.PropertyName))
services.AddOptions<MemoryStoreOptions>()
.Bind(configuration.GetSection(MemoryStoreOptions.PropertyName))
.ValidateDataAnnotations()
.ValidateOnStart()
.PostConfigure(TrimStringProperties);
Expand Down
1 change: 1 addition & 0 deletions webapi/Models/Response/ProposedPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public enum PlanType
{
Action, // single-step
Sequential, // multi-step
Stepwise, // MRKL style planning
}

// State of Plan
Expand Down
14 changes: 7 additions & 7 deletions webapi/Models/Response/ServiceOptionsResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ namespace CopilotChat.WebApi.Models.Response;
public class ServiceOptionsResponse
{
/// <summary>
/// The memories store that is configured.
/// Configured memory store.
/// </summary>
[JsonPropertyName("memoriesStore")]
public MemoriesStoreOptionResponse MemoriesStore { get; set; } = new MemoriesStoreOptionResponse();
[JsonPropertyName("memoryStore")]
public MemoryStoreOptionResponse MemoryStore { get; set; } = new MemoryStoreOptionResponse();
}

/// <summary>
/// Response to memoriesStoreType request.
/// Response to memoryStoreType request.
/// </summary>
public class MemoriesStoreOptionResponse
public class MemoryStoreOptionResponse
{
/// <summary>
/// All the available memories store types.
/// All the available memory store types.
/// </summary>
[JsonPropertyName("types")]
public IEnumerable<string> Types { get; set; } = Enumerable.Empty<string>();

/// <summary>
/// The selected memories store type.
/// The selected memory store type.
/// </summary>
[JsonPropertyName("selectedType")]
public string SelectedType { get; set; } = string.Empty;
Expand Down
60 changes: 0 additions & 60 deletions webapi/Options/MemoriesStoreOptions.cs

This file was deleted.

Loading

0 comments on commit ddfbdf6

Please sign in to comment.