diff --git a/samples/cs/audio-transcription-example/Program.cs b/samples/cs/audio-transcription-example/Program.cs index ac5689c1..10047421 100644 --- a/samples/cs/audio-transcription-example/Program.cs +++ b/samples/cs/audio-transcription-example/Program.cs @@ -17,10 +17,18 @@ // Ensure that any Execution Provider (EP) downloads run and are completed. -// EP packages include dependencies and may be large. -// Download is only required again if a new version of the EP is released. -// For cross platform builds there is no dynamic EP download and this will return immediately. -await Utils.RunWithSpinner("Registering execution providers", mgr.DownloadAndRegisterEpsAsync()); +// Download and register all execution providers. +var currentEp = ""; +await mgr.DownloadAndRegisterEpsAsync((epName, percent) => +{ + if (epName != currentEp) + { + if (currentEp != "") Console.WriteLine(); + currentEp = epName; + } + Console.Write($"\r {epName.PadRight(30)} {percent,6:F1}%"); +}); +if (currentEp != "") Console.WriteLine(); // diff --git a/samples/cs/foundry-local-web-server/Program.cs b/samples/cs/foundry-local-web-server/Program.cs index 9225ad7d..eb88e4b3 100644 --- a/samples/cs/foundry-local-web-server/Program.cs +++ b/samples/cs/foundry-local-web-server/Program.cs @@ -23,10 +23,18 @@ // Ensure that any Execution Provider (EP) downloads run and are completed. -// EP packages include dependencies and may be large. -// Download is only required again if a new version of the EP is released. -// For cross platform builds there is no dynamic EP download and this will return immediately. -await Utils.RunWithSpinner("Registering execution providers", mgr.DownloadAndRegisterEpsAsync()); +// Download and register all execution providers. +var currentEp = ""; +await mgr.DownloadAndRegisterEpsAsync((epName, percent) => +{ + if (epName != currentEp) + { + if (currentEp != "") Console.WriteLine(); + currentEp = epName; + } + Console.Write($"\r {epName.PadRight(30)} {percent,6:F1}%"); +}); +if (currentEp != "") Console.WriteLine(); // diff --git a/samples/cs/model-management-example/Program.cs b/samples/cs/model-management-example/Program.cs index a34d2737..76beb89f 100644 --- a/samples/cs/model-management-example/Program.cs +++ b/samples/cs/model-management-example/Program.cs @@ -17,7 +17,17 @@ // Download and register all execution providers. -await Utils.RunWithSpinner("Registering execution providers", mgr.DownloadAndRegisterEpsAsync()); +var currentEp = ""; +await mgr.DownloadAndRegisterEpsAsync((epName, percent) => +{ + if (epName != currentEp) + { + if (currentEp != "") Console.WriteLine(); + currentEp = epName; + } + Console.Write($"\r {epName.PadRight(30)} {percent,6:F1}%"); +}); +if (currentEp != "") Console.WriteLine(); // Model catalog operations diff --git a/samples/cs/tool-calling-foundry-local-sdk/Program.cs b/samples/cs/tool-calling-foundry-local-sdk/Program.cs index 8ac96369..2a568330 100644 --- a/samples/cs/tool-calling-foundry-local-sdk/Program.cs +++ b/samples/cs/tool-calling-foundry-local-sdk/Program.cs @@ -23,10 +23,18 @@ // Ensure that any Execution Provider (EP) downloads run and are completed. -// EP packages include dependencies and may be large. -// Download is only required again if a new version of the EP is released. -// For cross platform builds there is no dynamic EP download and this will return immediately. -await Utils.RunWithSpinner("Registering execution providers", mgr.DownloadAndRegisterEpsAsync()); +// Download and register all execution providers. +var currentEp = ""; +await mgr.DownloadAndRegisterEpsAsync((epName, percent) => +{ + if (epName != currentEp) + { + if (currentEp != "") Console.WriteLine(); + currentEp = epName; + } + Console.Write($"\r {epName.PadRight(30)} {percent,6:F1}%"); +}); +if (currentEp != "") Console.WriteLine(); // diff --git a/samples/cs/tool-calling-foundry-local-web-server/Program.cs b/samples/cs/tool-calling-foundry-local-web-server/Program.cs index 48ee6c6f..6644a438 100644 --- a/samples/cs/tool-calling-foundry-local-web-server/Program.cs +++ b/samples/cs/tool-calling-foundry-local-web-server/Program.cs @@ -22,7 +22,17 @@ // Download and register all execution providers. -await Utils.RunWithSpinner("Registering execution providers", mgr.DownloadAndRegisterEpsAsync()); +var currentEp = ""; +await mgr.DownloadAndRegisterEpsAsync((epName, percent) => +{ + if (epName != currentEp) + { + if (currentEp != "") Console.WriteLine(); + currentEp = epName; + } + Console.Write($"\r {epName.PadRight(30)} {percent,6:F1}%"); +}); +if (currentEp != "") Console.WriteLine(); // Get the model catalog diff --git a/samples/cs/tutorial-chat-assistant/Program.cs b/samples/cs/tutorial-chat-assistant/Program.cs index 10e9a63b..d06de6a5 100644 --- a/samples/cs/tutorial-chat-assistant/Program.cs +++ b/samples/cs/tutorial-chat-assistant/Program.cs @@ -24,6 +24,19 @@ await FoundryLocalManager.CreateAsync(config, logger); var mgr = FoundryLocalManager.Instance; +// Download and register all execution providers. +var currentEp = ""; +await mgr.DownloadAndRegisterEpsAsync((epName, percent) => +{ + if (epName != currentEp) + { + if (currentEp != "") Console.WriteLine(); + currentEp = epName; + } + Console.Write($"\r {epName.PadRight(30)} {percent,6:F1}%"); +}); +if (currentEp != "") Console.WriteLine(); + // Select and load a model from the catalog var catalog = await mgr.GetCatalogAsync(); var model = await catalog.GetModelAsync("qwen2.5-0.5b") diff --git a/samples/cs/tutorial-document-summarizer/Program.cs b/samples/cs/tutorial-document-summarizer/Program.cs index bc5546f6..333d5c96 100644 --- a/samples/cs/tutorial-document-summarizer/Program.cs +++ b/samples/cs/tutorial-document-summarizer/Program.cs @@ -24,6 +24,19 @@ await FoundryLocalManager.CreateAsync(config, logger); var mgr = FoundryLocalManager.Instance; +// Download and register all execution providers. +var currentEp = ""; +await mgr.DownloadAndRegisterEpsAsync((epName, percent) => +{ + if (epName != currentEp) + { + if (currentEp != "") Console.WriteLine(); + currentEp = epName; + } + Console.Write($"\r {epName.PadRight(30)} {percent,6:F1}%"); +}); +if (currentEp != "") Console.WriteLine(); + // Select and load a model from the catalog var catalog = await mgr.GetCatalogAsync(); var model = await catalog.GetModelAsync("qwen2.5-0.5b") diff --git a/samples/cs/tutorial-tool-calling/Program.cs b/samples/cs/tutorial-tool-calling/Program.cs index 74f137db..5ae60419 100644 --- a/samples/cs/tutorial-tool-calling/Program.cs +++ b/samples/cs/tutorial-tool-calling/Program.cs @@ -122,6 +122,19 @@ string ExecuteTool(string functionName, JsonElement arguments) await FoundryLocalManager.CreateAsync(config, logger); var mgr = FoundryLocalManager.Instance; +// Download and register all execution providers. +var currentEp = ""; +await mgr.DownloadAndRegisterEpsAsync((epName, percent) => +{ + if (epName != currentEp) + { + if (currentEp != "") Console.WriteLine(); + currentEp = epName; + } + Console.Write($"\r {epName.PadRight(30)} {percent,6:F1}%"); +}); +if (currentEp != "") Console.WriteLine(); + var catalog = await mgr.GetCatalogAsync(); var model = await catalog.GetModelAsync("qwen2.5-0.5b") ?? throw new Exception("Model not found"); diff --git a/samples/cs/tutorial-voice-to-text/Program.cs b/samples/cs/tutorial-voice-to-text/Program.cs index 976b44e4..9a1a36c3 100644 --- a/samples/cs/tutorial-voice-to-text/Program.cs +++ b/samples/cs/tutorial-voice-to-text/Program.cs @@ -26,6 +26,20 @@ // Initialize the singleton instance await FoundryLocalManager.CreateAsync(config, logger); var mgr = FoundryLocalManager.Instance; + +// Download and register all execution providers. +var currentEp = ""; +await mgr.DownloadAndRegisterEpsAsync((epName, percent) => +{ + if (epName != currentEp) + { + if (currentEp != "") Console.WriteLine(); + currentEp = epName; + } + Console.Write($"\r {epName.PadRight(30)} {percent,6:F1}%"); +}); +if (currentEp != "") Console.WriteLine(); + var catalog = await mgr.GetCatalogAsync(); // diff --git a/samples/js/audio-transcription-example/app.js b/samples/js/audio-transcription-example/app.js index c2517ec7..51b69f99 100644 --- a/samples/js/audio-transcription-example/app.js +++ b/samples/js/audio-transcription-example/app.js @@ -14,6 +14,17 @@ const manager = FoundryLocalManager.create({ // console.log('✓ SDK initialized successfully'); +// Download and register all execution providers. +let currentEp = ''; +await manager.downloadAndRegisterEps((epName, percent) => { + if (epName !== currentEp) { + if (currentEp !== '') process.stdout.write('\n'); + currentEp = epName; + } + process.stdout.write(`\r ${epName.padEnd(30)} ${percent.toFixed(1).padStart(5)}%`); +}); +if (currentEp !== '') process.stdout.write('\n'); + // // Get the model object const modelAlias = 'whisper-tiny'; // Using an available model from the list above diff --git a/samples/js/chat-and-audio-foundry-local/src/app.js b/samples/js/chat-and-audio-foundry-local/src/app.js index 50bc195f..87845aa6 100644 --- a/samples/js/chat-and-audio-foundry-local/src/app.js +++ b/samples/js/chat-and-audio-foundry-local/src/app.js @@ -15,6 +15,17 @@ async function main() { logLevel: "info", }); + // Download and register all execution providers. + let currentEp = ''; + await manager.downloadAndRegisterEps((epName, percent) => { + if (epName !== currentEp) { + if (currentEp !== '') process.stdout.write('\n'); + currentEp = epName; + } + process.stdout.write(`\r ${epName.padEnd(30)} ${percent.toFixed(1).padStart(5)}%`); + }); + if (currentEp !== '') process.stdout.write('\n'); + const catalog = manager.catalog; // --- Load both models --- diff --git a/samples/js/copilot-sdk-foundry-local/src/app.ts b/samples/js/copilot-sdk-foundry-local/src/app.ts index c7c7966a..4c201351 100644 --- a/samples/js/copilot-sdk-foundry-local/src/app.ts +++ b/samples/js/copilot-sdk-foundry-local/src/app.ts @@ -60,6 +60,17 @@ async function main() { webServiceUrls: endpointUrl, }); + // Download and register all execution providers. + let currentEp = ''; + await manager.downloadAndRegisterEps((epName, percent) => { + if (epName !== currentEp) { + if (currentEp !== '') process.stdout.write('\n'); + currentEp = epName; + } + process.stdout.write(`\r ${epName.padEnd(30)} ${percent.toFixed(1).padStart(5)}%`); + }); + if (currentEp !== '') process.stdout.write('\n'); + model = await manager.catalog.getModel(alias); await model.download(); await model.load(); diff --git a/samples/js/copilot-sdk-foundry-local/src/tool-calling.ts b/samples/js/copilot-sdk-foundry-local/src/tool-calling.ts index 3e41748c..3651b527 100644 --- a/samples/js/copilot-sdk-foundry-local/src/tool-calling.ts +++ b/samples/js/copilot-sdk-foundry-local/src/tool-calling.ts @@ -139,6 +139,17 @@ async function main() { webServiceUrls: endpointUrl, }); + // Download and register all execution providers. + let currentEp = ''; + await manager.downloadAndRegisterEps((epName, percent) => { + if (epName !== currentEp) { + if (currentEp !== '') process.stdout.write('\n'); + currentEp = epName; + } + process.stdout.write(`\r ${epName.padEnd(30)} ${percent.toFixed(1).padStart(5)}%`); + }); + if (currentEp !== '') process.stdout.write('\n'); + model = await manager.catalog.getModel(alias); await model.download(); await model.load(); diff --git a/samples/js/electron-chat-application/main.js b/samples/js/electron-chat-application/main.js index 22a1fc1d..92473846 100644 --- a/samples/js/electron-chat-application/main.js +++ b/samples/js/electron-chat-application/main.js @@ -50,17 +50,34 @@ let webServiceStarted = false; const SERVICE_PORT = 47392; const SERVICE_URL = `http://127.0.0.1:${SERVICE_PORT}`; +let initPromise = null; + async function initializeSDK() { - if (manager) return manager; + if (initPromise) return initPromise; - const { FoundryLocalManager } = await import('foundry-local-sdk'); - manager = FoundryLocalManager.create({ - appName: 'foundry_local_samples', - logLevel: 'info', - webServiceUrls: SERVICE_URL - }); + initPromise = (async () => { + const { FoundryLocalManager } = await import('foundry-local-sdk'); + manager = FoundryLocalManager.create({ + appName: 'foundry_local_samples', + logLevel: 'info', + webServiceUrls: SERVICE_URL + }); + + // Download and register all execution providers. + let currentEp = ''; + await manager.downloadAndRegisterEps((epName, percent) => { + if (epName !== currentEp) { + if (currentEp !== '') process.stdout.write('\n'); + currentEp = epName; + } + process.stdout.write(`\r ${epName.padEnd(30)} ${percent.toFixed(1).padStart(5)}%`); + }); + if (currentEp !== '') process.stdout.write('\n'); + + return manager; + })(); - return manager; + return initPromise; } function ensureWebServiceStarted() { diff --git a/samples/js/langchain-integration-example/app.js b/samples/js/langchain-integration-example/app.js index 9e4b7b60..8b2e74e3 100644 --- a/samples/js/langchain-integration-example/app.js +++ b/samples/js/langchain-integration-example/app.js @@ -19,6 +19,17 @@ const manager = FoundryLocalManager.create({ // console.log('✓ SDK initialized successfully'); +// Download and register all execution providers. +let currentEp = ''; +await manager.downloadAndRegisterEps((epName, percent) => { + if (epName !== currentEp) { + if (currentEp !== '') process.stdout.write('\n'); + currentEp = epName; + } + process.stdout.write(`\r ${epName.padEnd(30)} ${percent.toFixed(1).padStart(5)}%`); +}); +if (currentEp !== '') process.stdout.write('\n'); + // Get the model object const modelAlias = 'qwen2.5-0.5b'; // Using an available model from the list above const model = await manager.catalog.getModel(modelAlias); diff --git a/samples/js/tool-calling-foundry-local/src/app.js b/samples/js/tool-calling-foundry-local/src/app.js index f92464ee..cb06466b 100644 --- a/samples/js/tool-calling-foundry-local/src/app.js +++ b/samples/js/tool-calling-foundry-local/src/app.js @@ -33,6 +33,17 @@ async function runToolCallingExample() { }); // + // Download and register all execution providers. + let currentEp = ''; + await manager.downloadAndRegisterEps((epName, percent) => { + if (epName !== currentEp) { + if (currentEp !== '') process.stdout.write('\n'); + currentEp = epName; + } + process.stdout.write(`\r ${epName.padEnd(30)} ${percent.toFixed(1).padStart(5)}%`); + }); + if (currentEp !== '') process.stdout.write('\n'); + // const catalog = manager.catalog; model = await catalog.getModel(alias); diff --git a/samples/js/tutorial-chat-assistant/app.js b/samples/js/tutorial-chat-assistant/app.js index 9a5a430c..bb97960d 100644 --- a/samples/js/tutorial-chat-assistant/app.js +++ b/samples/js/tutorial-chat-assistant/app.js @@ -11,6 +11,17 @@ const manager = FoundryLocalManager.create({ logLevel: 'info' }); +// Download and register all execution providers. +let currentEp = ''; +await manager.downloadAndRegisterEps((epName, percent) => { + if (epName !== currentEp) { + if (currentEp !== '') process.stdout.write('\n'); + currentEp = epName; + } + process.stdout.write(`\r ${epName.padEnd(30)} ${percent.toFixed(1).padStart(5)}%`); +}); +if (currentEp !== '') process.stdout.write('\n'); + // Select and load a model from the catalog const model = await manager.catalog.getModel('qwen2.5-0.5b'); diff --git a/samples/js/tutorial-document-summarizer/app.js b/samples/js/tutorial-document-summarizer/app.js index f43e204d..436b626b 100644 --- a/samples/js/tutorial-document-summarizer/app.js +++ b/samples/js/tutorial-document-summarizer/app.js @@ -40,6 +40,17 @@ const manager = FoundryLocalManager.create({ logLevel: 'info' }); +// Download and register all execution providers. +let currentEp = ''; +await manager.downloadAndRegisterEps((epName, percent) => { + if (epName !== currentEp) { + if (currentEp !== '') process.stdout.write('\n'); + currentEp = epName; + } + process.stdout.write(`\r ${epName.padEnd(30)} ${percent.toFixed(1).padStart(5)}%`); +}); +if (currentEp !== '') process.stdout.write('\n'); + // Select and load a model from the catalog const model = await manager.catalog.getModel('qwen2.5-0.5b'); diff --git a/samples/js/tutorial-tool-calling/app.js b/samples/js/tutorial-tool-calling/app.js index efdd710c..b3b15d0a 100644 --- a/samples/js/tutorial-tool-calling/app.js +++ b/samples/js/tutorial-tool-calling/app.js @@ -122,6 +122,17 @@ const manager = FoundryLocalManager.create({ logLevel: 'info' }); +// Download and register all execution providers. +let currentEp = ''; +await manager.downloadAndRegisterEps((epName, percent) => { + if (epName !== currentEp) { + if (currentEp !== '') process.stdout.write('\n'); + currentEp = epName; + } + process.stdout.write(`\r ${epName.padEnd(30)} ${percent.toFixed(1).padStart(5)}%`); +}); +if (currentEp !== '') process.stdout.write('\n'); + const model = await manager.catalog.getModel('qwen2.5-0.5b'); await model.download((progress) => { diff --git a/samples/js/tutorial-voice-to-text/app.js b/samples/js/tutorial-voice-to-text/app.js index 08074100..60057e06 100644 --- a/samples/js/tutorial-voice-to-text/app.js +++ b/samples/js/tutorial-voice-to-text/app.js @@ -15,6 +15,17 @@ const manager = FoundryLocalManager.create({ }); // +// Download and register all execution providers. +let currentEp = ''; +await manager.downloadAndRegisterEps((epName, percent) => { + if (epName !== currentEp) { + if (currentEp !== '') process.stdout.write('\n'); + currentEp = epName; + } + process.stdout.write(`\r ${epName.padEnd(30)} ${percent.toFixed(1).padStart(5)}%`); +}); +if (currentEp !== '') process.stdout.write('\n'); + // // Load the speech-to-text model const speechModel = await manager.catalog.getModel('whisper-tiny'); diff --git a/samples/js/web-server-example/app.js b/samples/js/web-server-example/app.js index b03bf9df..c9a1e5ce 100644 --- a/samples/js/web-server-example/app.js +++ b/samples/js/web-server-example/app.js @@ -18,6 +18,17 @@ const manager = FoundryLocalManager.create({ // console.log('✓ SDK initialized successfully'); +// Download and register all execution providers. +let currentEp = ''; +await manager.downloadAndRegisterEps((epName, percent) => { + if (epName !== currentEp) { + if (currentEp !== '') process.stdout.write('\n'); + currentEp = epName; + } + process.stdout.write(`\r ${epName.padEnd(30)} ${percent.toFixed(1).padStart(5)}%`); +}); +if (currentEp !== '') process.stdout.write('\n'); + // // Get the model object const modelAlias = 'qwen2.5-0.5b'; // Using an available model from the list above diff --git a/samples/python/audio-transcription/src/app.py b/samples/python/audio-transcription/src/app.py index 20f9be04..ca06fb28 100644 --- a/samples/python/audio-transcription/src/app.py +++ b/samples/python/audio-transcription/src/app.py @@ -11,6 +11,20 @@ FoundryLocalManager.initialize(config) manager = FoundryLocalManager.instance +# Download and register all execution providers. +current_ep = "" +def _ep_progress(ep_name: str, percent: float): + global current_ep + if ep_name != current_ep: + if current_ep: + print() + current_ep = ep_name + print(f"\r {ep_name:<30} {percent:5.1f}%", end="", flush=True) + +manager.download_and_register_eps(progress_callback=_ep_progress) +if current_ep: + print() + # Load the whisper model for speech-to-text model = manager.catalog.get_model("whisper-tiny") model.download( diff --git a/samples/python/langchain-integration/src/app.py b/samples/python/langchain-integration/src/app.py index 1dd00224..4f8661cd 100644 --- a/samples/python/langchain-integration/src/app.py +++ b/samples/python/langchain-integration/src/app.py @@ -12,6 +12,20 @@ FoundryLocalManager.initialize(config) manager = FoundryLocalManager.instance +# Download and register all execution providers. +current_ep = "" +def _ep_progress(ep_name: str, percent: float): + global current_ep + if ep_name != current_ep: + if current_ep: + print() + current_ep = ep_name + print(f"\r {ep_name:<30} {percent:5.1f}%", end="", flush=True) + +manager.download_and_register_eps(progress_callback=_ep_progress) +if current_ep: + print() + # Load a model model = manager.catalog.get_model("qwen2.5-0.5b") model.download( diff --git a/samples/python/native-chat-completions/src/app.py b/samples/python/native-chat-completions/src/app.py index ca087b77..457d0cf5 100644 --- a/samples/python/native-chat-completions/src/app.py +++ b/samples/python/native-chat-completions/src/app.py @@ -12,6 +12,20 @@ async def main(): FoundryLocalManager.initialize(config) manager = FoundryLocalManager.instance + # Download and register all execution providers. + current_ep = "" + def ep_progress(ep_name: str, percent: float): + nonlocal current_ep + if ep_name != current_ep: + if current_ep: + print() + current_ep = ep_name + print(f"\r {ep_name:<30} {percent:5.1f}%", end="", flush=True) + + manager.download_and_register_eps(progress_callback=ep_progress) + if current_ep: + print() + # Select and load a model from the catalog model = manager.catalog.get_model("qwen2.5-0.5b") model.download( diff --git a/samples/python/tool-calling/src/app.py b/samples/python/tool-calling/src/app.py index ac00b023..995900e3 100644 --- a/samples/python/tool-calling/src/app.py +++ b/samples/python/tool-calling/src/app.py @@ -136,6 +136,20 @@ async def main(): FoundryLocalManager.initialize(config) manager = FoundryLocalManager.instance + # Download and register all execution providers. + current_ep = "" + def ep_progress(ep_name: str, percent: float): + nonlocal current_ep + if ep_name != current_ep: + if current_ep: + print() + current_ep = ep_name + print(f"\r {ep_name:<30} {percent:5.1f}%", end="", flush=True) + + manager.download_and_register_eps(progress_callback=ep_progress) + if current_ep: + print() + # Select and load a model model = manager.catalog.get_model("qwen2.5-0.5b") model.download( diff --git a/samples/python/tutorial-chat-assistant/src/app.py b/samples/python/tutorial-chat-assistant/src/app.py index 05fa0bcc..5aee3ae1 100644 --- a/samples/python/tutorial-chat-assistant/src/app.py +++ b/samples/python/tutorial-chat-assistant/src/app.py @@ -12,6 +12,20 @@ async def main(): FoundryLocalManager.initialize(config) manager = FoundryLocalManager.instance + # Download and register all execution providers. + current_ep = "" + def ep_progress(ep_name: str, percent: float): + nonlocal current_ep + if ep_name != current_ep: + if current_ep: + print() + current_ep = ep_name + print(f"\r {ep_name:<30} {percent:5.1f}%", end="", flush=True) + + manager.download_and_register_eps(progress_callback=ep_progress) + if current_ep: + print() + # Select and load a model from the catalog model = manager.catalog.get_model("qwen2.5-0.5b") model.download(lambda progress: print(f"\rDownloading model: {progress:.2f}%", end="", flush=True)) diff --git a/samples/python/tutorial-document-summarizer/src/app.py b/samples/python/tutorial-document-summarizer/src/app.py index 3a62fe24..671057cd 100644 --- a/samples/python/tutorial-document-summarizer/src/app.py +++ b/samples/python/tutorial-document-summarizer/src/app.py @@ -39,6 +39,20 @@ async def main(): FoundryLocalManager.initialize(config) manager = FoundryLocalManager.instance + # Download and register all execution providers. + current_ep = "" + def ep_progress(ep_name: str, percent: float): + nonlocal current_ep + if ep_name != current_ep: + if current_ep: + print() + current_ep = ep_name + print(f"\r {ep_name:<30} {percent:5.1f}%", end="", flush=True) + + manager.download_and_register_eps(progress_callback=ep_progress) + if current_ep: + print() + # Select and load a model from the catalog model = manager.catalog.get_model("qwen2.5-0.5b") model.download(lambda p: print(f"\rDownloading model: {p:.2f}%", end="", flush=True)) diff --git a/samples/python/tutorial-tool-calling/src/app.py b/samples/python/tutorial-tool-calling/src/app.py index b26085f6..5fc1cc53 100644 --- a/samples/python/tutorial-tool-calling/src/app.py +++ b/samples/python/tutorial-tool-calling/src/app.py @@ -136,6 +136,20 @@ async def main(): FoundryLocalManager.initialize(config) manager = FoundryLocalManager.instance + # Download and register all execution providers. + current_ep = "" + def ep_progress(ep_name: str, percent: float): + nonlocal current_ep + if ep_name != current_ep: + if current_ep: + print() + current_ep = ep_name + print(f"\r {ep_name:<30} {percent:5.1f}%", end="", flush=True) + + manager.download_and_register_eps(progress_callback=ep_progress) + if current_ep: + print() + # Select and load a model model = manager.catalog.get_model("qwen2.5-0.5b") model.download( diff --git a/samples/python/tutorial-voice-to-text/src/app.py b/samples/python/tutorial-voice-to-text/src/app.py index 4174e5ac..46ea3926 100644 --- a/samples/python/tutorial-voice-to-text/src/app.py +++ b/samples/python/tutorial-voice-to-text/src/app.py @@ -13,6 +13,20 @@ async def main(): manager = FoundryLocalManager.instance # + # Download and register all execution providers. + current_ep = "" + def ep_progress(ep_name: str, percent: float): + nonlocal current_ep + if ep_name != current_ep: + if current_ep: + print() + current_ep = ep_name + print(f"\r {ep_name:<30} {percent:5.1f}%", end="", flush=True) + + manager.download_and_register_eps(progress_callback=ep_progress) + if current_ep: + print() + # # Load the speech-to-text model speech_model = manager.catalog.get_model("whisper-tiny") diff --git a/samples/python/web-server/src/app.py b/samples/python/web-server/src/app.py index dc554ad9..67117029 100644 --- a/samples/python/web-server/src/app.py +++ b/samples/python/web-server/src/app.py @@ -10,6 +10,20 @@ FoundryLocalManager.initialize(config) manager = FoundryLocalManager.instance +# Download and register all execution providers. +current_ep = "" +def _ep_progress(ep_name: str, percent: float): + global current_ep + if ep_name != current_ep: + if current_ep: + print() + current_ep = ep_name + print(f"\r {ep_name:<30} {percent:5.1f}%", end="", flush=True) + +manager.download_and_register_eps(progress_callback=_ep_progress) +if current_ep: + print() + # Load a model model = manager.catalog.get_model("qwen2.5-0.5b") model.download( diff --git a/samples/rust/audio-transcription-example/src/main.rs b/samples/rust/audio-transcription-example/src/main.rs index f5fb4cff..70150546 100644 --- a/samples/rust/audio-transcription-example/src/main.rs +++ b/samples/rust/audio-transcription-example/src/main.rs @@ -27,6 +27,24 @@ async fn main() -> Result<(), Box> { let manager = FoundryLocalManager::create(FoundryLocalConfig::new("foundry_local_samples"))?; // + // Download and register all execution providers. + manager + .download_and_register_eps_with_progress(None, { + let mut current_ep = String::new(); + move |ep_name: &str, percent: f64| { + if ep_name != current_ep { + if !current_ep.is_empty() { + println!(); + } + current_ep = ep_name.to_string(); + } + print!("\r {:<30} {:5.1}%", ep_name, percent); + io::stdout().flush().ok(); + } + }) + .await?; + println!(); + // ── 2. Pick the whispermodel and ensure it is downloaded ──────────── // let model = manager.catalog().get_model(ALIAS).await?; diff --git a/samples/rust/foundry-local-webserver/src/main.rs b/samples/rust/foundry-local-webserver/src/main.rs index 02f0360e..d36581e9 100644 --- a/samples/rust/foundry-local-webserver/src/main.rs +++ b/samples/rust/foundry-local-webserver/src/main.rs @@ -26,6 +26,24 @@ async fn main() -> Result<(), Box> { println!("✓ SDK initialized"); // + // Download and register all execution providers. + manager + .download_and_register_eps_with_progress(None, { + let mut current_ep = String::new(); + move |ep_name: &str, percent: f64| { + if ep_name != current_ep { + if !current_ep.is_empty() { + println!(); + } + current_ep = ep_name.to_string(); + } + print!("\r {:<30} {:5.1}%", ep_name, percent); + io::stdout().flush().ok(); + } + }) + .await?; + println!(); + // ── 2. Download and load a model ───────────────────────────────────── // let model_alias = "qwen2.5-0.5b"; diff --git a/samples/rust/native-chat-completions/src/main.rs b/samples/rust/native-chat-completions/src/main.rs index d1c7cfd1..bee7147e 100644 --- a/samples/rust/native-chat-completions/src/main.rs +++ b/samples/rust/native-chat-completions/src/main.rs @@ -24,6 +24,24 @@ async fn main() -> Result<(), Box> { let manager = FoundryLocalManager::create(FoundryLocalConfig::new("foundry_local_samples"))?; // + // Download and register all execution providers. + manager + .download_and_register_eps_with_progress(None, { + let mut current_ep = String::new(); + move |ep_name: &str, percent: f64| { + if ep_name != current_ep { + if !current_ep.is_empty() { + println!(); + } + current_ep = ep_name.to_string(); + } + print!("\r {:<30} {:5.1}%", ep_name, percent); + io::stdout().flush().ok(); + } + }) + .await?; + println!(); + // ── 2. Pick a modeland ensure it is downloaded ────────────────────── // let model = manager.catalog().get_model(ALIAS).await?; diff --git a/samples/rust/tool-calling-foundry-local/src/main.rs b/samples/rust/tool-calling-foundry-local/src/main.rs index f6ab1965..7b96333a 100644 --- a/samples/rust/tool-calling-foundry-local/src/main.rs +++ b/samples/rust/tool-calling-foundry-local/src/main.rs @@ -58,6 +58,24 @@ async fn main() -> Result<(), Box> { let manager = FoundryLocalManager::create(FoundryLocalConfig::new("foundry_local_samples"))?; // + // Download and register all execution providers. + manager + .download_and_register_eps_with_progress(None, { + let mut current_ep = String::new(); + move |ep_name: &str, percent: f64| { + if ep_name != current_ep { + if !current_ep.is_empty() { + println!(); + } + current_ep = ep_name.to_string(); + } + print!("\r {:<30} {:5.1}%", ep_name, percent); + io::stdout().flush().ok(); + } + }) + .await?; + println!(); + // ── 2. Load a model────────────────────────────────────────────────── // let model = manager.catalog().get_model(ALIAS).await?; diff --git a/samples/rust/tutorial-chat-assistant/src/main.rs b/samples/rust/tutorial-chat-assistant/src/main.rs index 34a3c6ed..ab98460c 100644 --- a/samples/rust/tutorial-chat-assistant/src/main.rs +++ b/samples/rust/tutorial-chat-assistant/src/main.rs @@ -15,6 +15,24 @@ async fn main() -> anyhow::Result<()> { // Initialize the Foundry Local SDK let manager = FoundryLocalManager::create(FoundryLocalConfig::new("chat-assistant"))?; + // Download and register all execution providers. + manager + .download_and_register_eps_with_progress(None, { + let mut current_ep = String::new(); + move |ep_name: &str, percent: f64| { + if ep_name != current_ep { + if !current_ep.is_empty() { + println!(); + } + current_ep = ep_name.to_string(); + } + print!("\r {:<30} {:5.1}%", ep_name, percent); + io::stdout().flush().ok(); + } + }) + .await?; + println!(); + // Select and load a model from the catalog let model = manager.catalog().get_model("qwen2.5-0.5b").await?; diff --git a/samples/rust/tutorial-document-summarizer/src/main.rs b/samples/rust/tutorial-document-summarizer/src/main.rs index be600056..6e6e8e4a 100644 --- a/samples/rust/tutorial-document-summarizer/src/main.rs +++ b/samples/rust/tutorial-document-summarizer/src/main.rs @@ -87,6 +87,24 @@ async fn main() -> anyhow::Result<()> { FoundryLocalConfig::new("doc-summarizer"), )?; + // Download and register all execution providers. + manager + .download_and_register_eps_with_progress(None, { + let mut current_ep = String::new(); + move |ep_name: &str, percent: f64| { + if ep_name != current_ep { + if !current_ep.is_empty() { + println!(); + } + current_ep = ep_name.to_string(); + } + print!("\r {:<30} {:5.1}%", ep_name, percent); + io::stdout().flush().ok(); + } + }) + .await?; + println!(); + // Select and load a model from the catalog let model = manager .catalog() diff --git a/samples/rust/tutorial-tool-calling/src/main.rs b/samples/rust/tutorial-tool-calling/src/main.rs index d6cfb9ce..131e4ad5 100644 --- a/samples/rust/tutorial-tool-calling/src/main.rs +++ b/samples/rust/tutorial-tool-calling/src/main.rs @@ -190,6 +190,24 @@ async fn main() -> anyhow::Result<()> { FoundryLocalConfig::new("tool-calling-app"), )?; + // Download and register all execution providers. + manager + .download_and_register_eps_with_progress(None, { + let mut current_ep = String::new(); + move |ep_name: &str, percent: f64| { + if ep_name != current_ep { + if !current_ep.is_empty() { + println!(); + } + current_ep = ep_name.to_string(); + } + print!("\r {:<30} {:5.1}%", ep_name, percent); + io::stdout().flush().ok(); + } + }) + .await?; + println!(); + // Select and load a model let model = manager .catalog() diff --git a/samples/rust/tutorial-voice-to-text/src/main.rs b/samples/rust/tutorial-voice-to-text/src/main.rs index fd802c77..d5be04c2 100644 --- a/samples/rust/tutorial-voice-to-text/src/main.rs +++ b/samples/rust/tutorial-voice-to-text/src/main.rs @@ -18,6 +18,24 @@ async fn main() -> anyhow::Result<()> { )?; // + // Download and register all execution providers. + manager + .download_and_register_eps_with_progress(None, { + let mut current_ep = String::new(); + move |ep_name: &str, percent: f64| { + if ep_name != current_ep { + if !current_ep.is_empty() { + println!(); + } + current_ep = ep_name.to_string(); + } + print!("\r {:<30} {:5.1}%", ep_name, percent); + io::stdout().flush().ok(); + } + }) + .await?; + println!(); + // // Load the speech-to-text model let speech_model = manager