Skip to content
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

Rename "MemoriesStore" to "MemoryStore" #138

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions scripts/deploy/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -227,27 +227,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 @@ -336,27 +336,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
12 changes: 6 additions & 6 deletions webapi/Controllers/ServiceOptionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,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 @@ -42,10 +42,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
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 @@ -53,8 +53,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
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.

60 changes: 60 additions & 0 deletions webapi/Options/MemoryStoreOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) Microsoft. All rights reserved.

namespace CopilotChat.WebApi.Options;

/// <summary>
/// Configuration settings for the memory store.
/// </summary>
public class MemoryStoreOptions
{
public const string PropertyName = "MemoryStore";

/// <summary>
/// The type of memory store to use.
/// </summary>
public enum MemoryStoreType
{
/// <summary>
/// Non-persistent memory store.
/// </summary>
Volatile,

/// <summary>
/// Qdrant based persistent memory store.
/// </summary>
Qdrant,

/// <summary>
/// Azure Cognitive Search persistent memory store.
/// </summary>
AzureCognitiveSearch,

/// <summary>
/// Chroma DB persistent memory store.
/// </summary>
Chroma
}

/// <summary>
/// Gets or sets the type of memory store to use.
/// </summary>
public MemoryStoreType Type { get; set; } = MemoryStoreType.Volatile;

/// <summary>
/// Gets or sets the configuration for the Qdrant memory store.
/// </summary>
[RequiredOnPropertyValue(nameof(Type), MemoryStoreType.Qdrant)]
public QdrantOptions? Qdrant { get; set; }

/// <summary>
/// Gets or sets the configuration for the Chroma memory store.
/// </summary>
[RequiredOnPropertyValue(nameof(Type), MemoryStoreType.Chroma)]
public VectorMemoryWebOptions? Chroma { get; set; }

/// <summary>
/// Gets or sets the configuration for the Azure Cognitive Search memory store.
/// </summary>
[RequiredOnPropertyValue(nameof(Type), MemoryStoreType.AzureCognitiveSearch)]
public AzureCognitiveSearchOptions? AzureCognitiveSearch { get; set; }
}
2 changes: 1 addition & 1 deletion webapi/Skills/ChatSkills/CopilotChatPlanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public async Task<SKContext> RunStepwisePlannerAsync(string goal, SKContext cont
}
catch (Exception e)
{
context.Log.LogError(e, "Error running stepwise planner");
context.Logger.LogError(e, "Error running stepwise planner");
throw;
}
}
Expand Down
10 changes: 5 additions & 5 deletions webapi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@
// Memory stores are used for storing new memories and retrieving semantically similar memories.
// - Supported Types are "volatile", "qdrant", "azurecognitivesearch", or "chroma".
// - When using Qdrant or Azure Cognitive Search, see ./README.md for deployment instructions.
// - Set "MemoriesStore:AzureCognitiveSearch:Key" using dotnet's user secrets (see above)
// (i.e. dotnet user-secrets set "MemoriesStore:AzureCognitiveSearch:Key" "MY_AZCOGSRCH_KEY")
// - Set "MemoriesStore:Qdrant:Key" using dotnet's user secrets (see above) if you are using a Qdrant Cloud instance.
// (i.e. dotnet user-secrets set "MemoriesStore:Qdrant:Key" "MY_QDRANTCLOUD_KEY")
// - Set "MemoryStore:AzureCognitiveSearch:Key" using dotnet's user secrets (see above)
// (i.e. dotnet user-secrets set "MemoryStore:AzureCognitiveSearch:Key" "MY_AZCOGSRCH_KEY")
// - Set "MemoryStore:Qdrant:Key" using dotnet's user secrets (see above) if you are using a Qdrant Cloud instance.
// (i.e. dotnet user-secrets set "MemoryStore:Qdrant:Key" "MY_QDRANTCLOUD_KEY")
//
"MemoriesStore": {
"MemoryStore": {
"Type": "volatile",
"Qdrant": {
"Host": "http://localhost",
Expand Down
6 changes: 3 additions & 3 deletions webapp/src/components/chat/tabs/DocumentsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ export const DocumentsTab: React.FC = () => {
{/* Hardcode vector database as we don't support switching vector store dynamically now. */}
<div className={classes.vectorDatabase}>
<Label size="large">Vector Database</Label>
<RadioGroup defaultValue={serviceOptions.memoriesStore.selectedType} layout="horizontal">
{serviceOptions.memoriesStore.types.map((storeType) => {
<RadioGroup defaultValue={serviceOptions.memoryStore.selectedType} layout="horizontal">
{serviceOptions.memoryStore.types.map((storeType) => {
return (
<Radio
key={storeType}
value={storeType}
label={storeType}
disabled={storeType !== serviceOptions.memoriesStore.selectedType}
disabled={storeType !== serviceOptions.memoryStore.selectedType}
/>
);
})}
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/libs/models/ServiceOptions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.

export interface MemoriesStore {
export interface MemoryStore {
types: string[];
selectedType: string;
}

export interface ServiceOptions {
memoriesStore: MemoriesStore;
memoryStore: MemoryStore;
}
2 changes: 1 addition & 1 deletion webapp/src/redux/features/app/AppState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,5 @@ export const initialState: AppState = {
tokenUsage: {},
features: Features,
settings: Settings,
serviceOptions: { memoriesStore: { types: [], selectedType: '' } },
serviceOptions: { memoryStore: { types: [], selectedType: '' } },
};