diff --git a/dotnet/README.md b/dotnet/README.md index eb9b05e43d7c..28ca20228fb7 100644 --- a/dotnet/README.md +++ b/dotnet/README.md @@ -22,17 +22,18 @@ Copy and paste the following code into your project, with your Azure OpenAI key ```csharp using Microsoft.SemanticKernel; +using Microsoft.SemanticKernel.Connectors.AI.OpenAI; var builder = new KernelBuilder(); builder.WithAzureChatCompletionService( - "gpt-35-turbo", // Azure OpenAI Deployment Name + "gpt-35-turbo", // Azure OpenAI Deployment Name "https://contoso.openai.azure.com/", // Azure OpenAI Endpoint "...your Azure OpenAI Key..."); // Azure OpenAI Key // Alternative using OpenAI //builder.WithOpenAIChatCompletionService( -// "gpt-3.5-turbo", // OpenAI Model name +// "gpt-3.5-turbo", // OpenAI Model name // "...your OpenAI API Key..."); // OpenAI API Key var kernel = builder.Build(); @@ -41,7 +42,7 @@ var prompt = @"{{$input}} One line TLDR with the fewest words."; -var summarize = kernel.CreateSemanticFunction(prompt, maxTokens: 100); +var summarize = kernel.CreateSemanticFunction(prompt, requestSettings: new OpenAIRequestSettings { MaxTokens = 100 }); string text1 = @" 1st Law of Thermodynamics - Energy cannot be created or destroyed. @@ -53,9 +54,9 @@ string text2 = @" 2. The acceleration of an object depends on the mass of the object and the amount of force applied. 3. Whenever one object exerts a force on another object, the second object exerts an equal and opposite on the first."; -Console.WriteLine(await summarize.InvokeAsync(text1)); +Console.WriteLine(await kernel.RunAsync(text1, summarize)); -Console.WriteLine(await summarize.InvokeAsync(text2)); +Console.WriteLine(await kernel.RunAsync(text2, summarize)); // Output: // Energy conserved, entropy increases, zero entropy at 0K. @@ -80,8 +81,8 @@ string summarizePrompt = @"{{$input}} Give me a TLDR with the fewest words."; -var translator = kernel.CreateSemanticFunction(translationPrompt, maxTokens: 200); -var summarize = kernel.CreateSemanticFunction(summarizePrompt, maxTokens: 100); +var translator = kernel.CreateSemanticFunction(translationPrompt, requestSettings: new OpenAIRequestSettings { MaxTokens = 200 }); +var summarize = kernel.CreateSemanticFunction(summarizePrompt, requestSettings: new OpenAIRequestSettings { MaxTokens = 100 }); string inputText = @" 1st Law of Thermodynamics - Energy cannot be created or destroyed.