Skip to content

Commit

Permalink
.Net: Updated dotnet README to align with SK 1.0.0-beta2 (#3212)
Browse files Browse the repository at this point in the history
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

This PR contains changes to update `dotnet/README.md` file to be aligned
with recent SK version `1.0.0-beta2`.

### 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
- [x] I didn't break anyone 😄
  • Loading branch information
dmytrostruk authored Oct 17, 2023
1 parent 7c45f98 commit 8667826
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions dotnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 8667826

Please sign in to comment.