Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: OpenAI V2 Migration - Apply recommendations #7471

Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion dotnet/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageVersion Include="OpenAI" Version="2.0.0-beta.5" />
<PackageVersion Include="System.ClientModel" Version="1.1.0-beta.4" />
<PackageVersion Include="Azure.AI.ContentSafety" Version="1.0.0" />
<PackageVersion Include="Azure.AI.OpenAI" Version="1.0.0-beta.17" />
<PackageVersion Include="Azure.AI.OpenAI" Version="2.0.0-beta.2" />
<PackageVersion Include="Azure.AI.OpenAI.Assistants" Version="1.0.0-beta.4" />
<PackageVersion Include="Azure.Identity" Version="1.12.0" />
<PackageVersion Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.3.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" VersionOverride="2.0.0-beta.2" />
<PackageReference Include="Azure.AI.OpenAI" />
</ItemGroup>

<ItemGroup>
Expand Down
1,222 changes: 1,222 additions & 0 deletions dotnet/src/Connectors/Connectors.OpenAI/CompatibilitySuppressions.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<NoWarn>$(NoWarn);NU5104;SKEXP0001,SKEXP0010</NoWarn>
<EnablePackageValidation>false</EnablePackageValidation>
<EnablePackageValidation>true</EnablePackageValidation>
</PropertyGroup>

<!-- IMPORT NUGET PACKAGE SHARED PROPERTIES -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.

/*
Phase 01

This class was created to simplify any Text Embeddings Support from the v1 ClientCore
*/

using System;
using System.ClientModel;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.

/*
Phase 02

- This class was created focused in the Image Generation using the SDK client instead of the own client in V1.
- Added Checking for empty or whitespace prompt.
- Removed the format parameter as this is never called in V1 code. Plan to implement it in the future once we change the ITextToImageService abstraction, using PromptExecutionSettings.
- Allow custom size for images when the endpoint is not the default OpenAI v1 endpoint.
*/

using System.ClientModel;
using System.Threading;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.

/* Phase 4
- Added missing OpenAIClient extensions for audio
- Updated the Experimental attribute to the correct value 0001 -> 0010 (Connector)
*/
using System;
using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ namespace Microsoft.SemanticKernel;

#pragma warning disable IDE0039 // Use local function

/* Phase 02
- Add endpoint parameter for both Embedding and TextToImage services extensions.
- Removed unnecessary Validation checks (that are already happening in the service/client constructors)
- Added openAIClient extension for TextToImage service.
- Changed parameters order for TextToImage service extension (modelId comes first).
- Made modelId a required parameter of TextToImage services.

*/
/// <summary>
/// Sponsor extensions class for <see cref="IServiceCollection"/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@

namespace Microsoft.SemanticKernel.Connectors.OpenAI;

/* Phase 02
Adding the non-default endpoint parameter to the constructor.
*/

/// <summary>
/// OpenAI implementation of <see cref="ITextEmbeddingGenerationService"/>
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,6 @@
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel.TextToImage;

/* Phase 02
- Breaking the current constructor parameter order to follow the same order as the other services.
- Added custom endpoint support, and removed ApiKey validation, as it is performed by the ClientCore when the Endpoint is not provided.
- Added custom OpenAIClient support.
- Updated "organization" parameter to "organizationId".
- "modelId" parameter is now required in the constructor.

- Added OpenAIClient breaking glass constructor.

Phase 08
- Removed OpenAIClient breaking glass constructor
- Reverted the order and parameter names.
*/

namespace Microsoft.SemanticKernel.Connectors.OpenAI;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.

/* Phase 4
Bringing the OpenAITextToAudioExecutionSettings class to the OpenAI connector as is

*/

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.

/*
Phase 01:
This class is introduced in exchange for the original RequestExceptionExtensions class of Azure.Core to the new ClientException from System.ClientModel,
Preserved the logic as is.
*/

using System.ClientModel;
using System.Diagnostics.CodeAnalysis;
using System.Net;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.

/* Phase 03
Adapted from OpenAI SDK original policy with warning updates.

Original file: https://github.com/openai/openai-dotnet/blob/0b97311f58dfb28bd883d990f68d548da040a807/src/Utility/GenericActionPipelinePolicy.cs#L8
*/

using System;
using System.ClientModel.Primitives;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
using System.Threading.Tasks;
using Microsoft.SemanticKernel.Services;

/* Phase 02
- Changing "description" parameter to "prompt" to better match the OpenAI API and avoid confusion.
*/

namespace Microsoft.SemanticKernel.TextToImage;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.

/* Phase 01
This class was imported and adapted from the System.ClientModel Unit Tests.
https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockPipelineResponse.cs
*/

using System;
using System.ClientModel.Primitives;
using System.IO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.

/* Phase 01
This class was imported and adapted from the System.ClientModel Unit Tests.
https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/tests/TestFramework/Mocks/MockResponseHeaders.cs
*/

using System;
using System.ClientModel.Primitives;
using System.Collections.Generic;
Expand Down
Loading