diff --git a/src/AssemblyAI.SemanticKernel/AssemblyAI.SemanticKernel.csproj b/src/AssemblyAI.SemanticKernel/AssemblyAI.SemanticKernel.csproj index a9c3c80..9b22a59 100644 --- a/src/AssemblyAI.SemanticKernel/AssemblyAI.SemanticKernel.csproj +++ b/src/AssemblyAI.SemanticKernel/AssemblyAI.SemanticKernel.csproj @@ -1,5 +1,4 @@ - netstandard2.0 AssemblyAI.SemanticKernel @@ -12,9 +11,9 @@ SemanticKernel;AI;AssemblyAI;transcript AssemblyAI AssemblyAI - 1.0.0.0 - 1.0.0.0 - 1.0.0-alpha + 1.0.1.0 + 1.0.1.0 + 1.0.1-alpha Library MIT https://github.com/AssemblyAI/assemblyai-semantic-kernel diff --git a/src/AssemblyAI.SemanticKernel/TranscriptPlugin.cs b/src/AssemblyAI.SemanticKernel/TranscriptPlugin.cs index 60a2e76..d98e588 100644 --- a/src/AssemblyAI.SemanticKernel/TranscriptPlugin.cs +++ b/src/AssemblyAI.SemanticKernel/TranscriptPlugin.cs @@ -14,6 +14,7 @@ namespace AssemblyAI.SemanticKernel { public class TranscriptPlugin { + public const string PluginName = nameof(TranscriptPlugin); private readonly string _apiKey; public bool AllowFileSystemAccess { get; set; } @@ -22,6 +23,8 @@ public TranscriptPlugin(string apiKey) _apiKey = apiKey; } + public const string TranscribeFunctionName = nameof(Transcribe); + [SKFunction, Description("Transcribe an audio or video file to text.")] [SKParameter("filePath", @"The path of the audio or video file. If filePath is configured, the file will be uploaded to AssemblyAI, and then used as the audioUrl to transcribe. diff --git a/src/Sample/KernelBuilderExtensions.cs b/src/Sample/KernelBuilderExtensions.cs deleted file mode 100644 index 0e12ea4..0000000 --- a/src/Sample/KernelBuilderExtensions.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Microsoft.SemanticKernel; - -namespace AssemblyAI.SemanticKernel.Sample; - -internal static class KernelBuilderExtensions -{ - internal static KernelBuilder WithCompletionService(this KernelBuilder kernelBuilder, IConfiguration config) - { - switch (config["LlmService"]!) - { - case "AzureOpenAI": - if (config["AzureOpenAI:DeploymentType"]! == "text-completion") - { - kernelBuilder.WithAzureTextCompletionService( - deploymentName: config["AzureOpenAI:TextCompletionDeploymentName"]!, - endpoint: config["AzureOpenAI:Endpoint"]!, - apiKey: config["AzureOpenAI:ApiKey"]! - ); - } - else if (config["AzureOpenAI:DeploymentType"]! == "chat-completion") - { - kernelBuilder.WithAzureChatCompletionService( - deploymentName: config["AzureOpenAI:ChatCompletionDeploymentName"]!, - endpoint: config["AzureOpenAI:Endpoint"]!, - apiKey: config["AzureOpenAI:ApiKey"]! - ); - } - - break; - - case "OpenAI": - switch (config["OpenAI:ModelType"]!) - { - case "text-completion": - kernelBuilder.WithOpenAITextCompletionService( - modelId: config["OpenAI:TextCompletionModelId"]!, - apiKey: config["OpenAI:ApiKey"]!, - orgId: config["OpenAI:OrgId"] - ); - break; - case "chat-completion": - kernelBuilder.WithOpenAIChatCompletionService( - modelId: config["OpenAI:ChatCompletionModelId"]!, - apiKey: config["OpenAI:ApiKey"]!, - orgId: config["OpenAI:OrgId"] - ); - break; - } - - break; - - default: - throw new ArgumentException($"Invalid service type value: {config["OpenAI:ModelType"]}"); - } - - return kernelBuilder; - } -} \ No newline at end of file diff --git a/src/Sample/Program.cs b/src/Sample/Program.cs index a60f34b..6d1873a 100644 --- a/src/Sample/Program.cs +++ b/src/Sample/Program.cs @@ -15,18 +15,21 @@ using var loggerFactory = LoggerFactory.Create(builder => { builder.SetMinimumLevel(0); }); var kernel = new KernelBuilder() - .WithCompletionService(config) + .WithOpenAIChatCompletionService( + "gpt-3.5-turbo", + config["OpenAI:ApiKey"] ?? throw new Exception("OpenAI:ApiKey configuration is required.") + ) .WithLoggerFactory(loggerFactory) .Build(); -var apiKey = config["AssemblyAI:ApiKey"] ?? throw new Exception("AssemblyAI:ApiKey not configured."); +var apiKey = config["AssemblyAI:ApiKey"] ?? throw new Exception("AssemblyAI:ApiKey configuration is required."); var transcriptPlugin = kernel.ImportSkill( new TranscriptPlugin(apiKey: apiKey) { AllowFileSystemAccess = true }, - "TranscriptPlugin" + TranscriptPlugin.PluginName ); await TranscribeFileUsingPlugin(kernel); @@ -39,7 +42,7 @@ async Task TranscribeFileUsingPlugin(IKernel kernel) }; var result = await kernel.Skills - .GetFunction("TranscriptPlugin", "Transcribe") + .GetFunction(TranscriptPlugin.PluginName, TranscriptPlugin.TranscribeFunctionName) .InvokeAsync(variables); Console.WriteLine(result.Result); }