mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 11:19:56 +00:00
### Motivation and Context Rename `Skills` to `Plugins`. First sub task from https://github.com/microsoft/semantic-kernel/issues/2119. ### Description This is the first PR 1. Move Core, Document, MsGraph and Web skill projects to a new `Plugins` folder 2. Update Core, Document, MsGraph and Web projects to use `Plugins` instead of `Skills` in assembly names, namespace, class names 3. Extract text from `Skills.UnitTests` and create new `Plugins.UnitTests` project Solution Explorer:  File Explorer:  ### Contribution Checklist - [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 - [ ] I didn't break anyone 😄
74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.SemanticKernel;
|
|
using Microsoft.SemanticKernel.Plugins.Web;
|
|
using Microsoft.SemanticKernel.Plugins.Web.Bing;
|
|
using RepoUtils;
|
|
|
|
// ReSharper disable once InconsistentNaming
|
|
public static class Example04_CombineLLMPromptsAndNativeCode
|
|
{
|
|
public static async Task RunAsync()
|
|
{
|
|
Console.WriteLine("======== LLMPrompts ========");
|
|
|
|
string openAIApiKey = TestConfiguration.OpenAI.ApiKey;
|
|
|
|
if (openAIApiKey == null)
|
|
{
|
|
Console.WriteLine("OpenAI credentials not found. Skipping example.");
|
|
return;
|
|
}
|
|
|
|
IKernel kernel = new KernelBuilder()
|
|
.WithLoggerFactory(ConsoleLogger.LoggerFactory)
|
|
.WithOpenAIChatCompletionService(TestConfiguration.OpenAI.ChatModelId, openAIApiKey)
|
|
.Build();
|
|
|
|
// Load native skill
|
|
string bingApiKey = TestConfiguration.Bing.ApiKey;
|
|
|
|
if (bingApiKey == null)
|
|
{
|
|
Console.WriteLine("Bing credentials not found. Skipping example.");
|
|
return;
|
|
}
|
|
|
|
var bingConnector = new BingConnector(bingApiKey);
|
|
var bing = new WebSearchEnginePlugin(bingConnector);
|
|
var search = kernel.ImportSkill(bing, "bing");
|
|
|
|
// Load semantic skill defined with prompt templates
|
|
string folder = RepoFiles.SampleSkillsPath();
|
|
|
|
var sumSkill = kernel.ImportSemanticSkillFromDirectory(folder, "SummarizeSkill");
|
|
|
|
// Run
|
|
var ask = "What's the tallest building in South America";
|
|
|
|
var result1 = await kernel.RunAsync(
|
|
ask,
|
|
search["Search"]
|
|
);
|
|
|
|
var result2 = await kernel.RunAsync(
|
|
ask,
|
|
search["Search"],
|
|
sumSkill["Summarize"]
|
|
);
|
|
|
|
var result3 = await kernel.RunAsync(
|
|
ask,
|
|
search["Search"],
|
|
sumSkill["Notegen"]
|
|
);
|
|
|
|
Console.WriteLine(ask + "\n");
|
|
Console.WriteLine("Bing Answer: " + result1 + "\n");
|
|
Console.WriteLine("Summary: " + result2 + "\n");
|
|
Console.WriteLine("Notes: " + result3 + "\n");
|
|
}
|
|
}
|