Skip to content

Commit

Permalink
Misc dev improvements (#774)
Browse files Browse the repository at this point in the history
  • Loading branch information
dluc authored Sep 7, 2024
1 parent 9bad713 commit 6c4d705
Show file tree
Hide file tree
Showing 32 changed files with 60 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<PackageVersion Include="Microsoft.KernelMemory.Core" Version="0.72.240904.1" />
<PackageVersion Include="Microsoft.KernelMemory.Service.AspNetCore" Version="0.72.240904.1" />
<PackageVersion Include="MongoDB.Driver.GridFS" Version="2.28.0" />
<PackageVersion Include="Moq" Version="4.20.71" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="OllamaSharp" Version="3.0.4" />
<PackageVersion Include="PdfPig" Version="0.1.8" />
Expand Down
1 change: 1 addition & 0 deletions applications/tests/Evaluation.Tests/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void ConfigureHost(IHostBuilder hostBuilder)
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddUserSecrets<Startup>()
.AddEnvironmentVariables()
.Build();
Expand Down
1 change: 1 addition & 0 deletions examples/002-dotnet-Serverless/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public static async Task Main()

new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build()
.BindSection("KernelMemory", memoryConfiguration)
Expand Down
1 change: 1 addition & 0 deletions examples/101-dotnet-custom-Prompts/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static async Task Main()

new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build()
.BindSection("KernelMemory:Services:OpenAI", openAIConfig)
Expand Down
1 change: 1 addition & 0 deletions examples/103-dotnet-custom-EmbeddingGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static void Main()

new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build()
.BindSection("KernelMemory:Services:AzureOpenAIText", azureOpenAITextConfig);
Expand Down
1 change: 1 addition & 0 deletions examples/104-dotnet-custom-LLM/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public static void Main()

new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build()
.BindSection("KernelMemory:Services:AzureOpenAIEmbedding", azureOpenAIEmbeddingConfig);
Expand Down
1 change: 1 addition & 0 deletions examples/105-dotnet-serverless-llamasharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build()
.BindSection("KernelMemory:Services:LlamaSharp", llamaConfig)
Expand Down
1 change: 1 addition & 0 deletions examples/106-dotnet-retrieve-synthetics/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
WebApplicationBuilder appBuilder = WebApplication.CreateBuilder();
appBuilder.Configuration
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddEnvironmentVariables()
.Build()
Expand Down
1 change: 1 addition & 0 deletions examples/108-dotnet-custom-content-decoders/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build()
.BindSection("KernelMemory:Services:OpenAI", openAIConfig)
Expand Down
1 change: 1 addition & 0 deletions examples/110-dotnet-anthropic/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddEnvironmentVariables()
.Build()
Expand Down
1 change: 1 addition & 0 deletions examples/111-dotnet-azure-ai-hybrid-search/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static async Task Main()

new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build()
.BindSection("KernelMemory:Services:AzureOpenAIText", azureOpenAITextConfig)
Expand Down
1 change: 1 addition & 0 deletions examples/206-dotnet-configuration-and-logging/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static async Task Main()
// new ConfigurationBuilder()
// // Read settings from files
// .AddJsonFile("appsettings.json")
// .AddJsonFile("appsettings.development.json", optional: true)
// .AddJsonFile("appsettings.Development.json", optional: true)
// .AddIniFile("...")
// .AddXmlFile("...")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static async Task Main()
var openAIConfig = new OpenAIConfig();
new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build()
.BindSection("KernelMemory:Services:OpenAI", openAIConfig);
Expand Down
1 change: 1 addition & 0 deletions examples/210-KM-without-builder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static async Task Main()
WebApplicationBuilder appBuilder = WebApplication.CreateBuilder();
appBuilder.Configuration
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddEnvironmentVariables();
var app = appBuilder.Build();
Expand Down
1 change: 1 addition & 0 deletions examples/301-discord-test-application/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static void Main(string[] args)

appBuilder.Configuration
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddEnvironmentVariables()
.AddCommandLine(args);
Expand Down
1 change: 1 addition & 0 deletions examples/401-evaluation/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build()
.BindSection("KernelMemory", memoryConfiguration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void ConfigureHost(IHostBuilder hostBuilder)
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddUserSecrets<Startup>()
.AddEnvironmentVariables()
.Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static async Task Main()
{
var cfg = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void ConfigureHost(IHostBuilder hostBuilder)
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddUserSecrets<Startup>()
.AddEnvironmentVariables()
.Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void ConfigureHost(IHostBuilder hostBuilder)
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddUserSecrets<Startup>()
.AddEnvironmentVariables()
.Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void ConfigureHost(IHostBuilder hostBuilder)
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddUserSecrets<Startup>()
.AddEnvironmentVariables()
.Build();
Expand Down
56 changes: 27 additions & 29 deletions extensions/Postgres/Postgres.FunctionalTests/ConcurrencyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,35 @@ public async Task CreateDeleteIndexConcurrencyTest(string type)
break;

case "customSQL":
config = new PostgresConfig
config = this.PostgresConfig;
config.TableNamePrefix = "custom_sql";
config.Columns = new Dictionary<string, string>
{
ConnectionString = this.PostgresConfig.ConnectionString,
TableNamePrefix = "custom_sql",
Columns = new Dictionary<string, string>()
{
{ "id", "id" },
{ "embedding", "embedding" },
{ "tags", "tags" },
{ "content", "content" },
{ "payload", "payload" }
},
CreateTableSql = new List<string>
{
"""
BEGIN;
SELECT pg_advisory_xact_lock(%%lock_id%%);
CREATE TABLE IF NOT EXISTS %%table_name%% (
id TEXT NOT NULL PRIMARY KEY,
embedding vector(%%vector_size%%),
tags TEXT[] DEFAULT '{}'::TEXT[] NOT NULL,
content TEXT DEFAULT '' NOT NULL,
payload JSONB DEFAULT '{}'::JSONB NOT NULL,
some_text TEXT DEFAULT '',
last_update TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_tags ON %%table_name%% USING GIN(tags);
COMMIT;
"""
}
{ "id", "id" },
{ "embedding", "embedding" },
{ "tags", "tags" },
{ "content", "content" },
{ "payload", "payload" }
};
config.CreateTableSql =
[
"""
BEGIN;
SELECT pg_advisory_xact_lock(%%lock_id%%);
CREATE TABLE IF NOT EXISTS %%table_name%% (
id TEXT NOT NULL PRIMARY KEY,
embedding vector(%%vector_size%%),
tags TEXT[] DEFAULT '{}'::TEXT[] NOT NULL,
content TEXT DEFAULT '' NOT NULL,
payload JSONB DEFAULT '{}'::JSONB NOT NULL,
some_text TEXT DEFAULT '',
last_update TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_tags ON %%table_name%% USING GIN(tags);
COMMIT;
"""
];

break;
}

Expand Down
1 change: 1 addition & 0 deletions extensions/Postgres/Postgres.FunctionalTests/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void ConfigureHost(IHostBuilder hostBuilder)
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddUserSecrets<Startup>()
.AddEnvironmentVariables()
.Build();
Expand Down
3 changes: 3 additions & 0 deletions extensions/Postgres/Postgres.TestApplication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ private static async Task Test1()
{
var cfg = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build();

Expand Down Expand Up @@ -96,6 +97,7 @@ private static async Task Test2()

new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build()
.BindSection("KernelMemory:Services:Postgres", postgresConfig)
Expand Down Expand Up @@ -145,6 +147,7 @@ private static async Task Test3()
new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.Development.json", optional: true)
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.custom-sql.json")
.Build()
.BindSection("KernelMemory:Services:Postgres", postgresConfig)
Expand Down
1 change: 1 addition & 0 deletions extensions/Postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ To use Postgres with Kernel Memory:

new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build()
.BindSection("KernelMemory:Services:Postgres", postgresConfig);
Expand Down
1 change: 1 addition & 0 deletions extensions/Qdrant/Qdrant.FunctionalTests/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void ConfigureHost(IHostBuilder hostBuilder)
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddUserSecrets<Startup>()
.AddEnvironmentVariables()
.Build();
Expand Down
1 change: 1 addition & 0 deletions extensions/Qdrant/Qdrant.TestApplication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static async Task Main()
{
var cfg = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build();

Expand Down
1 change: 1 addition & 0 deletions extensions/Redis/Redis.FunctionalTests/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void ConfigureHost(IHostBuilder hostBuilder)
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddUserSecrets<Startup>()
.AddEnvironmentVariables()
.Build();
Expand Down
1 change: 1 addition & 0 deletions extensions/Redis/Redis.TestApplication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public static async Task Main()
{
IConfiguration config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.Build();

Expand Down
1 change: 1 addition & 0 deletions extensions/SQLServer/SQLServer.FunctionalTests/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void ConfigureHost(IHostBuilder hostBuilder)
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddUserSecrets<Startup>()
.AddEnvironmentVariables()
.Build();
Expand Down
1 change: 1 addition & 0 deletions service/tests/Core.FunctionalTests/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void ConfigureHost(IHostBuilder hostBuilder)
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddUserSecrets<Startup>()
.AddEnvironmentVariables()
.Build();
Expand Down
1 change: 1 addition & 0 deletions service/tests/Service.FunctionalTests/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void ConfigureHost(IHostBuilder hostBuilder)
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile("appsettings.development.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddUserSecrets<Startup>()
.AddEnvironmentVariables()
.Build();
Expand Down

0 comments on commit 6c4d705

Please sign in to comment.