From cbabd3b0cd653882cbcd2d9eab953e511a13a280 Mon Sep 17 00:00:00 2001 From: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com> Date: Wed, 20 Dec 2023 16:45:53 -0500 Subject: [PATCH 1/3] Refactor to use DI --- README.md | 16 +-- .../AssemblyAI.SemanticKernel.csproj | 6 + ...ranscriptPlugin.cs => AssemblyAIPlugin.cs} | 48 ++++--- .../AssemblyAIPluginsOptions.cs | 20 +++ src/AssemblyAI.SemanticKernel/Extensions.cs | 134 ++++++++++++++++++ src/AssemblyAI.SemanticKernel/Transcript.cs | 12 ++ src/Sample/Program.cs | 46 +++--- src/Sample/Sample.csproj | 6 + src/Sample/appsettings.json | 6 + 9 files changed, 243 insertions(+), 51 deletions(-) rename src/AssemblyAI.SemanticKernel/{TranscriptPlugin.cs => AssemblyAIPlugin.cs} (81%) create mode 100644 src/AssemblyAI.SemanticKernel/AssemblyAIPluginsOptions.cs create mode 100644 src/AssemblyAI.SemanticKernel/Extensions.cs create mode 100644 src/AssemblyAI.SemanticKernel/Transcript.cs create mode 100644 src/Sample/appsettings.json diff --git a/README.md b/README.md index c11b5ca..255c5ca 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Add the [AssemblyAI.SemanticKernel NuGet package](https://www.nuget.org/packages dotnet add package AssemblyAI.SemanticKernel ``` -Next, register the `TranscriptPlugin` into your kernel: +Next, register the `AssemblyAI` plugin into your kernel: ```csharp using AssemblyAI.SemanticKernel; @@ -50,8 +50,8 @@ var arguments = new KernelArguments ["INPUT"] = "https://storage.googleapis.com/aai-docs-samples/espn.m4a" }; var result = await kernel.InvokeAsync( - TranscriptPlugin.PluginName, - TranscriptPlugin.TranscribeFunctionName, + AssemblyAIPlugin.PluginName, + AssemblyAIPlugin.TranscribeFunctionName, arguments ); Console.WriteLine(result.GetValue()); @@ -60,7 +60,7 @@ Console.WriteLine(result.GetValue()); You can get the transcript using `result.GetValue()`. You can also upload local audio and video file. To do this: -- Set the `TranscriptPlugin.AllowFileSystemAccess` property to `true`. +- Set the `AssemblyAI:AllowFileSystemAccess` configuration to `true`. - Configure the `INPUT` variable with a local file path. ```csharp @@ -69,15 +69,15 @@ kernel.ImportPluginFromObject( { AllowFileSystemAccess = true }, - TranscriptPlugin.PluginName + AssemblyAIPlugin.PluginName ); var arguments = new KernelArguments { ["INPUT"] = "https://storage.googleapis.com/aai-docs-samples/espn.m4a" }; var result = await kernel.InvokeAsync( - TranscriptPlugin.PluginName, - TranscriptPlugin.TranscribeFunctionName, + AssemblyAIPlugin.PluginName, + AssemblyAIPlugin.TranscribeFunctionName, arguments ); Console.WriteLine(result.GetValue()); @@ -88,7 +88,7 @@ You can also invoke the function from within a semantic function like this. ```csharp const string prompt = """ Here is a transcript: - {{TranscriptPlugin.Transcribe "https://storage.googleapis.com/aai-docs-samples/espn.m4a"}} + {{AssemblyAI.Transcribe "https://storage.googleapis.com/aai-docs-samples/espn.m4a"}} --- Summarize the transcript. """; diff --git a/src/AssemblyAI.SemanticKernel/AssemblyAI.SemanticKernel.csproj b/src/AssemblyAI.SemanticKernel/AssemblyAI.SemanticKernel.csproj index 376369c..4216102 100644 --- a/src/AssemblyAI.SemanticKernel/AssemblyAI.SemanticKernel.csproj +++ b/src/AssemblyAI.SemanticKernel/AssemblyAI.SemanticKernel.csproj @@ -31,6 +31,12 @@ true + + 8.0.0 + + + 8.0.0 + 1.0.1 diff --git a/src/AssemblyAI.SemanticKernel/TranscriptPlugin.cs b/src/AssemblyAI.SemanticKernel/AssemblyAIPlugin.cs similarity index 81% rename from src/AssemblyAI.SemanticKernel/TranscriptPlugin.cs rename to src/AssemblyAI.SemanticKernel/AssemblyAIPlugin.cs index eea1bc7..18e6c88 100644 --- a/src/AssemblyAI.SemanticKernel/TranscriptPlugin.cs +++ b/src/AssemblyAI.SemanticKernel/AssemblyAIPlugin.cs @@ -7,19 +7,42 @@ using System.Text; using System.Text.Json; using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Microsoft.SemanticKernel; namespace AssemblyAI.SemanticKernel { - public class TranscriptPlugin + public class AssemblyAIPlugin { - public const string PluginName = nameof(TranscriptPlugin); - private readonly string _apiKey; - public bool AllowFileSystemAccess { get; set; } + public const string PluginName = "AssemblyAI"; + private readonly AssemblyAIPluginsOptions _options; - public TranscriptPlugin(string apiKey) + private string ApiKey => _options.ApiKey; + + private bool AllowFileSystemAccess => _options.AllowFileSystemAccess; + + public AssemblyAIPlugin(string apiKey) { - _apiKey = apiKey; + _options = new AssemblyAIPluginsOptions + { + ApiKey = apiKey + }; + } + + public AssemblyAIPlugin(string apiKey, bool allowFileSystemAccess) + { + _options = new AssemblyAIPluginsOptions + { + ApiKey = apiKey, + AllowFileSystemAccess = allowFileSystemAccess + }; + } + + [ActivatorUtilitiesConstructor] + public AssemblyAIPlugin(IOptions options) + { + _options = options.Value; } public const string TranscribeFunctionName = nameof(Transcribe); @@ -37,14 +60,14 @@ string input using (var httpClient = new HttpClient()) { - httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(_apiKey); + httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(ApiKey); string audioUrl; if (TryGetPath(input, out var filePath)) { if (AllowFileSystemAccess == false) { throw new Exception( - "You need to allow file system access to upload files. Set TranscriptPlugin.AllowFileSystemAccess to true." + "You need to allow file system access to upload files. Set AssemblyAI:AllowFileSystemAccess to true." ); } @@ -136,13 +159,4 @@ private static async Task WaitForTranscriptToProcess(Transcript tran } } } - - public class Transcript - { - public string Id { get; set; } = null; - public string Status { get; set; } = null; - public string Text { get; set; } - - public string Error { get; set; } - } } \ No newline at end of file diff --git a/src/AssemblyAI.SemanticKernel/AssemblyAIPluginsOptions.cs b/src/AssemblyAI.SemanticKernel/AssemblyAIPluginsOptions.cs new file mode 100644 index 0000000..a29f7c3 --- /dev/null +++ b/src/AssemblyAI.SemanticKernel/AssemblyAIPluginsOptions.cs @@ -0,0 +1,20 @@ +namespace AssemblyAI.SemanticKernel +{ + /// + /// Options to configure the AssemblyAI plugin with. + /// + public class AssemblyAIPluginsOptions + { + /// + /// The AssemblyAI API key. Find your API key at https://www.assemblyai.com/app/account + /// + public string ApiKey { get; set; } + + /// + /// If true, you can transcribe audio files from disk. + /// The file be uploaded to AssemblyAI's server to transcribe and deleted when transcription is completed. + /// If false, an exception will be thrown when trying to transcribe files from disk. + /// + public bool AllowFileSystemAccess { get; set; } + } +} \ No newline at end of file diff --git a/src/AssemblyAI.SemanticKernel/Extensions.cs b/src/AssemblyAI.SemanticKernel/Extensions.cs new file mode 100644 index 0000000..8d35624 --- /dev/null +++ b/src/AssemblyAI.SemanticKernel/Extensions.cs @@ -0,0 +1,134 @@ +using System; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Microsoft.SemanticKernel; +// ReSharper disable UnusedMember.Global +// ReSharper disable MemberCanBePrivate.Global + +namespace AssemblyAI.SemanticKernel +{ + public static class Extensions + { + /// + /// Configure the AssemblyAI plugins using the specified configuration section path. + /// + /// + /// + public static IKernelBuilder AddAssemblyAIPlugin( + this IKernelBuilder builder + ) => AddAssemblyAIPlugin(builder, "AssemblyAI"); + + /// + /// Configure the AssemblyAI plugins using the specified configuration section path. + /// + /// + /// The path of the configuration section to bind options to + /// + public static IKernelBuilder AddAssemblyAIPlugin( + this IKernelBuilder builder, + string configSectionPath + ) + { + var services = builder.Services; + var optionsBuilder = services.AddOptions(); + optionsBuilder.BindConfiguration(configSectionPath); + ValidateOptions(optionsBuilder); + AddPlugin(builder); + return builder; + } + + /// + /// Configure the AssemblyAI plugins using the specified configuration section path. + /// + /// + /// The configuration to bind options to + /// + public static IKernelBuilder AddAssemblyAIPlugin( + this IKernelBuilder builder, + IConfiguration configuration + ) + { + var services = builder.Services; + var optionsBuilder = services.AddOptions(); + optionsBuilder.Bind(configuration); + ValidateOptions(optionsBuilder); + AddPlugin(builder); + return builder; + } + + /// + /// Configure the AssemblyAI plugins using the specified options. + /// + /// + /// Options to configure plugin with + /// + public static IKernelBuilder AddAssemblyAIPlugin( + this IKernelBuilder builder, + AssemblyAIPluginsOptions options + ) + { + var services = builder.Services; + var optionsBuilder = services.AddOptions(); + optionsBuilder.Configure(optionsToConfigure => + { + optionsToConfigure.ApiKey = options.ApiKey; + optionsToConfigure.AllowFileSystemAccess = options.AllowFileSystemAccess; + }); + ValidateOptions(optionsBuilder); + AddPlugin(builder); + return builder; + } + + /// + /// Configure the AssemblyAI plugins using the specified options. + /// + /// + /// Action to configure options + /// + public static IKernelBuilder AddAssemblyAIPlugin( + this IKernelBuilder builder, + Action configureOptions + ) + { + var services = builder.Services; + var optionsBuilder = services.AddOptions(); + optionsBuilder.Configure(configureOptions); + ValidateOptions(optionsBuilder); + AddPlugin(builder); + return builder; + } + + /// + /// Configure the AssemblyAI plugins using the specified options. + /// + /// + /// Action to configure options + /// + public static IKernelBuilder AddAssemblyAIPlugin( + this IKernelBuilder builder, + Action configureOptions + ) + { + var services = builder.Services; + var optionsBuilder = services.AddOptions(); + optionsBuilder.Configure((options, provider) => configureOptions(provider, options)); + ValidateOptions(optionsBuilder); + AddPlugin(builder); + return builder; + } + + private static void ValidateOptions(OptionsBuilder optionsBuilder) + { + optionsBuilder.Validate( + options => !string.IsNullOrEmpty(options.ApiKey), + "AssemblyAI:ApiKey must be configured." + ); + } + + private static void AddPlugin(IKernelBuilder builder) + { + builder.Plugins.AddFromType(AssemblyAIPlugin.PluginName); + } + } +} \ No newline at end of file diff --git a/src/AssemblyAI.SemanticKernel/Transcript.cs b/src/AssemblyAI.SemanticKernel/Transcript.cs new file mode 100644 index 0000000..72e1ec3 --- /dev/null +++ b/src/AssemblyAI.SemanticKernel/Transcript.cs @@ -0,0 +1,12 @@ +namespace AssemblyAI.SemanticKernel +{ + // ReSharper disable once ClassNeverInstantiated.Global + public class Transcript + { + public string Id { get; set; } = null; + public string Status { get; set; } = null; + public string Text { get; set; } + + public string Error { get; set; } + } +} \ No newline at end of file diff --git a/src/Sample/Program.cs b/src/Sample/Program.cs index 4988faf..8b7aeaf 100644 --- a/src/Sample/Program.cs +++ b/src/Sample/Program.cs @@ -1,5 +1,6 @@ using System.Text.Json; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Planning.Handlebars; @@ -18,32 +19,10 @@ public static async Task Main(string[] args) await TranscribeFileUsingPlan(kernel); } - private static Kernel BuildKernel(IConfiguration config) - { - var kernel = Kernel.CreateBuilder() - .AddOpenAIChatCompletion( - "gpt-3.5-turbo", - config["OpenAI:ApiKey"] ?? throw new Exception("OpenAI:ApiKey configuration is required.") - ) - .Build(); - - var apiKey = config["AssemblyAI:ApiKey"] ?? throw new Exception("AssemblyAI:ApiKey configuration is required."); - - kernel.ImportPluginFromObject( - new TranscriptPlugin(apiKey: apiKey) - { - AllowFileSystemAccess = true - }, - TranscriptPlugin.PluginName - ); - - kernel.ImportPluginFromType(FindFilePlugin.PluginName); - return kernel; - } - private static IConfigurationRoot BuildConfig(string[] args) { var config = new ConfigurationBuilder() + .AddJsonFile("appsettings.json") .AddEnvironmentVariables() .AddUserSecrets() .AddCommandLine(args) @@ -51,6 +30,21 @@ private static IConfigurationRoot BuildConfig(string[] args) return config; } + private static Kernel BuildKernel(IConfiguration config) + { + var kernelBuilder = Kernel.CreateBuilder(); + kernelBuilder.Services.AddSingleton(config); + kernelBuilder.AddOpenAIChatCompletion( + "gpt-3.5-turbo", + config["OpenAI:ApiKey"] ?? throw new Exception("OpenAI:ApiKey configuration is required.") + ) + .AddAssemblyAIPlugin(); + var kernel = kernelBuilder.Build(); + + kernel.ImportPluginFromType(FindFilePlugin.PluginName); + return kernel; + } + private static async Task TranscribeFileUsingPluginDirectly(Kernel kernel) { Console.WriteLine("Transcribing file using plugin directly"); @@ -59,8 +53,8 @@ private static async Task TranscribeFileUsingPluginDirectly(Kernel kernel) ["INPUT"] = "https://storage.googleapis.com/aai-docs-samples/espn.m4a" }; var result = await kernel.InvokeAsync( - TranscriptPlugin.PluginName, - TranscriptPlugin.TranscribeFunctionName, + AssemblyAIPlugin.PluginName, + AssemblyAIPlugin.TranscribeFunctionName, arguments ); @@ -75,7 +69,7 @@ private static async Task TranscribeFileUsingPluginFromSemanticFunction(Kernel k // If `INPUT` is a URL, it'll use `INPUT` as `audioUrl`, otherwise, it'll use `INPUT` as `filePath`. const string prompt = """ Here is a transcript: - {{TranscriptPlugin.Transcribe "https://storage.googleapis.com/aai-docs-samples/espn.m4a"}} + {{AssemblyAI.Transcribe "https://storage.googleapis.com/aai-docs-samples/espn.m4a"}} --- Summarize the transcript. """; diff --git a/src/Sample/Sample.csproj b/src/Sample/Sample.csproj index 2b6a0d4..b542721 100644 --- a/src/Sample/Sample.csproj +++ b/src/Sample/Sample.csproj @@ -40,4 +40,10 @@ 1.0.1-preview + + + + Always + + diff --git a/src/Sample/appsettings.json b/src/Sample/appsettings.json new file mode 100644 index 0000000..b53a35c --- /dev/null +++ b/src/Sample/appsettings.json @@ -0,0 +1,6 @@ +{ + "AssemblyAI": { + "ApiKey": "", + "AllowFileSystemAccess": true + } +} \ No newline at end of file From 01ebc64b2345ff334abf24d530be87cc85c6f3bc Mon Sep 17 00:00:00 2001 From: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com> Date: Wed, 3 Jan 2024 17:06:42 -0500 Subject: [PATCH 2/3] Add backwards compatible alias --- .../AssemblyAIPlugin.cs | 13 +++++----- .../TranscriptPlugin.cs | 24 +++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 src/AssemblyAI.SemanticKernel/TranscriptPlugin.cs diff --git a/src/AssemblyAI.SemanticKernel/AssemblyAIPlugin.cs b/src/AssemblyAI.SemanticKernel/AssemblyAIPlugin.cs index 18e6c88..f2d733a 100644 --- a/src/AssemblyAI.SemanticKernel/AssemblyAIPlugin.cs +++ b/src/AssemblyAI.SemanticKernel/AssemblyAIPlugin.cs @@ -16,15 +16,16 @@ namespace AssemblyAI.SemanticKernel public class AssemblyAIPlugin { public const string PluginName = "AssemblyAI"; - private readonly AssemblyAIPluginsOptions _options; + + internal AssemblyAIPluginsOptions Options { get; } - private string ApiKey => _options.ApiKey; + private string ApiKey => Options.ApiKey; - private bool AllowFileSystemAccess => _options.AllowFileSystemAccess; + private bool AllowFileSystemAccess => Options.AllowFileSystemAccess; public AssemblyAIPlugin(string apiKey) { - _options = new AssemblyAIPluginsOptions + Options = new AssemblyAIPluginsOptions { ApiKey = apiKey }; @@ -32,7 +33,7 @@ public AssemblyAIPlugin(string apiKey) public AssemblyAIPlugin(string apiKey, bool allowFileSystemAccess) { - _options = new AssemblyAIPluginsOptions + Options = new AssemblyAIPluginsOptions { ApiKey = apiKey, AllowFileSystemAccess = allowFileSystemAccess @@ -42,7 +43,7 @@ public AssemblyAIPlugin(string apiKey, bool allowFileSystemAccess) [ActivatorUtilitiesConstructor] public AssemblyAIPlugin(IOptions options) { - _options = options.Value; + Options = options.Value; } public const string TranscribeFunctionName = nameof(Transcribe); diff --git a/src/AssemblyAI.SemanticKernel/TranscriptPlugin.cs b/src/AssemblyAI.SemanticKernel/TranscriptPlugin.cs new file mode 100644 index 0000000..7fd566f --- /dev/null +++ b/src/AssemblyAI.SemanticKernel/TranscriptPlugin.cs @@ -0,0 +1,24 @@ +using System; + +namespace AssemblyAI.SemanticKernel +{ + [Obsolete("Use AssemblyAIPlugin instead.")] + public class TranscriptPlugin : AssemblyAIPlugin + { + public new const string PluginName = nameof(TranscriptPlugin); + + public bool AllowFileSystemAccess + { + get => Options.AllowFileSystemAccess; + set => Options.AllowFileSystemAccess = value; + } + + public TranscriptPlugin(string apiKey) : base(apiKey) + { + } + + public TranscriptPlugin(string apiKey, bool allowFileSystemAccess) : base(apiKey, allowFileSystemAccess) + { + } + } +} \ No newline at end of file From da954e579f017737675b8e8d163f139738d15fec Mon Sep 17 00:00:00 2001 From: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com> Date: Fri, 16 Feb 2024 21:00:00 -0500 Subject: [PATCH 3/3] Update version, reduce extensions --- README.md | 2 +- .../AssemblyAI.SemanticKernel.csproj | 6 +-- .../AssemblyAIPlugin.cs | 2 +- src/AssemblyAI.SemanticKernel/Extensions.cs | 37 ++++--------------- src/Sample/Program.cs | 4 +- src/Sample/appsettings.json | 6 ++- 6 files changed, 18 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 510ba90..9ad8171 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Console.WriteLine(result.GetValue()); You can get the transcript using `result.GetValue()`. You can also upload local audio and video file. To do this: -- Set the `AssemblyAI:AllowFileSystemAccess` configuration to `true`. +- Set the `AssemblyAI:Plugin:AllowFileSystemAccess` configuration to `true`. - Configure the `INPUT` variable with a local file path. ```csharp diff --git a/src/AssemblyAI.SemanticKernel/AssemblyAI.SemanticKernel.csproj b/src/AssemblyAI.SemanticKernel/AssemblyAI.SemanticKernel.csproj index 4216102..0c9a3a6 100644 --- a/src/AssemblyAI.SemanticKernel/AssemblyAI.SemanticKernel.csproj +++ b/src/AssemblyAI.SemanticKernel/AssemblyAI.SemanticKernel.csproj @@ -11,9 +11,9 @@ SemanticKernel;AI;AssemblyAI;transcript AssemblyAI AssemblyAI - 1.0.3.0 - 1.0.3.0 - 1.0.3 + 1.1.0.0 + 1.1.0.0 + 1.1.0 Library MIT https://github.com/AssemblyAI/assemblyai-semantic-kernel diff --git a/src/AssemblyAI.SemanticKernel/AssemblyAIPlugin.cs b/src/AssemblyAI.SemanticKernel/AssemblyAIPlugin.cs index 86c17bf..8f6f533 100644 --- a/src/AssemblyAI.SemanticKernel/AssemblyAIPlugin.cs +++ b/src/AssemblyAI.SemanticKernel/AssemblyAIPlugin.cs @@ -66,7 +66,7 @@ string input if (AllowFileSystemAccess == false) { throw new Exception( - "You need to allow file system access to upload files. Set AssemblyAI:AllowFileSystemAccess to true." + "You need to allow file system access to upload files. Set AssemblyAI:Plugin:AllowFileSystemAccess to true." ); } diff --git a/src/AssemblyAI.SemanticKernel/Extensions.cs b/src/AssemblyAI.SemanticKernel/Extensions.cs index 2157f9d..b88666e 100644 --- a/src/AssemblyAI.SemanticKernel/Extensions.cs +++ b/src/AssemblyAI.SemanticKernel/Extensions.cs @@ -11,34 +11,6 @@ namespace AssemblyAI.SemanticKernel { public static class Extensions { - /// - /// Configure the AssemblyAI plugins using the specified configuration section path. - /// - /// - /// - public static IKernelBuilder AddAssemblyAIPlugin( - this IKernelBuilder builder - ) => AddAssemblyAIPlugin(builder, "AssemblyAI"); - - /// - /// Configure the AssemblyAI plugins using the specified configuration section path. - /// - /// - /// The path of the configuration section to bind options to - /// - public static IKernelBuilder AddAssemblyAIPlugin( - this IKernelBuilder builder, - string configSectionPath - ) - { - var services = builder.Services; - var optionsBuilder = services.AddOptions(); - optionsBuilder.BindConfiguration(configSectionPath); - ValidateOptions(optionsBuilder); - AddPlugin(builder); - return builder; - } - /// /// Configure the AssemblyAI plugins using the specified configuration section path. /// @@ -50,6 +22,13 @@ string configSectionPath IConfiguration configuration ) { + var pluginConfigurationSection = configuration.GetSection("AssemblyAI:Plugin"); + // if configuration exists at section, use that config, otherwise using section that was passed in. + if (pluginConfigurationSection.Exists()) + { + configuration = pluginConfigurationSection; + } + var services = builder.Services; var optionsBuilder = services.AddOptions(); optionsBuilder.Bind(configuration); @@ -123,7 +102,7 @@ private static void ValidateOptions(OptionsBuilder opti { optionsBuilder.Validate( options => !string.IsNullOrEmpty(options.ApiKey), - "AssemblyAI:ApiKey must be configured." + "AssemblyAI:Plugin:ApiKey must be configured." ); } diff --git a/src/Sample/Program.cs b/src/Sample/Program.cs index d776753..6d91a64 100644 --- a/src/Sample/Program.cs +++ b/src/Sample/Program.cs @@ -1,6 +1,5 @@ using System.Text.Json; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; using Microsoft.SemanticKernel; using Microsoft.SemanticKernel.Planning.Handlebars; @@ -33,12 +32,11 @@ private static IConfigurationRoot BuildConfig(string[] args) private static Kernel BuildKernel(IConfiguration config) { var kernelBuilder = Kernel.CreateBuilder(); - kernelBuilder.Services.AddSingleton(config); kernelBuilder.AddOpenAIChatCompletion( "gpt-3.5-turbo", config["OpenAI:ApiKey"] ?? throw new Exception("OpenAI:ApiKey configuration is required.") ) - .AddAssemblyAIPlugin(); + .AddAssemblyAIPlugin(config); var kernel = kernelBuilder.Build(); kernel.ImportPluginFromType(); diff --git a/src/Sample/appsettings.json b/src/Sample/appsettings.json index b53a35c..1de348a 100644 --- a/src/Sample/appsettings.json +++ b/src/Sample/appsettings.json @@ -1,6 +1,8 @@ { "AssemblyAI": { - "ApiKey": "", - "AllowFileSystemAccess": true + "Plugin": { + "ApiKey": "", + "AllowFileSystemAccess": true + } } } \ No newline at end of file