mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Resolves: https://github.com/microsoft/semantic-kernel/issues/6247 Fixed path issues and updated `Microsoft.SemanticKernel` version to `1.11.1`. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
4.3 KiB
4.3 KiB
In [ ]:
// Load some helper functions, e.g. to load values from settings.json
#!import config/Settings.cs In [ ]:
// Import Semantic Kernel
#r "nuget: Microsoft.SemanticKernel, 1.11.1"In [ ]:
using Microsoft.SemanticKernel;
using Kernel = Microsoft.SemanticKernel.Kernel;
//Create Kernel builder
var builder = Kernel.CreateBuilder();In [ ]:
// Configure AI service credentials used by the kernel
var (useAzureOpenAI, model, azureEndpoint, apiKey, orgId) = Settings.LoadFromFile();
if (useAzureOpenAI)
builder.AddAzureOpenAIChatCompletion(model, azureEndpoint, apiKey);
else
builder.AddOpenAIChatCompletion(model, apiKey, orgId);
var kernel = builder.Build();In [ ]:
// FunPlugin directory path
var funPluginDirectoryPath = Path.Combine(System.IO.Directory.GetCurrentDirectory(), "..", "..", "prompt_template_samples", "FunPlugin");
// Load the FunPlugin from the Plugins Directory
var funPluginFunctions = kernel.ImportPluginFromPromptDirectory(funPluginDirectoryPath);
// Construct arguments
var arguments = new KernelArguments() { ["input"] = "time travel to dinosaur age" };
// Run the Function called Joke
var result = await kernel.InvokeAsync(funPluginFunctions["Joke"], arguments);
// Return the result to the Notebook
Console.WriteLine(result);