feat: Maya-Adapter (Managed, gegen Attrappe), Engine-Wahl maya in Registry und CLI (M2.6b)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 08:04:09 +01:00
parent 531a4322ef
commit 07b1ad2d1f
12 changed files with 1213 additions and 12 deletions

View File

@ -3,7 +3,7 @@
use std::path::PathBuf;
use std::process::ExitCode;
use nexus_adapter::{Engine, LlamaCppEngine, OllamaEngine};
use nexus_adapter::{Engine, LlamaCppEngine, MayaEngine, OllamaEngine};
use nexus_core::Priority;
use nexus_store::{NewLlm, Rights};
@ -156,7 +156,16 @@ fn model_add(args: &[String]) -> Result<(), String> {
let flags = Flags::parse(
args,
&[
"name", "engine", "path", "tag", "gpus", "context", "vram-mb", "ram-mb", "quant",
"name",
"engine",
"path",
"tag",
"maya-config",
"gpus",
"context",
"vram-mb",
"ram-mb",
"quant",
"config",
],
&["disabled"],
@ -175,9 +184,17 @@ fn model_add(args: &[String]) -> Result<(), String> {
}
// Ollama verwaltet seine Modelle selbst; registriert wird nur der Name.
"ollama" => (PathBuf::from(flags.require("tag")?), None),
// Maya: das Modell ist die Konfigurationsdatei von Maya (JSON).
"maya" => {
let path = PathBuf::from(flags.require("maya-config")?);
if !path.is_file() {
return Err(format!("{} ist keine Datei.", path.display()));
}
(path, None)
}
other => {
return Err(format!(
"Unbekannte Engine \"{other}\" (llama.cpp oder ollama)."
"Unbekannte Engine \"{other}\" (llama.cpp, ollama oder maya)."
));
}
};
@ -274,9 +291,14 @@ async fn model_discover(args: &[String]) -> Result<(), String> {
.discover()
.await
}
"maya" => {
MayaEngine::new(crate::serve::maya_config(&config)?)
.discover()
.await
}
other => {
return Err(format!(
"Unbekannte Engine \"{other}\" (llama.cpp oder ollama)."
"Unbekannte Engine \"{other}\" (llama.cpp, ollama oder maya)."
));
}
}
@ -297,6 +319,8 @@ async fn model_discover(args: &[String]) -> Result<(), String> {
"\nRegistrieren mit: nexus model add --name <name> {} --gpus 0",
if engine == "ollama" {
"--engine ollama --tag <modellname>"
} else if engine == "maya" {
"--engine maya --maya-config <pfad> --gpus 0,1"
} else {
"--path <pfad>"
}

View File

@ -22,7 +22,8 @@ Aufruf:
nexus key list | enable --name N | disable --name N
nexus model add --name N --path PFAD [--gpus 0,1] [--context N] [--vram-mb N] [--ram-mb N] [--quant Q] [--disabled]
nexus model add --name N --engine ollama --tag MODELLNAME [--gpus 0] [--disabled]
nexus model list | enable --name N | disable --name N | discover [--engine llama.cpp|ollama]
nexus model add --name N --engine maya --maya-config PFAD.json [--gpus 0,1] [--disabled]
nexus model list | enable --name N | disable --name N | discover [--engine llama.cpp|ollama|maya]
nexus help Diese Hilfe
Die Konfiguration kommt aus --config, sonst NEXUS_CONFIG, sonst ./config.toml, sonst gelten Standardwerte.

View File

@ -5,7 +5,9 @@ use std::collections::HashMap;
use std::process::ExitCode;
use std::sync::Arc;
use nexus_adapter::{Engine, LlamaCppConfig, LlamaCppEngine, OllamaConfig, OllamaEngine};
use nexus_adapter::{
Engine, LlamaCppConfig, LlamaCppEngine, MayaConfig, MayaEngine, OllamaConfig, OllamaEngine,
};
use nexus_api::{AppState, Runtime};
use nexus_core::Config;
@ -42,6 +44,21 @@ pub fn ollama_config(config: &Config) -> Result<OllamaConfig, String> {
.map_err(|e| format!("Konfiguration [ollama]: {e}"))
}
/// Liest den Abschnitt `[maya]`; ohne eigenen `log_dir` landen die Logs im
/// Datenverzeichnis.
pub fn maya_config(config: &Config) -> Result<MayaConfig, String> {
let mut table = config.maya.clone();
if !table.contains_key("log_dir") {
table.insert(
"log_dir".to_string(),
toml::Value::String(config.data_dir.join("logs").display().to_string()),
);
}
table
.try_into::<MayaConfig>()
.map_err(|e| format!("Konfiguration [maya]: {e}"))
}
pub async fn command(args: &[String]) -> ExitCode {
match run(args).await {
Ok(()) => ExitCode::SUCCESS,
@ -67,6 +84,10 @@ async fn run(args: &[String]) -> Result<(), String> {
"ollama".to_string(),
Arc::new(OllamaEngine::new(ollama_config(&config)?)),
);
engines.insert(
"maya".to_string(),
Arc::new(MayaEngine::new(maya_config(&config)?)),
);
let state = AppState::new(store, Runtime::new(engines));
let listener = tokio::net::TcpListener::bind(&config.listen)