- MistralRsHarness: Harness trait impl wrapping mistral.rs HTTP API (list/load/unload models, health check, start/stop via systemd) - HarnessRegistry: maps harness name -> Box<dyn Harness>, built from neuron.toml config - Neuron API endpoints: GET /models, POST /models/load, POST /models/unload, GET /models/:id/endpoint - NeuronConfig: figment-based config loading from neuron.toml - Integration test: full model lifecycle through mock mistral.rs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
41 lines
879 B
Rust
41 lines
879 B
Rust
//! Neuron configuration loaded from neuron.toml.
|
|
|
|
use cortex_core::harness::HarnessConfig;
|
|
use figment::{
|
|
Figment,
|
|
providers::{Env, Format, Toml},
|
|
};
|
|
use serde::{Deserialize, Serialize};
|
|
use std::path::Path;
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct NeuronConfig {
|
|
#[serde(default = "default_port")]
|
|
pub port: u16,
|
|
#[serde(default)]
|
|
pub harnesses: Vec<HarnessConfig>,
|
|
}
|
|
|
|
fn default_port() -> u16 {
|
|
9090
|
|
}
|
|
|
|
impl NeuronConfig {
|
|
pub fn load(path: impl AsRef<Path>) -> Result<Self, Box<figment::Error>> {
|
|
Figment::new()
|
|
.merge(Toml::file(path))
|
|
.merge(Env::prefixed("NEURON_").split("__"))
|
|
.extract()
|
|
.map_err(Box::new)
|
|
}
|
|
}
|
|
|
|
impl Default for NeuronConfig {
|
|
fn default() -> Self {
|
|
Self {
|
|
port: 9090,
|
|
harnesses: vec![],
|
|
}
|
|
}
|
|
}
|