Commit 072a4bb
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
- OpenAI
- test/FoundryLocal.Tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
| 75 | + | |
77 | 76 | | |
78 | 77 | | |
79 | 78 | | |
| |||
121 | 120 | | |
122 | 121 | | |
123 | 122 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 123 | + | |
| 124 | + | |
128 | 125 | | |
129 | 126 | | |
130 | 127 | | |
131 | 128 | | |
132 | | - | |
| 129 | + | |
| 130 | + | |
133 | 131 | | |
134 | 132 | | |
0 commit comments