Skip to content

Commit

Permalink
Merge pull request #1 from AssemblyAI/add-constants
Browse files Browse the repository at this point in the history
Add constants, simplify sample
  • Loading branch information
Swimburger committed Sep 26, 2023
2 parents 5793b03 + 899100f commit e921fce
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>AssemblyAI.SemanticKernel</RootNamespace>
Expand All @@ -12,9 +11,9 @@
<PackageTags>SemanticKernel;AI;AssemblyAI;transcript</PackageTags>
<Company>AssemblyAI</Company>
<Product>AssemblyAI</Product>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<PackageVersion>1.0.0-alpha</PackageVersion>
<AssemblyVersion>1.0.1.0</AssemblyVersion>
<FileVersion>1.0.1.0</FileVersion>
<PackageVersion>1.0.1-alpha</PackageVersion>
<OutputType>Library</OutputType>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/AssemblyAI/assemblyai-semantic-kernel</PackageProjectUrl>
Expand Down
3 changes: 3 additions & 0 deletions src/AssemblyAI.SemanticKernel/TranscriptPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand All @@ -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.
Expand Down
59 changes: 0 additions & 59 deletions src/Sample/KernelBuilderExtensions.cs

This file was deleted.

11 changes: 7 additions & 4 deletions src/Sample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down

0 comments on commit e921fce

Please sign in to comment.