feat(model-server): wizard V2 config modèles locaux — source, options structurées & preview
Refonte UX du wizard de configuration des modèles locaux du serveur llama.cpp intégré, alignée sur la source Hugging Face et les options backend. - choix de source sans jargon (chemin local .gguf vs dépôt Hugging Face) ; - champs structurés -ngl (gpu_layers), -c (context_size), --jinja, --host ; - zone d'arguments libres avec alerte sur les flags réservés ; - preview de la commande via le backend (previewModelServerCommand, debounced) ; - gateway/ports et mock adaptés au contrat V2. QA : Vitest 22 verts, tsc/build OK. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -24,6 +24,7 @@ import type {
|
||||
LayoutOperation,
|
||||
LayoutTree,
|
||||
LocalModelServerConfig,
|
||||
ModelServerCommandPreview,
|
||||
Memory,
|
||||
MemoryIndexEntry,
|
||||
MemoryLink,
|
||||
@ -1284,6 +1285,44 @@ export class MockModelServerGateway implements ModelServerGateway {
|
||||
this.servers = this.servers.filter((s) => s.id !== serverId);
|
||||
}
|
||||
|
||||
async previewModelServerCommand(
|
||||
config: LocalModelServerConfig,
|
||||
): Promise<ModelServerCommandPreview> {
|
||||
// Mirror of the backend `LlamaCppRuntime::build_argv` (order matters), kept
|
||||
// deliberately simple: it exists so the UI preview flow is testable, never
|
||||
// as the source of truth (production uses the real backend command).
|
||||
if (!config.modelSource) {
|
||||
const err: GatewayError = {
|
||||
code: "INVALID",
|
||||
message: "model.source missing",
|
||||
};
|
||||
throw err;
|
||||
}
|
||||
const command =
|
||||
config.binaryPath && config.binaryPath.trim().length > 0
|
||||
? config.binaryPath
|
||||
: "llama-server";
|
||||
const args: string[] = [];
|
||||
if (config.modelSource.type === "localPath") {
|
||||
args.push("--model", config.modelSource.path);
|
||||
} else {
|
||||
args.push("-hf", config.modelSource.repo);
|
||||
}
|
||||
args.push("--port", String(config.port), "--host", config.host);
|
||||
if (config.gpuLayers !== undefined) {
|
||||
args.push("-ngl", String(config.gpuLayers));
|
||||
}
|
||||
if (config.contextSize !== undefined) {
|
||||
args.push("-c", String(config.contextSize));
|
||||
}
|
||||
if (config.jinja) args.push("--jinja");
|
||||
args.push(...config.args);
|
||||
const display = [command, ...args]
|
||||
.map((part) => (/\s/.test(part) ? `'${part}'` : part))
|
||||
.join(" ");
|
||||
return { command, args, display };
|
||||
}
|
||||
|
||||
/** Test hook: mark a server id as still referenced (delete then rejects). */
|
||||
markInUse(serverId: string): void {
|
||||
this.inUse.add(serverId);
|
||||
|
||||
@ -9,7 +9,10 @@
|
||||
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
import type { LocalModelServerConfig } from "@/domain";
|
||||
import type {
|
||||
LocalModelServerConfig,
|
||||
ModelServerCommandPreview,
|
||||
} from "@/domain";
|
||||
import type { ModelServerGateway } from "@/ports";
|
||||
|
||||
export class TauriModelServerGateway implements ModelServerGateway {
|
||||
@ -28,4 +31,14 @@ export class TauriModelServerGateway implements ModelServerGateway {
|
||||
async deleteModelServer(serverId: string): Promise<void> {
|
||||
await invoke("delete_model_server", { serverId });
|
||||
}
|
||||
|
||||
previewModelServerCommand(
|
||||
config: LocalModelServerConfig,
|
||||
): Promise<ModelServerCommandPreview> {
|
||||
// `preview_model_server_command` takes the config directly (no `request`
|
||||
// wrapper), unlike `save_model_server`.
|
||||
return invoke<ModelServerCommandPreview>("preview_model_server_command", {
|
||||
config,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user