Skip to content

Commit

Permalink
Refactor settings management
Browse files Browse the repository at this point in the history
  • Loading branch information
ciprianjichici committed Jul 28, 2024
1 parent 65f8502 commit 4fd40d7
Show file tree
Hide file tree
Showing 25 changed files with 528 additions and 299 deletions.
9 changes: 9 additions & 0 deletions src/dotnet/Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>RoleDefinitionNames.cs</LastGenOutput>
</None>
<None Update="Constants\Configuration\AppConfigurationKeyFilters.tt">
<LastGenOutput>AppConfigurationKeyFilters.cs</LastGenOutput>
<Generator>TextTemplatingFileGenerator</Generator>
</None>
<None Update="Constants\Configuration\AppConfigurationKeySections.tt">
<LastGenOutput>AppConfigurationKeySections.cs</LastGenOutput>
<Generator>TextTemplatingFileGenerator</Generator>
Expand Down Expand Up @@ -129,6 +133,11 @@
<AutoGen>True</AutoGen>
<DependentUpon>RoleDefinitionNames.tt</DependentUpon>
</Compile>
<Compile Update="Constants\Configuration\AppConfigurationKeyFilters.cs">
<DependentUpon>AppConfigurationKeyFilters.tt</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
<Compile Update="Constants\Configuration\AppConfigurationKeySections.cs">
<DependentUpon>AppConfigurationKeySections.tt</DependentUpon>
<DesignTime>True</DesignTime>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.IO" #>
<#@ assembly name="System.Text.Json" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ assembly name="System.Memory" #>
<#@ import namespace="System.Text.Json" #>
<#@ import namespace="System.Text.Json.Nodes" #>
<#@ output extension=".cs" #>
<#
string inputFileName = this.Host.ResolvePath($"../Data/AppConfiguration.json");
string inputContent = File.ReadAllText(inputFileName);
var jsonObjects = JsonNode.Parse(inputContent)!;
Func<JsonNode, string> getName = n => n.GetValue<string>().Replace(":", "_");
#>
namespace FoundationaLLM.Common.Constants.Configuration
{
/// <summary>
/// Defines all configuration section filters used to select subsets of configuration settings.
/// </summary>
public static partial class AppConfigurationKeyFilters
{<#
foreach (var jsonObject in jsonObjects.AsArray())
{
var configurationSection = jsonObject["configuration_section"];
if (configurationSection != null)
{
var description = configurationSection["description"].GetValue<string>();
description = "Filter for the "
+ Char.ToLowerInvariant(description[0]) + description.Substring(1);
#>

/// <summary>
/// <#=description#>
/// </summary>
public const string FoundationaLLM_<#=getName(jsonObject["namespace"])#> =
"FoundationaLLM:<#=jsonObject["namespace"]#>:*";
<#
}
}
#>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ public static partial class AppConfigurationKeySections
public const string FoundationaLLM_Instance =
"FoundationaLLM:Instance";

/// <summary>
/// Configuration section used to identify the Azure Key Vault settings related to the FoundationaLLM instance.
/// </summary>
public const string FoundationaLLM_Configuration =
"FoundationaLLM:Configuration";

/// <summary>
/// Configuration section used to identify the storage settings for the FoundationaLLM.AIModel resource provider.
/// </summary>
Expand Down Expand Up @@ -71,6 +77,12 @@ public static partial class AppConfigurationKeySections
public const string FoundationaLLM_APIEndpoints_CoreAPI_Configuration =
"FoundationaLLM:APIEndpoints:CoreAPI:Configuration";

/// <summary>
/// Configuration section used to identify the Entra ID authentication settings for Core API.
/// </summary>
public const string FoundationaLLM_APIEndpoints_CoreAPI_Configuration_Entra =
"FoundationaLLM:APIEndpoints:CoreAPI:Configuration:Entra";

/// <summary>
/// Configuration section used to identify the Cosmos DB settings for the Core API.
/// </summary>
Expand Down Expand Up @@ -119,6 +131,12 @@ public static partial class AppConfigurationKeySections
public const string FoundationaLLM_APIEndpoints_SemanticKernelAPI =
"FoundationaLLM:APIEndpoints:SemanticKernelAPI";

/// <summary>
/// Configuration section used to identify the Entra ID authentication settings for Management API.
/// </summary>
public const string FoundationaLLM_APIEndpoints_ManagementAPI_Configuration_Entra =
"FoundationaLLM:APIEndpoints:ManagementAPI:Configuration:Entra";

/// <summary>
/// Configuration section used to identify the authentication settings for the Vectorization API.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,10 @@ public static class AppConfigurationKeys

#endregion

#region FoundationaLLM:Vectorization:TextEmbedding:Gateway

#endregion

#region FoundationaLLM:DataSources

#endregion
Expand Down
146 changes: 0 additions & 146 deletions src/dotnet/Common/Constants/Configuration/AppConfigurationKeysOld.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,47 @@ public static partial class DependencyInjectionKeys
/// </summary>
public const string FoundationaLLM_ResourceProviders_Vectorization =
"FoundationaLLM:ResourceProviders:Vectorization";

/// <summary>
/// Dependency injection key used to inject the implementation of IIndexingService based on Azure AI Search.
/// </summary>
public const string FoundationaLLM_APIEndpoints_AzureAISearchVectorStore_Configuration =
"FoundationaLLM:APIEndpoints:AzureAISearchVectorStore:Configuration";

/// <summary>
/// Dependency injection key used to inject the implementation of IIndexingService based on Azure Cosmos DB NoSQL.
/// </summary>
public const string FoundationaLLM_APIEndpoints_AzureCosmosDBNoSQLVectorStore_Configuration =
"FoundationaLLM:APIEndpoints:AzureCosmosDBNoSQLVectorStore:Configuration";

/// <summary>
/// Dependency injection key used to inject the implementation of IIndexingService based on Azure PostgreSQL.
/// </summary>
public const string FoundationaLLM_APIEndpoints_AzurePostgreSQLVectorStore_Configuration =
"FoundationaLLM:APIEndpoints:AzurePostgreSQLVectorStore:Configuration";

/// <summary>
/// Dependency injection key used to inject the IConfiguration section for vectorization steps.
/// </summary>
public const string FoundationaLLM_Vectorization_Steps =
"FoundationaLLM:Vectorization:Steps";

/// <summary>
/// Dependency injection key used to inject the IConfiguration section for vectorization queues.
/// </summary>
public const string FoundationaLLM_Vectorization_Queues =
"FoundationaLLM:Vectorization:Queues";

/// <summary>
/// Dependency injection key used to inject storage settings for the Vectorization state service.
/// </summary>
public const string FoundationaLLM_Vectorization_StateService_Storage =
"FoundationaLLM:Vectorization:StateService:Storage";

/// <summary>
/// Dependency injection key used to inject the ITextEmbeddingService implementation that uses the FoundationaLLM Gateway for embedding.
/// </summary>
public const string FoundationaLLM_Vectorization_TextEmbedding_Gateway =
"FoundationaLLM:Vectorization:TextEmbedding:Gateway";
}
}

This file was deleted.

Loading

0 comments on commit 4fd40d7

Please sign in to comment.