Skip to content

Commit 6d5aa6e

Browse files
authored
.Net: {Azure}OpenAI Connectors Update to 2.1.0-beta.1 (microsoft#9078)
### Motivation and Context Update to the latest pre-release of OpenAI and Azure OpenAI pre-release packages following the new guidelines described in the ADR. Moving forward connectors that target pre-releases will also be tagged as pre-release as well as the `Microsoft.SemanticKernel` meta package (that targets pre-release version of OpenAI and AzureOpenAI connectors. THis update enable usage of the Realtime APIs provided by the underlying SDKs allowing them to be used for breaking glass scenarios.
1 parent d7d27ee commit 6d5aa6e

File tree

42 files changed

+139
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+139
-96
lines changed

dotnet/Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<ItemGroup>
88
<PackageVersion Include="Azure.AI.Inference" Version="1.0.0-beta.1" />
99
<PackageVersion Include="Microsoft.VisualStudio.Threading" Version="17.11.20" />
10-
<PackageVersion Include="OpenAI" Version="[2.0.0-beta.12]" />
10+
<PackageVersion Include="OpenAI" Version="[2.1.0-beta.1]" />
1111
<PackageVersion Include="Azure.AI.ContentSafety" Version="1.0.0" />
12-
<PackageVersion Include="Azure.AI.OpenAI" Version="[2.0.0-beta.6]" />
12+
<PackageVersion Include="Azure.AI.OpenAI" Version="[2.1.0-beta.1]" />
1313
<PackageVersion Include="Azure.Identity" Version="1.12.0" />
1414
<PackageVersion Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.3.0" />
1515
<PackageVersion Include="Azure.Search.Documents" Version="11.6.0" />

dotnet/samples/Concepts/Agents/ComplexChat_NestedShopper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
using Microsoft.SemanticKernel.Agents.Chat;
55
using Microsoft.SemanticKernel.ChatCompletion;
66
using Microsoft.SemanticKernel.Connectors.OpenAI;
7-
using OpenAI.Chat;
87
using Resources;
98

9+
using ChatResponseFormat = OpenAI.Chat.ChatResponseFormat;
10+
1011
namespace Agents;
1112

1213
/// <summary>

dotnet/samples/Concepts/Agents/MixedChat_Files.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public async Task AnalyzeFileAndGenerateReportAsync()
2121
{
2222
OpenAIClientProvider provider = this.GetClientProvider();
2323

24-
FileClient fileClient = provider.Client.GetFileClient();
24+
OpenAIFileClient fileClient = provider.Client.GetOpenAIFileClient();
2525

26-
OpenAIFileInfo uploadFile =
26+
OpenAIFile uploadFile =
2727
await fileClient.UploadFileAsync(
2828
new BinaryData(await EmbeddedResource.ReadAllAsync("30-user-context.txt")),
2929
"30-user-context.txt",

dotnet/samples/Concepts/Agents/MixedChat_Images.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public async Task AnalyzeDataAndGenerateChartAsync()
2424
{
2525
OpenAIClientProvider provider = this.GetClientProvider();
2626

27-
FileClient fileClient = provider.Client.GetFileClient();
27+
OpenAIFileClient fileClient = provider.Client.GetOpenAIFileClient();
2828

2929
// Define the agents
3030
OpenAIAssistantAgent analystAgent =

dotnet/samples/Concepts/Agents/OpenAIAssistant_ChartMaker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public async Task GenerateChartWithOpenAIAssistantAgentAsync()
2121
{
2222
OpenAIClientProvider provider = this.GetClientProvider();
2323

24-
FileClient fileClient = provider.Client.GetFileClient();
24+
OpenAIFileClient fileClient = provider.Client.GetOpenAIFileClient();
2525

2626
// Define the agent
2727
OpenAIAssistantAgent agent =

dotnet/samples/Concepts/Agents/OpenAIAssistant_FileManipulation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public async Task AnalyzeCSVFileUsingOpenAIAssistantAgentAsync()
1818
{
1919
OpenAIClientProvider provider = this.GetClientProvider();
2020

21-
FileClient fileClient = provider.Client.GetFileClient();
21+
OpenAIFileClient fileClient = provider.Client.GetOpenAIFileClient();
2222

23-
OpenAIFileInfo uploadFile =
23+
OpenAIFile uploadFile =
2424
await fileClient.UploadFileAsync(
2525
new BinaryData(await EmbeddedResource.ReadAllAsync("sales.csv")!),
2626
"sales.csv",

dotnet/samples/Concepts/ChatCompletion/AzureOpenAIWithData_ChatCompletion.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public async Task ExampleWithKernelAsync()
127127
/// <summary>
128128
/// Initializes a new instance of the <see cref="AzureSearchChatDataSource"/> class.
129129
/// </summary>
130+
#pragma warning disable AOAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
130131
private static AzureSearchChatDataSource GetAzureSearchDataSource()
131132
{
132133
return new AzureSearchChatDataSource
@@ -136,4 +137,5 @@ private static AzureSearchChatDataSource GetAzureSearchDataSource()
136137
IndexName = TestConfiguration.AzureAISearch.IndexName
137138
};
138139
}
140+
#pragma warning restore AOAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
139141
}

dotnet/samples/Concepts/ChatCompletion/OpenAI_ChatCompletionStreaming.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ private async Task<string> StreamMessageOutputFromKernelAsync(Kernel kernel, str
283283
/// </remarks>
284284
private void OutputInnerContent(OpenAI.Chat.StreamingChatCompletionUpdate streamChunk)
285285
{
286-
Console.WriteLine($"Id: {streamChunk.Id}");
286+
Console.WriteLine($"Id: {streamChunk.CompletionId}");
287287
Console.WriteLine($"Model: {streamChunk.Model}");
288288
Console.WriteLine($"Created at: {streamChunk.CreatedAt}");
289289
Console.WriteLine($"Finish reason: {(streamChunk.FinishReason?.ToString() ?? "--")}");

dotnet/samples/Concepts/ChatCompletion/OpenAI_CustomClient.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft. All rights reserved.
22

3+
using System.ClientModel;
34
using System.ClientModel.Primitives;
45
using Microsoft.SemanticKernel;
56
using OpenAI;
@@ -28,7 +29,7 @@ public async Task RunAsync()
2829
RetryPolicy = new ClientRetryPolicy()
2930
};
3031

31-
var customClient = new OpenAIClient(TestConfiguration.OpenAI.ApiKey, clientOptions);
32+
var customClient = new OpenAIClient(new ApiKeyCredential(TestConfiguration.OpenAI.ApiKey), clientOptions);
3233

3334
var kernel = Kernel.CreateBuilder()
3435
.AddOpenAIChatCompletion(TestConfiguration.OpenAI.ChatModelId, customClient)

dotnet/samples/Concepts/Planners/AutoFunctionCallingPlanning.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
using Microsoft.SemanticKernel.Planning;
1616
using OpenAI.Chat;
1717

18+
using ChatMessageContent = Microsoft.SemanticKernel.ChatMessageContent;
19+
1820
namespace Planners;
1921

2022
/// <summary>

0 commit comments

Comments
 (0)