Skip to content

Commit

Permalink
test case for predicted output
Browse files Browse the repository at this point in the history
  • Loading branch information
trrwilson committed Dec 12, 2024
1 parent eda00ed commit db68d71
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .dotnet/tests/Chat/ChatTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -870,4 +870,36 @@ public async Task ReasoningTokensWork()
Assert.That(completion.Usage.OutputTokenDetails?.ReasoningTokenCount, Is.GreaterThan(0));
Assert.That(completion.Usage.OutputTokenDetails?.ReasoningTokenCount, Is.LessThan(completion.Usage.OutputTokenCount));
}

[Test]
public async Task PredictedOutputsWork()
{
ChatClient client = GetTestClient<ChatClient>(TestScenario.Chat);

ChatCompletionOptions options = new()
{
PredictedContent =
[
ChatMessageContentPart.CreateTextPart("""
{
"feature_name": "test_feature",
"enabled": true
}
""".ReplaceLineEndings("\n")),
],
};

ChatMessage message = ChatMessage.CreateUserMessage("""
Modify the following input to enable the feature. Only respond with the JSON and include no other text.
{
"feature_name": "test_feature",
"enabled": false
}
""".ReplaceLineEndings("\n"));

ChatCompletion completion = await client.CompleteChatAsync([message], options);

Assert.That(completion.Usage.OutputTokenDetails.AcceptedPredictionTokenCount, Is.GreaterThan(0));
}
}

0 comments on commit db68d71

Please sign in to comment.