mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
### Motivation and Context Following best practices for libraries outlined at https://learn.microsoft.com/en-us/dotnet/core/extensions/logging-library-authors, SK should generally be taking an ILoggerFactory rather than an ILogger. This allows individual components to each get a logger with its own category applied. ### 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 - [ ] I didn't break anyone 😄 --------- Co-authored-by: Shawn Callegari <[email protected]> Co-authored-by: Lee Miller <[email protected]>
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.SemanticKernel;
|
|
using Microsoft.SemanticKernel.Orchestration;
|
|
using Microsoft.SemanticKernel.Skills.Grpc.Extensions;
|
|
using RepoUtils;
|
|
|
|
/**
|
|
* This example shows how to use gRPC skills.
|
|
*/
|
|
|
|
// ReSharper disable once InconsistentNaming
|
|
public static class Example35_GrpcSkills
|
|
{
|
|
public static async Task RunAsync()
|
|
{
|
|
var kernel = new KernelBuilder().WithLoggerFactory(ConsoleLogger.LoggerFactory).Build();
|
|
|
|
// Import a gRPC skill using one of the following Kernel extension methods
|
|
// kernel.RegisterGrpcSkill
|
|
// kernel.ImportGrpcSkillFromDirectory
|
|
var skill = kernel.ImportGrpcSkillFromFile("<skill-name>", "<path-to-.proto-file>");
|
|
|
|
// Add arguments for required parameters, arguments for optional ones can be skipped.
|
|
var contextVariables = new ContextVariables();
|
|
contextVariables.Set("address", "<gRPC-server-address>");
|
|
contextVariables.Set("payload", "<gRPC-request-message-as-json>");
|
|
|
|
// Run
|
|
var result = await kernel.RunAsync(contextVariables, skill["<operation-name>"]);
|
|
|
|
Console.WriteLine("Skill response: {0}", result);
|
|
}
|
|
}
|