Files
IdeA/frontend/src/adapters/modelServer.ts
Blomios efa081b074 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>
2026-07-12 14:32:04 +02:00

45 lines
1.4 KiB
TypeScript

/**
* Tauri adapter for {@link ModelServerGateway} (F35). One of the only places that
* calls `invoke()`; features reach it exclusively through the port.
*
* Commands and payload keys are camelCase, matching the backend DTO convention.
* The flat `LocalModelServerConfig` wire shape is the DTO frozen by Architect —
* no nesting.
*/
import { invoke } from "@tauri-apps/api/core";
import type {
LocalModelServerConfig,
ModelServerCommandPreview,
} from "@/domain";
import type { ModelServerGateway } from "@/ports";
export class TauriModelServerGateway implements ModelServerGateway {
listModelServers(): Promise<LocalModelServerConfig[]> {
return invoke<LocalModelServerConfig[]>("list_model_servers");
}
saveModelServer(
config: LocalModelServerConfig,
): Promise<LocalModelServerConfig> {
return invoke<LocalModelServerConfig>("save_model_server", {
request: { config },
});
}
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,
});
}
}