feat: Oberfläche neu, Modell-Adapter wählbar, Bewertung je Bereich
Die erste Fassung der Oberfläche war inhaltlich und optisch schwach. Neu: drei Reiter (Benchmark, Ergebnisse, Einstellungen). Modelle werden in den Einstellungen mit Adapter (Ollama oder OpenAI-kompatibel), URL, Modell-ID und Schlüssel-Variable angelegt, mit Verbindungstest. config.toml speichert die Liste. Bewertung absolut in Prozent: ein Wert je Bereich A bis D und eine Gesamtnote, gewichtet nach weight. Batch-Verlauf, Schritt-Ansicht, Erklärung der Bewertung. 55 Unit-Tests grün, svelte-check ohne Fehler. Im Browser mit Beispieldaten geprüft, nicht in der echten App. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -29,15 +29,25 @@ pub struct Job {
|
||||
pub repeat_idx: u32,
|
||||
}
|
||||
|
||||
/// Verbindung zu einem Modell, aufgelöst aus der Konfiguration.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct ModelConn {
|
||||
/// Anzeigename, wie er in Läufen und Ranglisten steht.
|
||||
pub name: String,
|
||||
/// `ollama` oder `openai`.
|
||||
pub adapter: String,
|
||||
pub url: String,
|
||||
/// Modell-ID, die der Server erwartet.
|
||||
pub model_id: String,
|
||||
/// Schlüssel, wird nicht gespeichert.
|
||||
pub api_key: Option<String>,
|
||||
}
|
||||
|
||||
/// Einstellungen für einen Batch.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RunConfig {
|
||||
pub runtime: String,
|
||||
/// `ollama` oder `openai`.
|
||||
pub backend: String,
|
||||
pub endpoint_url: String,
|
||||
/// Schlüssel für den OpenAI-Endpunkt, wird nicht gespeichert.
|
||||
pub api_key: Option<String>,
|
||||
pub models: Vec<ModelConn>,
|
||||
pub data_dir: PathBuf,
|
||||
pub limits: Limits,
|
||||
}
|
||||
@ -123,8 +133,9 @@ pub fn run_batch(
|
||||
) -> Result<BatchSummary, String> {
|
||||
let config_json = json!({
|
||||
"runtime": cfg.runtime,
|
||||
"backend": cfg.backend,
|
||||
"endpoint": cfg.endpoint_url,
|
||||
"models": cfg.models.iter().map(|m| json!({
|
||||
"name": m.name, "adapter": m.adapter, "url": m.url, "model_id": m.model_id
|
||||
})).collect::<Vec<_>>(),
|
||||
"limits": { "memory": cfg.limits.memory, "cpus": cfg.limits.cpus },
|
||||
"system_prompt": crate::agent::SYSTEM_PROMPT,
|
||||
"tool_output_chars": crate::agent::MAX_TOOL_OUTPUT_CHARS,
|
||||
@ -255,12 +266,22 @@ enum JobResult {
|
||||
Cancelled,
|
||||
}
|
||||
|
||||
/// Baut den Modell-Client für das gewählte Backend.
|
||||
pub fn make_client(cfg: &RunConfig, model: &str) -> Result<Box<dyn ModelClient>, String> {
|
||||
match cfg.backend.as_str() {
|
||||
"ollama" => Ok(Box::new(OllamaClient::new(&cfg.endpoint_url, model)?)),
|
||||
"openai" => Ok(Box::new(OpenAiClient::new(&cfg.endpoint_url, model, cfg.api_key.clone())?)),
|
||||
other => Err(format!("Unbekanntes Backend: {other} (erlaubt: ollama, openai)")),
|
||||
/// Baut den Modell-Client für den Adapter des Modells.
|
||||
pub fn make_client(cfg: &RunConfig, name: &str) -> Result<Box<dyn ModelClient>, String> {
|
||||
let conn = cfg
|
||||
.models
|
||||
.iter()
|
||||
.find(|m| m.name == name)
|
||||
.ok_or_else(|| format!("Modell {name:?} ist nicht angebunden."))?;
|
||||
client_for(conn)
|
||||
}
|
||||
|
||||
/// Baut den Client für eine Verbindung, je nach Adapter.
|
||||
pub fn client_for(conn: &ModelConn) -> Result<Box<dyn ModelClient>, String> {
|
||||
match conn.adapter.as_str() {
|
||||
"ollama" => Ok(Box::new(OllamaClient::new(&conn.url, &conn.model_id)?)),
|
||||
"openai" => Ok(Box::new(OpenAiClient::new(&conn.url, &conn.model_id, conn.api_key.clone())?)),
|
||||
other => Err(format!("Unbekannter Adapter: {other} (erlaubt: ollama, openai)")),
|
||||
}
|
||||
}
|
||||
|
||||
@ -456,9 +477,13 @@ mod tests {
|
||||
let jobs = plan(&[model.clone()], &tasks, 2);
|
||||
let cfg = RunConfig {
|
||||
runtime: "podman".into(),
|
||||
backend: "ollama".into(),
|
||||
endpoint_url: url,
|
||||
api_key: None,
|
||||
models: vec![ModelConn {
|
||||
name: model.clone(),
|
||||
adapter: "ollama".into(),
|
||||
url,
|
||||
model_id: model.clone(),
|
||||
api_key: None,
|
||||
}],
|
||||
data_dir: base.join("data"),
|
||||
limits: Limits::default(),
|
||||
};
|
||||
@ -507,9 +532,13 @@ mod tests {
|
||||
let jobs = plan(&[model.clone()], &tasks, 1);
|
||||
let cfg = RunConfig {
|
||||
runtime: "podman".into(),
|
||||
backend,
|
||||
endpoint_url: url,
|
||||
api_key,
|
||||
models: vec![ModelConn {
|
||||
name: model.clone(),
|
||||
adapter: backend,
|
||||
url,
|
||||
model_id: model.clone(),
|
||||
api_key,
|
||||
}],
|
||||
data_dir: data.clone(),
|
||||
limits: Limits::default(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user