Mise en place v0.6.8
Some checks failed
E2E Tests / e2e (push) Failing after 19s
Build & Push Images / build (brain) (push) Successful in 52s
Build & Push Images / build (core) (push) Successful in 1m20s
Build & Push Images / build (web) (push) Successful in 1m30s

Amélioration de l'installation automatique
Ajout de la possibilité de télécharger le llm que l'on veut à l'interieur de l'application en communicant avec ollama
This commit is contained in:
2026-04-26 01:11:04 +02:00
parent 5e04e84ee4
commit addf78f01d
12 changed files with 754 additions and 18 deletions

View File

@@ -56,11 +56,91 @@
<lucide-icon [img]="RefreshCw" [size]="14"></lucide-icon>
<span>{{ loadingModels ? 'Chargement...' : 'Actualiser' }}</span>
</button>
<button type="button" class="btn-secondary" (click)="openPullDialog()">
<lucide-icon [img]="Plus" [size]="14"></lucide-icon>
<span>Telecharger</span>
</button>
</div>
<p class="hint" *ngIf="ollamaModels.length === 0">Aucun modele detecte. Verifie que Ollama tourne et que l'URL est correcte.</p>
</div>
<!-- Liste des modeles installes avec bouton supprimer -->
<div class="form-row" *ngIf="ollamaModels.length > 0">
<label>Modeles installes</label>
<ul class="installed-models">
<li *ngFor="let m of ollamaModels">
<span class="model-name">{{ m }}</span>
<button type="button" class="btn-icon btn-danger"
(click)="deleteModel(m)"
[disabled]="deletingModel === m"
[title]="'Supprimer ' + m">
<lucide-icon [img]="Trash2" [size]="14"></lucide-icon>
</button>
</li>
</ul>
</div>
</section>
<!-- Dialog de telechargement de modele -->
<div class="modal-overlay" *ngIf="pullDialogOpen" (click)="closePullDialog()">
<div class="modal-content" (click)="$event.stopPropagation()">
<header class="modal-header">
<h3>Telecharger un modele Ollama</h3>
<button type="button" class="btn-icon" (click)="closePullDialog()" [disabled]="pullInProgress" title="Fermer">
<lucide-icon [img]="X" [size]="18"></lucide-icon>
</button>
</header>
<div class="modal-body">
<div *ngIf="!pullInProgress">
<label for="pull-name">Nom du modele</label>
<input id="pull-name" type="text" [(ngModel)]="pullModelName"
placeholder="ex: gemma4:e4b" autocomplete="off"
(keydown.enter)="startPull()">
<p class="hint">Suggestions :</p>
<div class="suggestions">
<button type="button" *ngFor="let s of pullSuggestions"
class="suggestion-chip" (click)="selectSuggestion(s)">{{ s }}</button>
</div>
<p class="hint" style="margin-top: 0.75rem;">
La liste complete est sur <a href="https://ollama.com/library" target="_blank" rel="noopener">ollama.com/library</a>.
</p>
</div>
<div *ngIf="pullInProgress" class="pull-progress">
<div class="pull-status">{{ pullStatus }}</div>
<div class="progress-bar" *ngIf="pullTotal > 0">
<div class="progress-fill" [style.width.%]="pullPercent"></div>
</div>
<div class="progress-text" *ngIf="pullTotal > 0">
{{ formatBytes(pullCompleted) }} / {{ formatBytes(pullTotal) }} ({{ pullPercent }}%)
</div>
<div class="progress-text" *ngIf="pullTotal === 0">
Preparation...
</div>
</div>
</div>
<footer class="modal-footer">
<button type="button" class="btn-secondary"
(click)="cancelPull()" *ngIf="pullInProgress">
Annuler
</button>
<button type="button" class="btn-secondary"
(click)="closePullDialog()" *ngIf="!pullInProgress">
Fermer
</button>
<button type="button" class="btn-primary"
(click)="startPull()"
[disabled]="pullInProgress || !pullModelName.trim()" *ngIf="!pullInProgress">
<lucide-icon [img]="Download" [size]="14"></lucide-icon>
<span>Telecharger</span>
</button>
</footer>
</div>
</div>
<!-- Bloc 1min.ai -->
<section class="card" *ngIf="settings && settings.llm_provider === 'onemin'">
<h2>Configuration 1min.ai</h2>

View File

@@ -5,6 +5,173 @@
color: var(--color-text, #e8e8e8);
}
// --- Liste des modeles installes -----------------------------------------
.installed-models {
list-style: none;
margin: 6px 0 0;
padding: 0;
display: flex;
flex-direction: column;
gap: 4px;
li {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px 12px;
background: rgba(255, 255, 255, 0.03);
border: 1px solid rgba(255, 255, 255, 0.06);
border-radius: 6px;
font-size: 0.9rem;
}
.model-name {
font-family: ui-monospace, SFMono-Regular, monospace;
color: #c4b8e0;
}
}
.btn-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
background: transparent;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 5px;
color: inherit;
cursor: pointer;
&:hover { background: rgba(255, 255, 255, 0.06); }
&:disabled { opacity: 0.5; cursor: not-allowed; }
}
.btn-icon.btn-danger:hover {
background: rgba(239, 68, 68, 0.12);
border-color: rgba(239, 68, 68, 0.4);
color: #fca5a5;
}
// --- Modal de pull -------------------------------------------------------
.modal-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.6);
backdrop-filter: blur(4px);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
}
.modal-content {
background: #1f1a2e;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 10px;
width: min(520px, 92vw);
max-height: 90vh;
display: flex;
flex-direction: column;
}
.modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 20px;
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
h3 {
margin: 0;
font-size: 1.05rem;
font-weight: 600;
}
}
.modal-body {
padding: 20px;
overflow-y: auto;
label {
display: block;
margin-bottom: 6px;
font-weight: 500;
font-size: 0.9rem;
}
input[type="text"] {
width: 100%;
padding: 8px 12px;
background: rgba(255, 255, 255, 0.04);
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 6px;
color: inherit;
font-family: ui-monospace, SFMono-Regular, monospace;
box-sizing: border-box;
&:focus { outline: 2px solid #b794f4; outline-offset: 0; }
}
}
.suggestions {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 4px;
}
.suggestion-chip {
padding: 4px 10px;
background: rgba(183, 148, 244, 0.1);
border: 1px solid rgba(183, 148, 244, 0.25);
border-radius: 14px;
color: #d6c5f0;
font-family: ui-monospace, SFMono-Regular, monospace;
font-size: 0.82rem;
cursor: pointer;
&:hover { background: rgba(183, 148, 244, 0.2); }
}
.modal-footer {
display: flex;
justify-content: flex-end;
gap: 8px;
padding: 14px 20px;
border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.pull-progress {
display: flex;
flex-direction: column;
gap: 10px;
padding: 12px 0;
}
.pull-status {
font-size: 0.92rem;
color: #d6c5f0;
font-family: ui-monospace, SFMono-Regular, monospace;
}
.progress-bar {
width: 100%;
height: 8px;
background: rgba(255, 255, 255, 0.06);
border-radius: 4px;
overflow: hidden;
}
.progress-fill {
height: 100%;
background: linear-gradient(90deg, #8b5cf6, #b794f4);
transition: width 0.3s ease;
}
.progress-text {
font-size: 0.82rem;
color: #aaa0c5;
font-family: ui-monospace, SFMono-Regular, monospace;
}
.page-header {
display: flex;
align-items: center;

View File

@@ -2,8 +2,9 @@ import { Component, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Router } from '@angular/router';
import { LucideAngularModule, ArrowLeft, RefreshCw, Save, Check, AlertCircle, Download } from 'lucide-angular';
import { SettingsService, AppSettings, AppSettingsUpdate, OneMinModelGroup } from '../services/settings.service';
import { LucideAngularModule, ArrowLeft, RefreshCw, Save, Check, AlertCircle, Download, Trash2, Plus, X } from 'lucide-angular';
import { SettingsService, AppSettings, AppSettingsUpdate, OneMinModelGroup, OllamaPullEvent } from '../services/settings.service';
import { Subscription } from 'rxjs';
import { UpdatesService, UpdateStatus } from '../services/updates.service';
import { ConfigService } from '../services/config.service';
@@ -33,6 +34,34 @@ export class SettingsComponent implements OnInit {
readonly Check = Check;
readonly AlertCircle = AlertCircle;
readonly Download = Download;
readonly Trash2 = Trash2;
readonly Plus = Plus;
readonly X = X;
// --- Pull / delete de modeles Ollama ---
/** Dialog d'ajout de modele ouvert/ferme. */
pullDialogOpen = false;
/** Nom saisi par l'utilisateur dans le dialog. */
pullModelName = '';
/** Suggestions courantes affichees dans le dialog. */
readonly pullSuggestions = [
'gemma4:e4b', 'gemma3:4b', 'gemma3:12b',
'llama3.2:3b', 'llama3.1:8b',
'mistral:7b', 'qwen2.5:3b', 'qwen2.5:7b'
];
/** Pull en cours ; null si aucun. */
pullInProgress = false;
/** Etape courante affichee a l'utilisateur (ex: "downloading", "verifying"). */
pullStatus = '';
/** Bytes telecharges sur le digest courant. */
pullCompleted = 0;
/** Bytes totaux du digest courant. */
pullTotal = 0;
/** Souscription au flux de pull pour pouvoir l'annuler. */
private pullSubscription: Subscription | null = null;
/** Modele en cours de suppression (nom) pour disabler son bouton. */
deletingModel: string | null = null;
// Mises a jour conteneurs
updateStatus: UpdateStatus | null = null;
@@ -229,6 +258,119 @@ export class SettingsComponent implements OnInit {
});
}
// --- Gestion des modeles Ollama (pull / delete) -------------------------
openPullDialog(): void {
this.pullDialogOpen = true;
this.pullModelName = '';
this.resetPullState();
}
closePullDialog(): void {
if (this.pullInProgress) return; // empêche fermeture pendant un pull
this.pullDialogOpen = false;
}
selectSuggestion(name: string): void {
this.pullModelName = name;
}
startPull(): void {
const name = this.pullModelName.trim();
if (!name || this.pullInProgress) return;
this.resetPullState();
this.pullInProgress = true;
this.pullStatus = 'connexion...';
this.errorMessage = '';
this.pullSubscription = this.settingsService.pullOllamaModel(name).subscribe({
next: (event: OllamaPullEvent) => {
if (event.error) {
this.errorMessage = `Echec : ${event.error}`;
this.pullInProgress = false;
return;
}
if (event.status) this.pullStatus = event.status;
if (event.completed != null) this.pullCompleted = event.completed;
if (event.total != null) this.pullTotal = event.total;
},
error: (err) => {
this.errorMessage = this.extractError(err, `Echec du telechargement de ${name}.`);
this.pullInProgress = false;
},
complete: () => {
this.pullInProgress = false;
this.successMessage = `Modele ${name} telecharge.`;
this.refreshModels();
// Si l'utilisateur n'avait aucun modele, on selectionne celui-ci.
if (this.settings && !this.settings.llm_model) {
this.settings.llm_model = name;
this.fetchOllamaModelInfo();
}
// Petite tempo avant de fermer pour que le user voie "success".
setTimeout(() => this.closePullDialog(), 1200);
}
});
}
cancelPull(): void {
if (this.pullSubscription) {
this.pullSubscription.unsubscribe();
this.pullSubscription = null;
}
this.pullInProgress = false;
this.pullStatus = 'annule';
}
private resetPullState(): void {
this.pullStatus = '';
this.pullCompleted = 0;
this.pullTotal = 0;
if (this.pullSubscription) {
this.pullSubscription.unsubscribe();
this.pullSubscription = null;
}
}
/** Pourcentage du digest courant pour la barre de progression. */
get pullPercent(): number {
if (this.pullTotal <= 0) return 0;
return Math.min(100, Math.round((this.pullCompleted / this.pullTotal) * 100));
}
/** Affichage humain des octets ('1.2 GB' / '450 MB'). */
formatBytes(b: number): string {
if (!b) return '0';
const u = ['B', 'KB', 'MB', 'GB', 'TB'];
let i = 0;
let v = b;
while (v >= 1024 && i < u.length - 1) { v /= 1024; i++; }
return `${v.toFixed(v < 10 && i > 0 ? 1 : 0)} ${u[i]}`;
}
deleteModel(name: string): void {
if (!confirm(`Supprimer le modele '${name}' ? L'espace disque sera libere.`)) return;
this.deletingModel = name;
this.errorMessage = '';
this.settingsService.deleteOllamaModel(name).subscribe({
next: () => {
this.deletingModel = null;
this.successMessage = `Modele ${name} supprime.`;
// Si l'utilisateur supprime le modele actuellement selectionne,
// on bascule sur le premier disponible (ou vide).
this.refreshModels();
if (this.settings && this.settings.llm_model === name) {
this.settings.llm_model = '';
this.ollamaModelMaxContext = 0;
}
},
error: (err) => {
this.deletingModel = null;
this.errorMessage = this.extractError(err, `Echec de la suppression de ${name}.`);
}
});
}
goBack(): void {
this.router.navigate(['/lore']);
}