Auto-réglage GPU : détection, num_ctx optimal et bouton Réglage auto

Backend :
- agent_config : num_ctx dans la config, envoyé à Ollama (0 = défaut modèle)
- ollama_client : méthode ps() (placement GPU/CPU via /api/ps)
- autotune : placement() lit size vs size_vram pour savoir si le modèle est sur GPU
- routes/config : POST /api/config/auto (détecte GPU + modèle, calcule et applique
  num_ctx/max_tokens, renvoie la détection et le placement)

Frontend :
- client/store : autoTune(), état tuning + résultat
- SettingsView : bouton ⚡ Réglage auto, bannière de détection (GPU/VRAM,
  contexte, placement GPU/CPU), slider Contexte (num_ctx)

Config :
- GPU_VRAM_MB / GPU_NAME pour déclarer la VRAM si Ollama est distant

Tests : recommandation (8B sur 12 Go -> ctx 32768), route /auto + persistance,
transmission num_ctx aux options Ollama, placement via /api/ps.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SVay7z3y7q2gEe54ByAE6N
This commit is contained in:
Claude committed 2026-06-30 05:54:30 +00:00
1 parent 98d7bb03fd
commit cbe9bcd514
10 files changed
+231 -5

No files matched your search

+21
View File
@@ -1,5 +1,6 @@
import { create } from "zustand";
import {
autoTune,
createSession,
deleteSession,
getConfig,
@@ -13,6 +14,7 @@ import {
saveConfig,
streamChat,
type AgentConfig,
type AutoTuneResult,
type FileNode,
type Message,
type OllamaModel,
@@ -43,6 +45,10 @@ interface LokiState {
refreshConfig: () => Promise<void>;
updateConfig: (patch: Partial<AgentConfig>) => Promise<void>;
tuning: boolean;
tuneResult: AutoTuneResult | null;
runAutoTune: () => Promise<void>;
pendingShell: string | null; // commande shell en attente de validation
approveShell: () => Promise<void>;
rejectShell: () => Promise<void>;
@@ -114,6 +120,21 @@ export const useStore = create<LokiState>((set, get) => ({
set({ config });
},
tuning: false,
tuneResult: null,
runAutoTune: async () => {
const model = get().selectedModel;
if (!model || get().tuning) return;
set({ tuning: true });
try {
const result = await autoTune(model, true);
set({ tuneResult: result, config: result.config });
} finally {
set({ tuning: false });
}
},
openPreview: async (path) => {
const content = await fileContent(path);
set({ previewPath: path, previewContent: content });