scripts/dev/split_module.py (lexer-based, with 16 self-tests) moves the top-level fn and impl items of 59 oversize module files in control-plane, desktop-core, model-format, gateway-text, leleka-memory, experimental-ref, context, serving-policy, tokenizer, backend-api, quant-core, harmony, igpu, libc-shim, npu-service and runtime-client into foo/<name>.rs groups of about 250 lines; types, constants, macros, nested modules and tests stay, every path stays valid through pub use re-exports, restricted visibilities keep their scope one level down, include paths and super:: paths are shifted. Not touched: leleka-runtime, cuda-driver, native-cpu-expert, sampler-ref and cpu-* (hot path, next wave) and the files kar-off-ab edits. The baseline drops from 311 to 263 oversize files and from 273,600 to about 233,000 lines; the path-include ratchet ignores dir/name.rs child declarations.
47 lines
1.4 KiB
Rust
47 lines
1.4 KiB
Rust
//! The operational HTTP surface of the Original's Python server (`engine/strata/serve/server.py`)
|
|
//! that is not an inference API: `GET /props`, `GET /slots`, `GET /v1/status`, `GET /api/health`,
|
|
//! `GET|POST /settings`, `POST /load`, `POST /unload`, `POST /v1/load`, `POST /v1/unload`, CORS and
|
|
//! the own-page guard. Behaviour is checked against the real Python handlers in
|
|
//! `tests/http_surface.rs` (fixtures from `tests/golden/gen_goldens.py http`).
|
|
//!
|
|
//! One engine at a time: `total_slots` is 1 and `/slots` lists one slot while the engine is loaded.
|
|
|
|
use std::{
|
|
sync::Arc,
|
|
time::{Duration, SystemTime, UNIX_EPOCH},
|
|
};
|
|
|
|
use axum::{
|
|
Json,
|
|
body::Bytes,
|
|
extract::{RawQuery, Request, State},
|
|
http::{HeaderMap, HeaderName, HeaderValue, Method, StatusCode, header},
|
|
middleware::Next,
|
|
response::{IntoResponse, Response},
|
|
};
|
|
use leleka_serving_policy::{
|
|
cors::{Cors, own_page},
|
|
idle::Outcome,
|
|
};
|
|
use serde_json::{Value, json};
|
|
use tokio::sync::{mpsc, oneshot};
|
|
|
|
use crate::{
|
|
app::AppState,
|
|
worker::{Control, LoadError, WorkerState, WorkerStatus},
|
|
};
|
|
|
|
/// The chat template the Original serves in `/props` when the model ships none.
|
|
pub const DEFAULT_CHAT_TEMPLATE: &str =
|
|
include_str!("../../engine/strata/serve/chat_template.jinja");
|
|
|
|
mod error_body;
|
|
#[allow(unused_imports)]
|
|
pub use error_body::*;
|
|
mod slots;
|
|
#[allow(unused_imports)]
|
|
pub use slots::*;
|
|
mod model_busy;
|
|
#[allow(unused_imports)]
|
|
pub use model_busy::*;
|