Skip to content

Commit 632280c

Browse files
sgoingsshawncal
authored andcommitted
.Net: docs(dotnet): supply maxTokens to avoid response truncation (microsoft#2249)
### Motivation and Context 1. Why is this change required? When working through the examples in the dotnet/README.md file, I noticed that [OpenAI sets the max_tokens to 16](https://platform.openai.com/docs/api-reference/completions/create), which is far too low for these examples and led to truncated output and failing prompt chaining examples. 3. What problem does it solve? This makes the README.md examples work again. 5. What scenario does it contribute to? Onboarding/experimentation. 8. If it fixes an open issue, please link to the issue here. - [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 😄 Co-authored-by: Shawn Callegari <[email protected]>
1 parent 388d2a5 commit 632280c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

dotnet/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var prompt = @"{{$input}}
4141
4242
One line TLDR with the fewest words.";
4343

44-
var summarize = kernel.CreateSemanticFunction(prompt);
44+
var summarize = kernel.CreateSemanticFunction(prompt, maxTokens: 100);
4545

4646
string text1 = @"
4747
1st Law of Thermodynamics - Energy cannot be created or destroyed.
@@ -80,8 +80,8 @@ string summarizePrompt = @"{{$input}}
8080
8181
Give me a TLDR with the fewest words.";
8282

83-
var translator = kernel.CreateSemanticFunction(translationPrompt);
84-
var summarize = kernel.CreateSemanticFunction(summarizePrompt);
83+
var translator = kernel.CreateSemanticFunction(translationPrompt, maxTokens: 200);
84+
var summarize = kernel.CreateSemanticFunction(summarizePrompt, maxTokens: 100);
8585

8686
string inputText = @"
8787
1st Law of Thermodynamics - Energy cannot be created or destroyed.

0 commit comments

Comments
 (0)