Skip to content

Commit 072a4bb

Browse files
MaanavDCopilot
andcommitted
Switch C# Responses client to official OpenAI package
Replaces the hand-rolled Responses DTO/SSE/serialization layer with the official `OpenAI` 2.10.0 NuGet package's `OpenAI.Responses.ResponsesClient` while keeping `Microsoft.AI.Foundry.Local.OpenAIResponsesClient` as the public Foundry Local-shaped wrapper. - Public surface unchanged: `OpenAIResponsesClient` ctor, `Settings`, `CreateAsync` / `CreateStreamingAsync` / `GetAsync` / `DeleteAsync` / `CancelAsync` / `GetInputItemsAsync` / `ListAsync` - Endpoints come from `OpenAI.Responses.ResponsesClient` configured with the Foundry Local web service URL via `OpenAIClientOptions.Endpoint`; only `ListAsync` keeps a small `HttpClient` shim for Foundry Local's list-responses extension (the official client doesn't expose that yet) - `ResponsesClientSettings` keeps the same Foundry Local-shaped knobs but applies them onto official `CreateResponseOptions` (`MaxOutputTokenCount`, `StoredOutputEnabled`, `ParallelToolCallsEnabled`, etc.) - New `ResponseContentPartHelpers` produces official `ResponseContentPart` instances for vision: file (auto-detect MIME, throws on missing/unknown extension), bytes (data URI), and URL - Vision now uses official OpenAI shape (`input_image` + `image_url` data URI) rather than Foundry Local's `image_data` + `media_type` extension - Deleted the hand-rolled `ResponsesTypes.cs` polymorphic DTO surface and the source-gen `ResponsesSerializationContext` Bug fixes: - Avoid `op_Implicit(null)` on `ResponseImageDetailLevel` and `ResponseItemCollectionOrder` value-type structs when callers pass null/empty options - Map `ClientResultException` -> `FoundryLocalException` consistently across CRUD methods Tests: - Unit tests rewritten for the official surface; cover settings defaults, input validation, image helper factories, MIME detection, and `ListResponsesResult.FromJson` parsing - Integration tests updated to use `CreateResponseOptions` / `ResponseItem` / `StreamingResponseUpdate` types - `dotnet build` clean; all Responses tests pass (51/61 overall, the 10 failures are pre-existing `EmbeddingClientTests` infra) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 64e78f2 commit 072a4bb

6 files changed

Lines changed: 349 additions & 1966 deletions

File tree

sdk/cs/src/Microsoft.AI.Foundry.Local.csproj

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@
7272
<!-- This target runs automatically after package assets are resolved and prints the exact version of the Core package that was selected. -->
7373
<Target Name="PrintResolvedVersions" AfterTargets="ResolvePackageAssets">
7474
<Message Importance="High" Text="Resolved Dependencies:" />
75-
<Message Importance="High" Text=" %(PackageDependencies.Identity) : %(PackageDependencies.Version)"
76-
Condition="$([System.String]::Copy('%(PackageDependencies.Identity)').StartsWith('Microsoft.AI.Foundry.Local.Core'))" />
75+
<Message Importance="High" Text=" %(PackageDependencies.Identity) : %(PackageDependencies.Version)" Condition="$([System.String]::Copy('%(PackageDependencies.Identity)').StartsWith('Microsoft.AI.Foundry.Local.Core'))" />
7776
</Target>
7877

7978
<ItemGroup>
@@ -121,14 +120,13 @@
121120
<NoWarn>$(NoWarn);NU1604</NoWarn>
122121
</PropertyGroup>
123122
<ItemGroup>
124-
<PackageReference Condition="'$(UseWinML)' == 'true'"
125-
Include="Microsoft.AI.Foundry.Local.Core.WinML" Version="$(FoundryLocalCoreWinMLVersion)" />
126-
<PackageReference Condition="'$(UseWinML)' != 'true'"
127-
Include="Microsoft.AI.Foundry.Local.Core" Version="$(FoundryLocalCoreVersion)" />
123+
<PackageReference Condition="'$(UseWinML)' == 'true'" Include="Microsoft.AI.Foundry.Local.Core.WinML" Version="$(FoundryLocalCoreWinMLVersion)" />
124+
<PackageReference Condition="'$(UseWinML)' != 'true'" Include="Microsoft.AI.Foundry.Local.Core" Version="$(FoundryLocalCoreVersion)" />
128125

129126
<PackageReference Include="Betalgo.Ranul.OpenAI" Version="9.1.0" />
130127
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.9" />
131128
<!-- specify PrivateAssets to exclude from nuget dependencies -->
132-
<PackageReference Include="IDisposableAnalyzers" Version="4.0.8" PrivateAssets="all"/>
129+
<PackageReference Include="IDisposableAnalyzers" Version="4.0.8" PrivateAssets="all" />
130+
<PackageReference Include="OpenAI" Version="2.10.0" />
133131
</ItemGroup>
134132
</Project>

0 commit comments

Comments
 (0)