a79d8282dc
- 15 Controller-Klassen ersetzen Minimal APIs in Program.cs - Repository Pattern mit Interfaces + Implementierungen (Project, Task, Activity, User) - AuthService verwendet jetzt IUserRepository statt direktem DbContext-Zugriff - SecurityHeadersMiddleware als eigenständige Middleware-Klasse - PathSecurityHelper als gemeinsamer Helper für Pfadvalidierung - DTOs in eigenem Namespace Nexus.Api.DTOs - EF-Entities in Nexus.Api.Data (vorher Nexus.Api.Domain) - Program.cs auf DI-Registrierung + Middleware reduziert - Alle 43 Endpoints unverändert erhalten - Build + 3/3 Tests erfolgreich
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System.Net.Http.Json;
|
|
using Nexus.Api.Data;
|
|
|
|
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)
|
|
];
|
|
}
|
|
}
|
|
}
|