| File: LocalModelHealthCheck.cs | Web Access |
| Project: src\src\Aspire.Hosting.Foundry\Aspire.Hosting.Foundry.csproj (Aspire.Hosting.Foundry) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Diagnostics.HealthChecks; namespace Aspire.Hosting.Foundry; internal sealed class LocalModelHealthCheck(string? modelId) : IHealthCheck { public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(modelId)) { return HealthCheckResult.Unhealthy("Model has not been loaded."); } if (!await FoundryLocalService.IsModelLoadedAsync(modelId, cancellationToken).ConfigureAwait(false)) { return HealthCheckResult.Unhealthy("Model has not been loaded."); } return HealthCheckResult.Healthy(); } }