Files
semantic-kernel/dotnet/samples/KernelSyntaxExamples/Example04_CombineLLMPromptsAndNativeCode.cs
T
Mark Wallace c10f7c4e3a .Net: Rename 'Skills' -> 'Plugins' - Part 1 (#2854)
### 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:

![image](https://github.com/microsoft/semantic-kernel/assets/127216156/16dd8146-d8a0-44e3-8995-894afb644e09)

File Explorer:

![image](https://github.com/microsoft/semantic-kernel/assets/127216156/1aef0bd9-ac54-492f-8725-eac0d3e6db86)

### 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 😄
2023-09-18 18:58:36 +00:00

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");
}
}