Commit 64e78f2
Add OpenAI Responses API client to C# SDK
Implements `OpenAIResponsesClient` for the OpenAI Responses API surface in the C# SDK, mirroring the Python (#670) and JS (#671) SDKs and incorporating their resolved review feedback up front.
- New `Microsoft.AI.Foundry.Local.OpenAI.OpenAIResponsesClient` (HTTP-only, `HttpClient`-based, no FFI)
- Non-streaming + IAsyncEnumerable streaming (`Channel<T>` SSE pipeline)
- Full CRUD: `GetAsync`, `DeleteAsync`, `CancelAsync`, `GetInputItemsAsync`, `ListAsync(limit, order, after)`
- Polymorphic content parts and response items via `[JsonPolymorphic]` + source-gen context
- Streaming events for lifecycle, output, text deltas, function calls, and reasoning
- Vision helpers: `InputImageContent.FromFile/FromUrl/FromBytes`
- `FoundryLocalManager.GetResponsesClient(modelId?)` and `IModel.GetResponsesClientAsync`
Pre-applied PR review feedback from the Python and JS PRs:
- `Settings.Store` defaults to `null` (omit) instead of forcing `store=true`
- `InputImageContent.MediaType` is optional; unknown extensions omit the field so the server infers
- `InputImageContent.FromFile` throws `FileNotFoundException` on missing path
- `HttpClient.Timeout = Timeout.InfiniteTimeSpan`; callers use `CancellationToken` for deadlines (avoids 100s default cutting off SSE)
- `ListAsync` accepts `limit`, `order`, `after`; `ListResponsesResult` exposes `first_id`, `last_id`, `has_more`
- `InputImageContent.Validate()` enforces mutual exclusivity of `ImageUrl` / `ImageData` at request build time
- BMP supported in `DetectMediaType` alongside png/jpg/jpeg/gif/webp
- Uses shared `FoundryLocalException` for transport/parse errors, no dedicated `ResponsesException`
Tests: 22 unit tests (mocked HTTP) + integration tests gated on a running service. `dotnet build sdk/cs/src` clean; all Responses tests pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 088f844 commit 64e78f2
10 files changed
Lines changed: 2674 additions & 1 deletion
File tree
- sdk/cs
- src
- Detail
- OpenAI
- test/FoundryLocal.Tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
107 | 112 | | |
108 | 113 | | |
109 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
112 | 119 | | |
113 | 120 | | |
114 | 121 | | |
| |||
210 | 217 | | |
211 | 218 | | |
212 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
213 | 241 | | |
214 | 242 | | |
215 | 243 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
463 | 482 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
80 | 87 | | |
81 | 88 | | |
82 | 89 | | |
| |||
0 commit comments