Files
nexus/backend/Integrations/OllamaProvider.cs
T
bao eeb6174de0 Initial commit: Nexus Mission Control Platform
- ASP.NET Core 10 Backend (JWT Auth, Agent config API)
- Vue 3 Frontend (Dashboard, Team, Agents, Config Editor)
- PostgreSQL Database
- Docker Compose setup
- Mission Control Dashboard redesign
2026-06-09 16:31:56 +02:00

38 lines
1.1 KiB
C#

using System.Net.Http.Json;
using Nexus.Api.Domain;
namespace Nexus.Api.Integrations;
public sealed class OllamaProvider(HttpClient client) : IModelProvider
{
private sealed record OllamaTag(string Name);
private sealed record OllamaTags(IReadOnlyCollection<OllamaTag>? Models);
public string Name => "Ollama";
public async Task<IReadOnlyCollection<ModelProviderStatus>> GetModelsAsync(
CancellationToken cancellationToken)
{
try
{
var response = await client.GetFromJsonAsync<OllamaTags>("/api/tags", cancellationToken);
return response?.Models?
.Select(model => new ModelProviderStatus(
Name,
model.Name,
OperationalStatus.Online,
true,
"Local"))
.ToArray() ?? [];
}
catch (Exception exception)
{
return
[
new(Name, "qwen3:4b", OperationalStatus.Offline, true, exception.Message)
];
}
}
}