From 65b5f423ecbc33f875858438dd0e734b20f5905a Mon Sep 17 00:00:00 2001 From: Artur Kordowski <9746197+akordowski@users.noreply.github.com> Date: Mon, 15 Jul 2024 17:53:25 +0200 Subject: [PATCH 1/2] Rename AnthropicConfiguration class to AnthropicConfig --- examples/110-dotnet-anthropic/Program.cs | 2 +- .../{AnthropicConfiguration.cs => AnthropicConfig.cs} | 2 +- extensions/Anthropic/AnthropicTextGeneration.cs | 2 +- extensions/Anthropic/DependencyInjection.cs | 4 ++-- service/Service/ServiceConfiguration.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename extensions/Anthropic/{AnthropicConfiguration.cs => AnthropicConfig.cs} (98%) diff --git a/examples/110-dotnet-anthropic/Program.cs b/examples/110-dotnet-anthropic/Program.cs index 1fa228cd8..d6849127a 100644 --- a/examples/110-dotnet-anthropic/Program.cs +++ b/examples/110-dotnet-anthropic/Program.cs @@ -5,7 +5,7 @@ using Microsoft.KernelMemory.DocumentStorage.DevTools; using Microsoft.KernelMemory.MemoryStorage.DevTools; -var anthropicConfig = new AnthropicConfiguration(); +var anthropicConfig = new AnthropicConfig(); var azureOpenAIEmbeddingConfig = new AzureOpenAIConfig(); new ConfigurationBuilder() diff --git a/extensions/Anthropic/AnthropicConfiguration.cs b/extensions/Anthropic/AnthropicConfig.cs similarity index 98% rename from extensions/Anthropic/AnthropicConfiguration.cs rename to extensions/Anthropic/AnthropicConfig.cs index 21a120d52..da6a1baf1 100644 --- a/extensions/Anthropic/AnthropicConfiguration.cs +++ b/extensions/Anthropic/AnthropicConfig.cs @@ -7,7 +7,7 @@ namespace Microsoft.KernelMemory.AI.Anthropic; /// /// Configuration for Text Generation with Anthropic /// -public class AnthropicConfiguration +public class AnthropicConfig { /// /// Anthropic web service endpoint diff --git a/extensions/Anthropic/AnthropicTextGeneration.cs b/extensions/Anthropic/AnthropicTextGeneration.cs index 02ba52a00..c257d2aec 100644 --- a/extensions/Anthropic/AnthropicTextGeneration.cs +++ b/extensions/Anthropic/AnthropicTextGeneration.cs @@ -36,7 +36,7 @@ public sealed class AnthropicTextGeneration : ITextGenerator, IDisposable /// Optional factory used to inject a pre-configured HTTP client for requests to Anthropic API /// Optional factory used to inject configured loggers public AnthropicTextGeneration( - AnthropicConfiguration config, + AnthropicConfig config, ITextTokenizer? textTokenizer = null, IHttpClientFactory? httpClientFactory = null, ILoggerFactory? loggerFactory = null) diff --git a/extensions/Anthropic/DependencyInjection.cs b/extensions/Anthropic/DependencyInjection.cs index aaa8f0e7d..eda9c5d6d 100644 --- a/extensions/Anthropic/DependencyInjection.cs +++ b/extensions/Anthropic/DependencyInjection.cs @@ -23,7 +23,7 @@ public static partial class KernelMemoryBuilderExtensions /// Optional tokenizer, default one will be used if passed null. public static IKernelMemoryBuilder WithAnthropicTextGeneration( this IKernelMemoryBuilder builder, - AnthropicConfiguration config, + AnthropicConfig config, ITextTokenizer? textTokenizer = null) { builder.Services.AddAnthropicTextGeneration(config, textTokenizer); @@ -44,7 +44,7 @@ public static partial class DependencyInjection /// Tokenizer to measure content size public static IServiceCollection AddAnthropicTextGeneration( this IServiceCollection services, - AnthropicConfiguration config, + AnthropicConfig config, ITextTokenizer? textTokenizer = null) { services.AddSingleton(config); diff --git a/service/Service/ServiceConfiguration.cs b/service/Service/ServiceConfiguration.cs index 7d5819e0b..f714dbf7a 100644 --- a/service/Service/ServiceConfiguration.cs +++ b/service/Service/ServiceConfiguration.cs @@ -420,7 +420,7 @@ private void ConfigureTextGenerator(IKernelMemoryBuilder builder) break; case string x when x.Equals("Anthropic", StringComparison.OrdinalIgnoreCase): - builder.Services.AddAnthropicTextGeneration(this.GetServiceConfig("Anthropic")); + builder.Services.AddAnthropicTextGeneration(this.GetServiceConfig("Anthropic")); break; case string x when x.Equals("LlamaSharp", StringComparison.OrdinalIgnoreCase): From efa03fe0ab16aca031238596663cfbf2f6d2d0b3 Mon Sep 17 00:00:00 2001 From: Artur Kordowski <9746197+akordowski@users.noreply.github.com> Date: Mon, 15 Jul 2024 17:56:42 +0200 Subject: [PATCH 2/2] Raname methods tokenizer parameter to textTokenizer --- .../SemanticKernel/KernelMemoryBuilderExtensions.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/service/Core/SemanticKernel/KernelMemoryBuilderExtensions.cs b/service/Core/SemanticKernel/KernelMemoryBuilderExtensions.cs index 0ba291268..ad6b87761 100644 --- a/service/Core/SemanticKernel/KernelMemoryBuilderExtensions.cs +++ b/service/Core/SemanticKernel/KernelMemoryBuilderExtensions.cs @@ -22,19 +22,19 @@ public static partial class KernelMemoryBuilderExtensions /// KM builder /// SK text generation service instance /// SK text generator settings - /// Tokenizer used to count tokens used by prompts + /// Tokenizer used to count tokens used by prompts /// .NET logger factory /// KM builder public static IKernelMemoryBuilder WithSemanticKernelTextGenerationService( this IKernelMemoryBuilder builder, ITextGenerationService service, SemanticKernelConfig config, - ITextTokenizer? tokenizer = null, + ITextTokenizer? textTokenizer = null, ILoggerFactory? loggerFactory = null) { if (service == null) { throw new ConfigurationException("Memory Builder: the semantic kernel text generation service instance is NULL"); } - return builder.AddSingleton(new SemanticKernelTextGenerator(service, config, tokenizer, loggerFactory)); + return builder.AddSingleton(new SemanticKernelTextGenerator(service, config, textTokenizer, loggerFactory)); } /// @@ -44,7 +44,7 @@ public static IKernelMemoryBuilder WithSemanticKernelTextGenerationService( /// KM builder /// SK text embedding generation instance /// SK text embedding generator settings - /// Tokenizer used to count tokens sent to the embedding generator + /// Tokenizer used to count tokens sent to the embedding generator /// .NET logger factory /// Whether to use this embedding generator only during data ingestion, and not for retrieval (search and ask API) /// KM builder @@ -52,13 +52,13 @@ public static IKernelMemoryBuilder WithSemanticKernelTextEmbeddingGenerationServ this IKernelMemoryBuilder builder, ITextEmbeddingGenerationService service, SemanticKernelConfig config, - ITextTokenizer? tokenizer = null, + ITextTokenizer? textTokenizer = null, ILoggerFactory? loggerFactory = null, bool onlyForRetrieval = false) { if (service == null) { throw new ConfigurationException("Memory Builder: the semantic kernel text embedding generation service instance is NULL"); } - var generator = new SemanticKernelTextEmbeddingGenerator(service, config, tokenizer, loggerFactory); + var generator = new SemanticKernelTextEmbeddingGenerator(service, config, textTokenizer, loggerFactory); builder.AddSingleton(generator); if (!onlyForRetrieval)