-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete Index creation and deletion, test insert (#5)
Update README including installation steps Fix/Improve SQL statements Update DI method names Extend test application Add build script Upgrade to latest KM nuget
- Loading branch information
Showing
14 changed files
with
427 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[*.cs] | ||
dotnet_diagnostic.CA2007.severity = none # no need of ConfigureAwait(false) in examples | ||
dotnet_diagnostic.CA1303.severity = none # Passing literal strings as values | ||
resharper_inconsistent_naming_highlighting = none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,65 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.KernelMemory; | ||
using Microsoft.KernelMemory.Postgres; | ||
|
||
namespace TestApplication; | ||
|
||
internal class Program | ||
{ | ||
public static void Main(string[] args) | ||
public static async Task Main(string[] args) | ||
{ | ||
var postgresConfig = new PostgresConfig(); | ||
var azureOpenAIEmbeddingConfig = new AzureOpenAIConfig(); | ||
var azureOpenAITextConfig = new AzureOpenAIConfig(); | ||
|
||
new ConfigurationBuilder() | ||
.AddJsonFile("appsettings.json") | ||
.AddJsonFile("appsettings.Development.json", optional: true) | ||
.Build() | ||
.BindSection("KernelMemory:Services:Postgres", postgresConfig) | ||
.BindSection("KernelMemory:Services:AzureOpenAIEmbedding", azureOpenAIEmbeddingConfig) | ||
.BindSection("KernelMemory:Services:AzureOpenAIText", azureOpenAITextConfig); | ||
|
||
// Concatenate our 'WithPostgres()' after 'WithOpenAIDefaults()' from the core nuget | ||
var test1 = new KernelMemoryBuilder() | ||
.WithOpenAIDefaults("api key") | ||
.WithPostgres("conn string") | ||
var mem1 = new KernelMemoryBuilder() | ||
.WithAzureOpenAITextGeneration(azureOpenAITextConfig) | ||
.WithAzureOpenAITextEmbeddingGeneration(azureOpenAIEmbeddingConfig) | ||
.WithPostgres(postgresConfig) | ||
.Build(); | ||
|
||
// Concatenate our 'WithPostgres()' before 'WithOpenAIDefaults()' from the core nuget | ||
var test2 = new KernelMemoryBuilder() | ||
.WithPostgres("conn string") | ||
.WithOpenAIDefaults("api key") | ||
var mem2 = new KernelMemoryBuilder() | ||
.WithPostgres(postgresConfig) | ||
.WithAzureOpenAITextGeneration(azureOpenAITextConfig) | ||
.WithAzureOpenAITextEmbeddingGeneration(azureOpenAIEmbeddingConfig) | ||
.Build(); | ||
|
||
// Concatenate our 'WithPostgres()' before and after KM builder extension methods from the core nuget | ||
var test3 = new KernelMemoryBuilder() | ||
var mem3 = new KernelMemoryBuilder() | ||
.WithSimpleFileStorage() | ||
.WithPostgres("conn string") | ||
.WithOpenAIDefaults("api key") | ||
.WithAzureOpenAITextGeneration(azureOpenAITextConfig) | ||
.WithPostgres(postgresConfig) | ||
.WithAzureOpenAITextEmbeddingGeneration(azureOpenAIEmbeddingConfig) | ||
.Build(); | ||
|
||
Console.WriteLine("Test complete"); | ||
await mem1.DeleteIndexAsync("index1"); | ||
await mem2.DeleteIndexAsync("index2"); | ||
await mem3.DeleteIndexAsync("index3"); | ||
|
||
await mem1.ImportTextAsync("this is a test 1", index: "index1"); | ||
await mem1.ImportTextAsync("this is a test 2", index: "index2"); | ||
await mem1.ImportTextAsync("this is a test 3", index: "index3"); | ||
|
||
foreach (var s in await mem1.ListIndexesAsync()) | ||
{ | ||
Console.WriteLine(s.Name); | ||
} | ||
|
||
await mem1.DeleteIndexAsync("index2"); | ||
await mem3.DeleteIndexAsync("index3"); | ||
|
||
Console.WriteLine("\n=== Test complete ==="); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.