summaryrefslogtreecommitdiff
path: root/makima/src/server/state.rs
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-05-02 15:26:39 +0100
committerGitHub <noreply@github.com>2026-05-02 15:26:39 +0100
commit70a83104292c4e1fe5f43dd5f50e5214928c8dd6 (patch)
treef423621f1cd7a06ccdeb2cf8b7a011080c49a278 /makima/src/server/state.rs
parent760516b2e7b97fa389fb3902e8d2314eea052ff0 (diff)
downloadsoryu-70a83104292c4e1fe5f43dd5f50e5214928c8dd6.tar.gz
soryu-70a83104292c4e1fe5f43dd5f50e5214928c8dd6.zip
build(server): split Dockerfiles, make ML model paths optional (#120)
Existing Dockerfile (with LLM/STT/TTS model download) is now `Dockerfile.full`. The new top-level `Dockerfile` builds a slim image without python, without huggingface_hub, without the model download step. The slim image is the new default for users who only want the orchestration surface — the directive folder UI, the mesh/task system, the API. ## Slim Dockerfile * No python / huggingface_hub / model downloads. * Same runtime tooling as `k8s/daemon/Dockerfile` (git, gh CLI, ssh, jq, curl, ca-certs, libssl3). * Embeds the daemon binary at /app/daemon-binaries/makima-linux-x86_64 for the in-server download endpoint. * PARAKEET_MODEL_DIR / SORTFORMER_MODEL_PATH / CHATTERBOX_MODEL_DIR are intentionally NOT set — Listen and Speak return "ML models not configured" if a client tries to use them. ## ML model paths now optional `ServerArgs.parakeet_model_dir`, `parakeet_eou_dir`, `sortformer_model_path`, `chatterbox_model_dir` are now `Option<String>` (no defaults). The bin constructor inspects them: if all four are present, configures `AppState::new`; if all four are absent, uses the new `AppState::new_slim()` which leaves `model_config = None`. The lazy load path in `get_ml_models` already returned a clean error for None. Speak (TTS) was already optional via `model_config.as_ref()` — still works. Mixed configurations log a warning and degrade to slim mode. ## Ops note The old `Dockerfile.full` retains the original behaviour for anyone who needs STT/diarization/TTS in production. CI still builds the daemon image from `k8s/daemon/Dockerfile` (untouched). Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'makima/src/server/state.rs')
-rw-r--r--makima/src/server/state.rs37
1 files changed, 24 insertions, 13 deletions
diff --git a/makima/src/server/state.rs b/makima/src/server/state.rs
index 6bd9e2b..e267da1 100644
--- a/makima/src/server/state.rs
+++ b/makima/src/server/state.rs
@@ -691,21 +691,37 @@ pub struct AppState {
}
impl AppState {
+ /// Create AppState WITHOUT ML model configuration. Listen and Speak
+ /// endpoints will return "not configured" errors if used; everything
+ /// else (mesh, directives, files, contracts-free CRUD) works normally.
+ /// This is the constructor used by the slim Dockerfile.
+ pub fn new_slim() -> Self {
+ Self::new_inner(None)
+ }
+
/// Create AppState with ML model configuration for lazy loading.
+ /// Pass None to disable a specific model family — Listen needs all
+ /// three of parakeet/parakeet_eou/sortformer; Speak needs chatterbox.
+ /// If `parakeet_model_dir` is None we skip the whole ModelConfig and
+ /// behave like `new_slim()`.
///
- /// Models are NOT loaded at startup - they will be loaded on first Listen connection.
- ///
- /// # Arguments
- /// * `parakeet_model_dir` - Path to the Parakeet TDT model directory
- /// * `parakeet_eou_dir` - Path to the Parakeet EOU model directory
- /// * `sortformer_model_path` - Path to the Sortformer diarization model file
- /// * `chatterbox_model_dir` - Path to the Chatterbox TTS model directory
+ /// Models are NOT loaded at startup — they're loaded on first use.
pub fn new(
parakeet_model_dir: &str,
parakeet_eou_dir: &str,
sortformer_model_path: &str,
chatterbox_model_dir: &str,
) -> Self {
+ Self::new_inner(Some(ModelConfig {
+ parakeet_model_dir: parakeet_model_dir.to_string(),
+ parakeet_eou_dir: parakeet_eou_dir.to_string(),
+ sortformer_model_path: sortformer_model_path.to_string(),
+ chatterbox_model_dir: chatterbox_model_dir.to_string(),
+ }))
+ }
+
+ /// Internal constructor — model_config can be None for the slim build.
+ fn new_inner(model_config: Option<ModelConfig>) -> Self {
// Create broadcast channels with buffer for 256 messages
let (file_updates, _) = broadcast::channel(256);
let (task_updates, _) = broadcast::channel(256);
@@ -744,12 +760,7 @@ impl AppState {
};
Self {
- model_config: Some(ModelConfig {
- parakeet_model_dir: parakeet_model_dir.to_string(),
- parakeet_eou_dir: parakeet_eou_dir.to_string(),
- sortformer_model_path: sortformer_model_path.to_string(),
- chatterbox_model_dir: chatterbox_model_dir.to_string(),
- }),
+ model_config,
ml_models: OnceCell::new(),
db_pool: None,
file_updates,