@@ -39,7 +39,7 @@ public interface IModelContext
3939 /// </summary>
4040 /// <param name="modelId">The id of the model to check for existence.</param>
4141 /// <returns>A boolean value indicating whether the model file exists locally.</returns>
42- bool Exists ( string modelId ) ;
42+ bool IsDownloaded ( string modelId ) ;
4343
4444 /// <summary>
4545 /// Asynchronously downloads a known model from its configured download URL. This method handles the complete download process
@@ -52,33 +52,27 @@ public interface IModelContext
5252 Task < IModelContext > DownloadAsync ( string modelId , CancellationToken cancellationToken = default ) ;
5353
5454 /// <summary>
55- /// Asynchronously downloads a custom model from a specified URL. This method allows downloading models that are not part
56- /// of the known models collection, adding them to the system after download.
55+ /// Ensures a known local model is downloaded before use. If the model is already present on disk the call
56+ /// returns immediately; if not, the model is downloaded. Cloud models are silently skipped.
57+ /// Thread-safe: concurrent calls for the same model will not trigger duplicate downloads.
5758 /// </summary>
58- /// <param name="model">The name to assign to the downloaded model.</param>
59- /// <param name="url">The URL from which to download the model.</param>
60- /// <returns>A task that represents the asynchronous download operation that completes when the download finishes,
61- /// returning the context instance implementing <see cref="IModelContext"/> for method chaining.</returns>
62- Task < IModelContext > DownloadAsync ( string model , string url , CancellationToken cancellationToken = default ) ;
63-
64- /// <summary>
65- /// Synchronously downloads a known model from its configured download URL. This is the blocking version of the download operation
66- /// with progress tracking.
67- /// </summary>
68- /// <param name="modelName">The name of the model to download.</param>
69- /// <returns>The context instance implementing <see cref="IModelContext"/> for method chaining.</returns>
70- [ Obsolete ( "Use DownloadAsync instead" ) ]
71- IModelContext Download ( string modelName ) ;
59+ /// <param name="modelId">The id of the model to ensure is downloaded.</param>
60+ /// <param name="cancellationToken">Optional cancellation token to abort the download operation.</param>
61+ /// <returns>A task that represents the asynchronous operation, returning the context instance implementing
62+ /// <see cref="IModelContext"/> for method chaining.</returns>
63+ Task < IModelContext > EnsureDownloadedAsync ( string modelId , CancellationToken cancellationToken = default ) ;
7264
7365 /// <summary>
74- /// Synchronously downloads a custom model from a specified URL. This method provides blocking download functionality
75- /// for custom models not in the known models collection.
66+ /// Ensures a known local model is downloaded before use using a strongly-typed model reference.
67+ /// If the model is already present on disk the call returns immediately; if not, the model is downloaded.
68+ /// Cloud models are silently skipped.
69+ /// Thread-safe: concurrent calls for the same model will not trigger duplicate downloads.
7670 /// </summary>
77- /// <param name="model">The name to assign to the downloaded model .</param >
78- /// <param name="url">The URL from which to download the model .</param>
79- /// <returns>The context instance implementing <see cref="IModelContext"/> for method chaining.</returns>
80- [ Obsolete ( "Use DownloadAsync instead" ) ]
81- IModelContext Download ( string model , string url ) ;
71+ /// <typeparam name="TModel">A <see cref="LocalModel"/> type with a parameterless constructor .</typeparam >
72+ /// <param name="cancellationToken">Optional cancellation token to abort the download operation .</param>
73+ /// <returns>A task that represents the asynchronous operation, returning the context instance implementing
74+ /// <see cref="IModelContext"/> for method chaining.</returns>
75+ Task < IModelContext > EnsureDownloadedAsync < TModel > ( CancellationToken cancellationToken = default ) where TModel : LocalModel , new ( ) ;
8276
8377 /// <summary>
8478 /// Loads a model into the memory cache for faster access during inference operations. This method preloads the model to avoid loading
0 commit comments