Commit 1b00229
committed
feat(sdk/cs): add Responses API client for OpenAI/OpenResponses compatibility
Add OpenAIResponsesClient to the C# SDK v2 with full CRUD support for the
Responses API served by Foundry Local's embedded web service.
New files:
- src/OpenAI/ResponsesClient.cs: HTTP-based client with SSE streaming
- src/OpenAI/ResponsesTypes.cs: Request/response DTOs, items, streaming events
- src/OpenAI/ResponsesJsonContext.cs: AOT-compatible source-generated JSON context
Modified files:
- src/IModel.cs: GetResponsesClientAsync() on IModel interface
- src/ModelVariant.cs: Implementation with web service URL validation
- src/Model.cs: Delegation to SelectedVariant
- src/FoundryLocalManager.cs: GetResponsesClient() factory method
Key design decisions:
- HTTP-based (HttpClient + SSE), not FFI, since no CoreInterop command exists
- AOT-compatible: all serialization uses source-generated JsonSerializerContext
- IDisposable: HttpClient properly disposed
- Follows existing patterns: Utils.CallWithExceptionHandling, ConfigureAwait(false)
- Factory on FoundryLocalManager + convenience on IModel
- ResponseObject.OutputText convenience property (matches OpenAI Python SDK)
- Full CRUD: Create, CreateStreaming, Get, Delete, Cancel, GetInputItems1 parent b76b3ea commit 1b00229
8 files changed
Lines changed: 1703 additions & 0 deletions
File tree
- sdk/cs
- src
- OpenAI
- test/FoundryLocal.Tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
153 | 171 | | |
154 | 172 | | |
155 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
70 | 80 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
116 | 121 | | |
117 | 122 | | |
118 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
103 | 110 | | |
104 | 111 | | |
105 | 112 | | |
| |||
190 | 197 | | |
191 | 198 | | |
192 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
193 | 217 | | |
0 commit comments