Skip to content

Commit 23abaa6

Browse files
authored
Azure OpenAI: 2.2.0-beta.2 (Azure#48347)
* reflect latest from development location * include eng folder for package.data.props pinning
1 parent 1d5a868 commit 23abaa6

File tree

9 files changed

+62
-4
lines changed

9 files changed

+62
-4
lines changed

eng/Packages.Data.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
</ItemGroup>
191191

192192
<ItemGroup Condition="$(MSBuildProjectName.StartsWith('Azure.AI.OpenAI'))">
193-
<PackageReference Update="OpenAI" Version="2.2.0-beta.1" />
193+
<PackageReference Update="OpenAI" Version="2.2.0-beta.2" />
194194
</ItemGroup>
195195

196196
<ItemGroup Condition="$(MSBuildProjectName.StartsWith('Azure.Developer.MicrosoftPlaywrightTesting'))">

sdk/openai/Azure.AI.OpenAI/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Release History
22

3+
## 2.2.0-beta.2 (2025-02-18)
4+
5+
### Bugs fixed
6+
7+
- Addressed a problem calling the `SetNewMaxCompletionTokensPropertyEnabled()` method, needed for o1/o3 model support, on `ChatCompletionOptions` instances prior to use in a method call. Related issue: [azure-sdk-for-net#46545](https://github.com/Azure/azure-sdk-for-net/issues/46545) with thanks to the PR [azure-sdk-for-net#48218](https://github.com/Azure/azure-sdk-for-net/pull/48218).
8+
39
## 2.2.0-beta.1 (2025-02-07)
410

511
This preview release aligns with the corresponding `2.2.0` beta of `OpenAI` and the `2025-01-01-Preview` Azure OpenAI Service API version.

sdk/openai/Azure.AI.OpenAI/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/openai/Azure.AI.OpenAI",
5-
"Tag": "net/openai/Azure.AI.OpenAI_9db5b129ea"
5+
"Tag": "net/openai/Azure.AI.OpenAI_0f09bc4c00"
66
}

sdk/openai/Azure.AI.OpenAI/src/Azure.AI.OpenAI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<Otherwise>
3535
<PropertyGroup>
3636
<VersionPrefix>2.2.0</VersionPrefix>
37-
<VersionSuffix>beta.1</VersionSuffix>
37+
<VersionSuffix>beta.2</VersionSuffix>
3838
</PropertyGroup>
3939
</Otherwise>
4040
</Choose>

sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatClient.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ private static void PostfixClearStreamOptions(IEnumerable<ChatMessage> messages,
9494
== true)
9595
{
9696
options ??= new();
97-
options.StreamOptions = null;
97+
options.SerializedAdditionalRawData ??= new Dictionary<string, BinaryData>();
98+
AdditionalPropertyHelpers.SetEmptySentinelValue(options.SerializedAdditionalRawData, "stream_options");
9899
}
99100
}
100101

sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public static void SetNewMaxCompletionTokensPropertyEnabled(this ChatCompletionO
4242
if (newPropertyEnabled)
4343
{
4444
// Blocking serialization of max_tokens via dictionary acts as a signal to skip pre-serialization fixup
45+
options.SerializedAdditionalRawData ??= new Dictionary<string, BinaryData>();
4546
AdditionalPropertyHelpers.SetEmptySentinelValue(options.SerializedAdditionalRawData, "max_tokens");
4647
}
4748
else

sdk/openai/Azure.AI.OpenAI/tests/Assets/playback_test_config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
"key": "Sanitized",
4040
"deployment": "o1"
4141
},
42+
"chat_o3-mini": {
43+
"endpoint": "https://Sanitized.openai.azure.com/",
44+
"key": "Sanitized",
45+
"deployment": "o3-mini"
46+
},
4247
"chat_with_async_filter": {
4348
"endpoint": "https://Sanitized.openai.azure.com/",
4449
"key": "Sanitized",

sdk/openai/Azure.AI.OpenAI/tests/ChatTests.Audio.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,17 @@ public async Task ChatAudioWorks()
7979
DateTimeOffset? streamedExpiresAt = null;
8080
StringBuilder streamedTranscriptBuilder = new();
8181
using MemoryStream outputAudioStream = new();
82+
ChatTokenUsage? streamedUsage = null;
8283
await foreach (StreamingChatCompletionUpdate update in client.CompleteChatStreamingAsync(messages, options))
8384
{
8485
Assert.That(update.ContentUpdate, Has.Count.EqualTo(0));
8586
StreamingChatOutputAudioUpdate outputAudioUpdate = update.OutputAudioUpdate;
8687

88+
if (update.Usage is not null)
89+
{
90+
Assert.That(streamedUsage, Is.Null);
91+
streamedUsage = update.Usage;
92+
}
8793
if (outputAudioUpdate is not null)
8894
{
8995
string serializedOutputAudioUpdate = ModelReaderWriter.Write(outputAudioUpdate).ToString();
@@ -108,5 +114,7 @@ public async Task ChatAudioWorks()
108114
Assert.That(streamedExpiresAt.HasValue, Is.True);
109115
Assert.That(streamedTranscriptBuilder.ToString(), Is.Not.Null.And.Not.Empty);
110116
Assert.That(outputAudioStream.Length, Is.GreaterThan(9000));
117+
Assert.That(streamedUsage?.InputTokenDetails?.AudioTokenCount, Is.GreaterThan(0));
118+
Assert.That(streamedUsage?.OutputTokenDetails?.AudioTokenCount, Is.GreaterThan(0));
111119
}
112120
}

sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,43 @@ public async Task UserSecurityContextWorks()
542542
Assert.That(completion, Is.Not.Null);
543543
}
544544

545+
[RecordedTest]
546+
[TestCase("chat", false)]
547+
[TestCase("chat_o1", true)]
548+
[TestCase("chat_o3-mini", true)]
549+
public async Task MaxOutputTokensWorksAcrossModels(string testConfigName, bool useNewProperty)
550+
{
551+
IConfiguration testConfig = TestConfig.GetConfig(testConfigName)!;
552+
ChatClient client = GetTestClient(testConfig);
553+
554+
ChatCompletionOptions options = new()
555+
{
556+
MaxOutputTokenCount = 16,
557+
};
558+
559+
if (useNewProperty)
560+
{
561+
options.SetNewMaxCompletionTokensPropertyEnabled();
562+
}
563+
564+
ChatCompletion completion = await client.CompleteChatAsync(
565+
["Hello, world! Please write a funny haiku to greet me."],
566+
options);
567+
Assert.That(completion.FinishReason, Is.EqualTo(ChatFinishReason.Length));
568+
569+
string serializedOptionsAfterUse = ModelReaderWriter.Write(options).ToString();
570+
571+
if (useNewProperty)
572+
{
573+
Assert.That(serializedOptionsAfterUse, Does.Contain("max_completion_tokens"));
574+
Assert.That(serializedOptionsAfterUse, Does.Not.Contain("max_tokens"));
575+
}
576+
else
577+
{
578+
Assert.That(serializedOptionsAfterUse, Does.Not.Contain("max_completion_tokens"));
579+
Assert.That(serializedOptionsAfterUse, Does.Contain("max_tokens"));
580+
}
581+
}
545582
#endregion
546583

547584
#region Streaming chat completion tests

0 commit comments

Comments
 (0)