Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/AI.Tests/OpenAITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,54 @@ public async Task GPT5_ThinksFast()
Assert.Equal("minimal", search["effort"]?.GetValue<string>());
});
}

[SecretsTheory("OPENAI_API_KEY")]
[InlineData(ReasoningEffort.Minimal)]
[InlineData(ReasoningEffort.Low)]
[InlineData(ReasoningEffort.Medium)]
[InlineData(ReasoningEffort.High)]
public async Task GPT5_ThinkingTime(ReasoningEffort effort)
{
var messages = new Chat()
{
{ "system", "You are an intelligent AI assistant that's an expert on financial matters." },
{ "user", "If you have a debt of 100k and accumulate a compounding 5% debt on top of it every year, how long before you are a negative millonaire? (round up to full integer value)" },
};

var requests = new List<JsonNode>();

var chat = new OpenAIChatClient(Configuration["OPENAI_API_KEY"]!, "gpt-5-nano",
OpenAIClientOptions.Observable(requests.Add).WriteTo(output));

var options = new ChatOptions
{
ModelId = "gpt-5",
ReasoningEffort = effort
};

var watch = System.Diagnostics.Stopwatch.StartNew();
var response = await chat.GetResponseAsync(messages, options);
watch.Stop();

var text = response.Text;

Assert.Contains("48 years", text);
// NOTE: the chat client was requested as grok-3 but the chat options wanted a
// different model and the grok client honors that choice.
Assert.StartsWith("gpt-5", response.ModelId);
Assert.DoesNotContain("nano", response.ModelId);

// Reasoning should have been set to medium
Assert.All(requests, x =>
{
var search = Assert.IsType<JsonObject>(x["reasoning"]);
Assert.Equal(effort.ToString().ToLowerInvariant(), search["effort"]?.GetValue<string>());
});

output.WriteLine($"Effort: {effort}, Time: {watch.ElapsedMilliseconds}ms, Tokens: {response.Usage?.TotalTokenCount}");
}


[SecretsFact("OPENAI_API_KEY")]
public async Task WebSearchCountryHighContext()
{
Expand Down
Loading