Files
semantic-kernel/dotnet/samples/KernelSyntaxExamples/Example27_SemanticFunctionsUsingChatGPT.cs
T
Shawn Callegariandname f8a8d884ff Moving KernelSyntaxExamples into the dotnet/ folder (#1616)
"KernelSyntaxExamples" is the only outstanding project under /samples
that still uses project references to access the kernel libraries.

This change consolidates all the building, linked dotnet SDK code in
SK-dotnet.sln into a single top-level folder. This will simplify build
jobs, automatic code owner assignment, and other dev ops tasks.

Coming next: other projects in samples will get removed from the
dotnet/SK-dotnet.sln solution, and a new solution with dedicated builds
created for the /samples folder.

TBD:
- Language-specific code "samples" will move into a similar subfolder
for each language.
- The current "/samples" folder (at the root) will likely become
something like "apps", with the demo apps promoted to the top-level
folder for better discoverability.
- notebooks may also move to this folder in the future.

Co-authored-by: name <email>
2023-06-21 01:37:54 +00:00

38 lines
1.1 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Threading.Tasks;
using Microsoft.SemanticKernel;
using RepoUtils;
/**
* This example shows how to use GPT3.5 Chat model for prompts and semantic functions.
*/
// ReSharper disable once InconsistentNaming
public static class Example27_SemanticFunctionsUsingChatGPT
{
public static async Task RunAsync()
{
Console.WriteLine("======== Using Chat GPT model for text completion ========");
IKernel kernel = new KernelBuilder()
.WithLogger(ConsoleLogger.Log)
// Note: we use Chat Completion and GPT 3.5 Turbo
.WithAzureChatCompletionService("gpt-35-turbo", "https://....openai.azure.com/", "...API KEY...")
.Build();
var func = kernel.CreateSemanticFunction(
"List the two planets closest to '{{$input}}', excluding moons, using bullet points.");
var result = await func.InvokeAsync("Jupiter");
Console.WriteLine(result);
/*
Output:
- Saturn
- Uranus
*/
}
}