feat: Ollama-Adapter (Managed und Attached), Engine-Wahl in der Registry (M2.6a, gegen Attrappe)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -140,6 +140,7 @@ mod tests {
|
||||
store
|
||||
.register_llm(&NewLlm {
|
||||
name: "bonsai".to_string(),
|
||||
engine: "llama.cpp".to_string(),
|
||||
path: PathBuf::from("/m/b.gguf"),
|
||||
quantization: None,
|
||||
size_bytes: None,
|
||||
|
||||
@ -9,11 +9,16 @@ use crate::{Store, db};
|
||||
|
||||
/// Name der Engine-Zeile für llama.cpp.
|
||||
pub const LLAMA_CPP: &str = "llama.cpp";
|
||||
/// Name der Engine-Zeile für Ollama.
|
||||
pub const OLLAMA: &str = "ollama";
|
||||
|
||||
/// Eingabe für `register_llm`: ein Sprachmodell mit einem Startprofil.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct NewLlm {
|
||||
pub name: String,
|
||||
/// Engine: `llama.cpp` oder `ollama`.
|
||||
pub engine: String,
|
||||
/// Pfad der Modelldatei (llama.cpp) oder Modellname der Engine (Ollama, zum Beispiel `qwen3:0.6b`).
|
||||
pub path: PathBuf,
|
||||
pub quantization: Option<String>,
|
||||
pub size_bytes: Option<i64>,
|
||||
@ -62,6 +67,12 @@ impl Store {
|
||||
if new.gpus.is_empty() {
|
||||
return Err(Error::Db("mindestens eine GPU angeben".to_string()));
|
||||
}
|
||||
if new.engine != LLAMA_CPP && new.engine != OLLAMA {
|
||||
return Err(Error::Db(format!(
|
||||
"unbekannte Engine \"{}\" (llama.cpp oder ollama)",
|
||||
new.engine
|
||||
)));
|
||||
}
|
||||
let gpus = new
|
||||
.gpus
|
||||
.iter()
|
||||
@ -71,13 +82,15 @@ impl Store {
|
||||
let tx = self.transaction().map_err(db)?;
|
||||
tx.execute(
|
||||
"INSERT OR IGNORE INTO engine (name, art, modus) VALUES (?1, ?1, 'managed')",
|
||||
[LLAMA_CPP],
|
||||
[&new.engine],
|
||||
)
|
||||
.map_err(db)?;
|
||||
let engine_id: i64 = tx
|
||||
.query_row("SELECT id FROM engine WHERE name = ?1", [LLAMA_CPP], |r| {
|
||||
r.get(0)
|
||||
})
|
||||
.query_row(
|
||||
"SELECT id FROM engine WHERE name = ?1",
|
||||
[&new.engine],
|
||||
|r| r.get(0),
|
||||
)
|
||||
.map_err(db)?;
|
||||
tx.execute(
|
||||
"INSERT INTO model (name, art, freigegeben) VALUES (?1, 'llm', ?2)",
|
||||
@ -195,6 +208,7 @@ mod tests {
|
||||
fn neu(name: &str) -> NewLlm {
|
||||
NewLlm {
|
||||
name: name.to_string(),
|
||||
engine: "llama.cpp".to_string(),
|
||||
path: PathBuf::from(format!("/srv/models/{name}.gguf")),
|
||||
quantization: Some("Q4_0".to_string()),
|
||||
size_bytes: Some(100),
|
||||
@ -277,6 +291,32 @@ mod tests {
|
||||
assert_eq!(plan.extra_args, vec!["--flash-attn".to_string()]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ollama_modell_hat_den_modellnamen_als_pfad_und_eigene_engine() {
|
||||
let mut store = Store::open_in_memory().unwrap();
|
||||
let mut n = neu("klein");
|
||||
n.engine = "ollama".to_string();
|
||||
n.path = PathBuf::from("qwen3:0.6b");
|
||||
store.register_llm(&n).unwrap();
|
||||
store.register_llm(&neu("gross")).unwrap();
|
||||
let plan = store.start_plan("klein").unwrap().unwrap();
|
||||
assert_eq!(plan.engine_name, "ollama");
|
||||
assert_eq!(plan.model_path, PathBuf::from("qwen3:0.6b"));
|
||||
assert_eq!(
|
||||
store.start_plan("gross").unwrap().unwrap().engine_name,
|
||||
"llama.cpp"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unbekannte_engine_wird_abgelehnt() {
|
||||
let mut store = Store::open_in_memory().unwrap();
|
||||
let mut n = neu("a");
|
||||
n.engine = "vllm".to_string();
|
||||
assert!(store.register_llm(&n).is_err());
|
||||
assert!(store.list_models(false).unwrap().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn profil_ohne_gpu_wird_nicht_registriert() {
|
||||
let mut store = Store::open_in_memory().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user