Skip to content

Commit 76c640c

Browse files
committed
Create basic experiment for semantic kernel handlebar planners.
1 parent 75aef39 commit 76c640c

File tree

3 files changed

+45
-10
lines changed

3 files changed

+45
-10
lines changed

99_CSharp/Program.cs

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,13 @@
33
using Microsoft.SemanticKernel;
44
using Microsoft.SemanticKernel.ChatCompletion;
55
using Microsoft.SemanticKernel.Connectors.OpenAI;
6+
using Microsoft.SemanticKernel.Planning.Handlebars;
67
using Microsoft.SemanticKernel.PromptTemplates.Handlebars;
78
using SemanticKernelExperiments.Helper;
89
using System;
910
using System.IO;
1011
using System.Linq;
1112
using System.Threading.Tasks;
12-
using System;
13-
using System.Net;
14-
using System.Threading.Tasks;
15-
using Microsoft.Extensions.DependencyInjection;
16-
using Microsoft.Extensions.Http.Resilience;
17-
using Microsoft.Extensions.Logging;
18-
using Microsoft.SemanticKernel;
1913

2014
namespace SemanticKernelExperiments;
2115

@@ -32,7 +26,8 @@ static async Task Main(string[] args)
3226
// await Ex03_DirectSequentialCallToExtractVideo();
3327
// await Ex03_b_DirectSequentialCallToExtractVideo();
3428

35-
await Ex04_Load_function_in_builder();
29+
//await Ex04_Load_function_in_builder();
30+
await Ex05_basic_planner();
3631
Console.ReadLine();
3732
}
3833

@@ -208,6 +203,45 @@ private static async Task Ex04_Load_function_in_builder()
208203
}
209204
}
210205

206+
private static async Task Ex05_basic_planner()
207+
{
208+
var pluginsDirectory = Path.Combine(System.IO.Directory.GetCurrentDirectory(), "plugins", "PublishingPlugin");
209+
var kernelBuilder = CreateBasicKernelBuilder();
210+
kernelBuilder
211+
.Plugins
212+
.AddFromType<AudioVideoPlugin.AudioVideoPlugin>("AudioVideoPlugin")
213+
.AddFromPromptDirectory(pluginsDirectory);
214+
var kernel = kernelBuilder.Build();
215+
216+
#pragma warning disable SKEXP0060 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
217+
var planner = new HandlebarsPlanner();
218+
219+
Console.WriteLine("\n\nProcess followed to answer the question:\n");
220+
var question = "I want to extract summarized timeline from video file C:\\temp\\ssh.mp4";
221+
222+
var plan = await planner.CreatePlanAsync(kernel, question);
223+
224+
var textPlan = plan.ToString();
225+
Console.WriteLine(textPlan);
226+
227+
//now we can invoke the plan
228+
var result = await plan.InvokeAsync(kernel);
229+
230+
#pragma warning restore SKEXP0060 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
231+
DumpTextSection("RAW FUNCTION CALLS");
232+
var llmCalls = _loggingProvider.GetLLMCalls();
233+
foreach (var llmCall in llmCalls)
234+
{
235+
Console.WriteLine($"Function {llmCall.ResponseFunctionCall} with arguments {llmCall.ResponseFunctionCallParameters}");
236+
}
237+
238+
DumpTextSection("FULL INFORMATION DUMP");
239+
foreach (var llmCall in llmCalls)
240+
{
241+
Console.WriteLine(llmCall.Dump());
242+
}
243+
}
244+
211245
private static void DumpTextSection(string text)
212246
{
213247
int totalWidth = 80;
@@ -232,7 +266,7 @@ private static IKernelBuilder CreateBasicKernelBuilder()
232266
.AddLogger(s => _loggingProvider.CreateHttpRequestBodyLogger(s.GetRequiredService<ILogger<DumpLoggingProvider>>())));
233267

234268
kernelBuilder.Services.AddAzureOpenAIChatCompletion(
235-
"GPT35_2",//"GPT42",
269+
"GPT42", //"GPT35_2",//"GPT42",
236270
Dotenv.Get("OPENAI_API_BASE"),
237271
Dotenv.Get("OPENAI_API_KEY"));
238272

99_CSharp/SemanticKernelExperiments.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
3232
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
3333
<PackageReference Include="Microsoft.SemanticKernel" Version="1.1.0" />
34+
<PackageReference Include="Microsoft.SemanticKernel.Planners.Handlebars" Version="1.1.0-preview" />
3435
<PackageReference Include="Microsoft.SemanticKernel.PromptTemplates.Handlebars" Version="1.1.0" />
3536
<PackageReference Include="Microsoft.SemanticKernel.Yaml" Version="1.1.0" />
3637
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.1.0" />

99_CSharp/python/transcript_timeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33

44
def transcript_timeline(audiofile: str) -> str:
5-
model = whisper.load_model("tiny.en")
5+
model = whisper.load_model("large-v3")
66

77
transcription_options = {
88
"verbose" : False,

0 commit comments

Comments
 (0)