Skip to content

Commit 1153614

Browse files
bmehta001Copilot
andcommitted
Unify EP download into single async method with optional callback
All SDKs now have one method instead of separate sync/progress variants: - C#: DownloadAndRegisterEpsAsync(names?, progressCallback?, ct?) Merged two overloads into one with optional Action<string,double>. - JS: downloadAndRegisterEps(names?, progressCallback?) Now async (returns Promise<EpDownloadResult>), no longer blocks the event loop. Removed downloadAndRegisterEpsWithProgress. Updated executeCommandStreaming to return response data. - Rust: download_and_register_eps(names, progress_callback) Now async with Option<F>, returns Result<EpDownloadResult>. Removed sync version and _with_progress variant. - Python: Already had unified API (no changes needed). Updated all READMEs, samples, examples, and regenerated docs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 94a6aa0 commit 1153614

16 files changed

+457
-188
lines changed

samples/js/native-chat-completions/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ for (const ep of eps) {
2727
if (eps.length > 0) {
2828
const maxNameLen = Math.max(...eps.map(e => e.name.length));
2929
let currentEp = '';
30-
await manager.downloadAndRegisterEpsWithProgress(undefined, (epName, percent) => {
30+
await manager.downloadAndRegisterEps(undefined, (epName, percent) => {
3131
if (epName !== currentEp) {
3232
if (currentEp !== '') {
3333
process.stdout.write('\n');

sdk/cs/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ dotnet build src/Microsoft.AI.Foundry.Local.csproj /p:UseWinML=true
5151
EP management is explicit via two methods:
5252

5353
- **`DiscoverEps()`** — returns an array of `EpInfo` describing each available EP and whether it is already registered.
54-
- **`DownloadAndRegisterEpsAsync(names?, ct?)`** — downloads and registers the specified EPs (or all available EPs if no names are given). This is a blocking call that returns an `EpDownloadResult`.
54+
- **`DownloadAndRegisterEpsAsync(names?, progressCallback?, ct?)`** — downloads and registers the specified EPs (or all available EPs if no names are given). Returns an `EpDownloadResult`.
5555

5656
```csharp
5757
// Initialize the manager first (see Quick Start)
@@ -64,7 +64,9 @@ var mgr = FoundryLocalManager.Instance;
6464
// Discover what EPs are available
6565
var eps = mgr.DiscoverEps();
6666
foreach (var ep in eps)
67+
{
6768
Console.WriteLine($"{ep.Name} — registered: {ep.IsRegistered}");
69+
}
6870

6971
// Download and register all EPs
7072
var result = await mgr.DownloadAndRegisterEpsAsync();
@@ -76,8 +78,8 @@ var result2 = await mgr.DownloadAndRegisterEpsAsync(new[] { eps[0].Name });
7678

7779
#### Per-EP download progress
7880

79-
An overload of `DownloadAndRegisterEpsAsync` accepts an `Action<string, double>` callback that is
80-
invoked with `(epName, percent)` as each EP downloads (`percent` is 0–100):
81+
Pass an optional `Action<string, double>` callback to receive `(epName, percent)` updates
82+
as each EP downloads (`percent` is 0–100):
8183

8284
```csharp
8385
string currentEp = "";

sdk/cs/docs/api/microsoft.ai.foundry.local.epdownloadresult.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ Namespace: Microsoft.AI.Foundry.Local
55
Result of an explicit EP download and registration operation.
66

77
```csharp
8-
public record EpDownloadResult
8+
public record EpDownloadResult : System.IEquatable`1[[Microsoft.AI.Foundry.Local.EpDownloadResult, Microsoft.AI.Foundry.Local, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]
99
```
1010

1111
## Properties
1212

13+
### Property Value
14+
15+
[Type](https://docs.microsoft.com/en-us/dotnet/api/system.type)<br>
16+
1317
### **Success**
1418

1519
True if all requested EPs were successfully downloaded and registered.

sdk/cs/docs/api/microsoft.ai.foundry.local.epinfo.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ Namespace: Microsoft.AI.Foundry.Local
55
Describes a discoverable execution provider bootstrapper.
66

77
```csharp
8-
public record EpInfo
8+
public record EpInfo : System.IEquatable`1[[Microsoft.AI.Foundry.Local.EpInfo, Microsoft.AI.Foundry.Local, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]
99
```
1010

1111
## Properties
1212

13+
### Property Value
14+
15+
[Type](https://docs.microsoft.com/en-us/dotnet/api/system.type)<br>
16+
1317
### **Name**
1418

1519
The identifier of the bootstrapper/execution provider (e.g. "CUDAExecutionProvider").

sdk/cs/docs/api/microsoft.ai.foundry.local.foundrylocalmanager.md

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ The model catalog.
9797
**Remarks:**
9898

9999
The catalog is populated on first use and returns models based on currently available execution providers.
100-
To ensure all hardware-accelerated models are listed, call [FoundryLocalManager.DownloadAndRegisterEpsAsync(IEnumerable&lt;String&gt;, Nullable&lt;CancellationToken&gt;)](./microsoft.ai.foundry.local.foundrylocalmanager.md#downloadandregisterepsasyncienumerablestring-nullablecancellationtoken) first to
100+
To ensure all hardware-accelerated models are listed, call [FoundryLocalManager.DownloadAndRegisterEpsAsync(IEnumerable&lt;String&gt;, Action&lt;String, Double&gt;, Nullable&lt;CancellationToken&gt;)](./microsoft.ai.foundry.local.foundrylocalmanager.md#downloadandregisterepsasyncienumerablestring-actionstring-double-nullablecancellationtoken) first to
101101
register execution providers, then access the catalog.
102102

103103
### **StartWebServiceAsync(Nullable&lt;CancellationToken&gt;)**
@@ -155,13 +155,12 @@ public EpInfo[] DiscoverEps()
155155
[EpInfo[]](./microsoft.ai.foundry.local.epinfo.md)<br>
156156
Array of EP bootstrapper info describing available EPs.
157157

158-
### **DownloadAndRegisterEpsAsync(IEnumerable&lt;String&gt;, Nullable&lt;CancellationToken&gt;)**
158+
### **DownloadAndRegisterEpsAsync(IEnumerable&lt;String&gt;, Action&lt;String, Double&gt;, Nullable&lt;CancellationToken&gt;)**
159159

160-
Downloads and registers execution providers. This is a blocking call that completes when all
161-
requested EPs have been processed.
160+
Downloads and registers execution providers.
162161

163162
```csharp
164-
public Task<EpDownloadResult> DownloadAndRegisterEpsAsync(IEnumerable<string> names, Nullable<CancellationToken> ct)
163+
public Task<EpDownloadResult> DownloadAndRegisterEpsAsync(IEnumerable<string> names, Action<string, double> progressCallback, Nullable<CancellationToken> ct)
165164
```
166165

167166
#### Parameters
@@ -170,6 +169,9 @@ public Task<EpDownloadResult> DownloadAndRegisterEpsAsync(IEnumerable<string> na
170169
Optional subset of EP bootstrapper names to download (as returned by [FoundryLocalManager.DiscoverEps()](./microsoft.ai.foundry.local.foundrylocalmanager.md#discovereps)).
171170
If null or empty, all discoverable EPs are downloaded.
172171

172+
`progressCallback` [Action&lt;String, Double&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.action-2)<br>
173+
Optional callback invoked as each EP downloads. Parameters are (epName, percentComplete) where percentComplete is 0-100.
174+
173175
`ct` [Nullable&lt;CancellationToken&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)<br>
174176
Optional cancellation token.
175177

@@ -183,31 +185,6 @@ Result describing which EPs succeeded and which failed.
183185
Catalog and model requests use whatever EPs are currently registered and do not block on EP downloads.
184186
After downloading new EPs, re-fetch the model catalog to include models requiring the newly registered EPs.
185187

186-
### **DownloadAndRegisterEpsAsync(IEnumerable&lt;String&gt;, Action&lt;String, Double&gt;, Nullable&lt;CancellationToken&gt;)**
187-
188-
Downloads and registers execution providers with per-EP progress reporting.
189-
190-
```csharp
191-
public Task<EpDownloadResult> DownloadAndRegisterEpsAsync(IEnumerable<string> names, Action<string, double> progressCallback, Nullable<CancellationToken> ct)
192-
```
193-
194-
#### Parameters
195-
196-
`names` [IEnumerable&lt;String&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)<br>
197-
Optional subset of EP bootstrapper names to download (as returned by [FoundryLocalManager.DiscoverEps()](./microsoft.ai.foundry.local.foundrylocalmanager.md#discovereps)).
198-
If null or empty, all discoverable EPs are downloaded.
199-
200-
`progressCallback` [Action&lt;String, Double&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.action-2)<br>
201-
Callback invoked as each EP downloads. Parameters are (epName, percentComplete) where percentComplete is 0-100.
202-
203-
`ct` [Nullable&lt;CancellationToken&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)<br>
204-
Optional cancellation token.
205-
206-
#### Returns
207-
208-
[Task&lt;EpDownloadResult&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)<br>
209-
Result describing which EPs succeeded and which failed.
210-
211188
### **Dispose(Boolean)**
212189

213190
```csharp
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# LiveAudioTranscriptionResponse
2+
3+
Namespace: Microsoft.AI.Foundry.Local.OpenAI
4+
5+
Transcription result for real-time audio streaming sessions.
6+
Extends the OpenAI Realtime API's so that
7+
customers access text via `result.Content[0].Text` or
8+
`result.Content[0].Transcript`, ensuring forward compatibility
9+
when the transport layer moves to WebSocket.
10+
11+
```csharp
12+
public class LiveAudioTranscriptionResponse : Betalgo.Ranul.OpenAI.ObjectModels.RealtimeModels.ConversationItem
13+
```
14+
15+
Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → ConversationItem → [LiveAudioTranscriptionResponse](./microsoft.ai.foundry.local.openai.liveaudiotranscriptionresponse.md)
16+
17+
## Properties
18+
19+
### **IsFinal**
20+
21+
Whether this is a final or partial (interim) result.
22+
- Nemotron models always return `true` (every result is final).
23+
- Other models (e.g., Azure Embedded) may return `false` for interim
24+
hypotheses that will be replaced by a subsequent final result.
25+
26+
```csharp
27+
public bool IsFinal { get; set; }
28+
```
29+
30+
#### Property Value
31+
32+
[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
33+
34+
### **StartTime**
35+
36+
Start time offset of this segment in the audio stream (seconds).
37+
38+
```csharp
39+
public Nullable<double> StartTime { get; set; }
40+
```
41+
42+
#### Property Value
43+
44+
[Nullable&lt;Double&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)<br>
45+
46+
### **EndTime**
47+
48+
End time offset of this segment in the audio stream (seconds).
49+
50+
```csharp
51+
public Nullable<double> EndTime { get; set; }
52+
```
53+
54+
#### Property Value
55+
56+
[Nullable&lt;Double&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)<br>
57+
58+
### **Id**
59+
60+
```csharp
61+
public string Id { get; set; }
62+
```
63+
64+
#### Property Value
65+
66+
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
67+
68+
### **Type**
69+
70+
```csharp
71+
public ItemType Type { get; set; }
72+
```
73+
74+
#### Property Value
75+
76+
ItemType<br>
77+
78+
### **Status**
79+
80+
```csharp
81+
public Nullable<Status> Status { get; set; }
82+
```
83+
84+
#### Property Value
85+
86+
[Nullable&lt;Status&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)<br>
87+
88+
### **Role**
89+
90+
```csharp
91+
public Nullable<Role> Role { get; set; }
92+
```
93+
94+
#### Property Value
95+
96+
[Nullable&lt;Role&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)<br>
97+
98+
### **Content**
99+
100+
```csharp
101+
public List<ContentPart> Content { get; set; }
102+
```
103+
104+
#### Property Value
105+
106+
[List&lt;ContentPart&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)<br>
107+
108+
### **CallId**
109+
110+
```csharp
111+
public string CallId { get; set; }
112+
```
113+
114+
#### Property Value
115+
116+
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
117+
118+
### **Name**
119+
120+
```csharp
121+
public string Name { get; set; }
122+
```
123+
124+
#### Property Value
125+
126+
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
127+
128+
### **Arguments**
129+
130+
```csharp
131+
public string Arguments { get; set; }
132+
```
133+
134+
#### Property Value
135+
136+
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
137+
138+
### **Output**
139+
140+
```csharp
141+
public string Output { get; set; }
142+
```
143+
144+
#### Property Value
145+
146+
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
147+
148+
## Constructors
149+
150+
### **LiveAudioTranscriptionResponse()**
151+
152+
```csharp
153+
public LiveAudioTranscriptionResponse()
154+
```

0 commit comments

Comments
 (0)