Created
December 5, 2024 16:48
-
-
Save rsantosdev/7f1c71d529897c495ceb18b4d53d6a9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Logging; | |
using Microsoft.SemanticKernel; | |
// Create a kernel with Azure OpenAI chat completion | |
#pragma warning disable SKEXP0001, SKEXP0003, SKEXP0010, SKEXP0011, SKEXP0050, SKEXP0052 | |
var builder = Kernel.CreateBuilder().AddOpenAIChatCompletion( | |
modelId: "Phi-3-5-mini-instruct-lfqzp", | |
endpoint: new Uri("https://Phi-3-5-mini-instruct-lfqzp.eastus2.models.ai.azure.com"), | |
apiKey: Environment.GetEnvironmentVariable("AZML_MODEL_KEY")); | |
// Add enterprise components | |
builder.Services.AddLogging(services => services.AddConsole().SetMinimumLevel(LogLevel.Information)); | |
// Build the kernel | |
Kernel kernel = builder.Build(); | |
// invoke a simple prompt to the chat service | |
string prompt = "Write a joke about dogs"; | |
var response = await kernel.InvokePromptAsync(prompt); | |
Console.WriteLine(response.GetValue<string>()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment