Skip to content

Commit 5fb40a5

Browse files
fix: add lib accessors so examples compile (#49)
The library compiles clean; the two examples `basic_usage.rs` and `mlp_router.rs` called methods that don't exist on the public API (8x E0599 for stale API names). Adds thin 1:1 accessor / convenience wrappers to the lib (preferred approach): - `Orchestrator::current_project()` — delegates to the context manager - `MLP::input_size()` / `MLP::output_size()` — getters for private fields - `MLP::train_step(input, target, lr)` — runs `backward` + `update`, returns the step loss `cargo check --examples` is now clean (0 errors). `reservoir_demo.rs` untouched. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 85f607b commit 5fb40a5

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/mlp.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,24 @@ impl MLP {
146146
// Phase 2 implementation
147147
}
148148

149+
/// Number of input features the network expects.
150+
pub fn input_size(&self) -> usize {
151+
self.input_size
152+
}
153+
154+
/// Number of output classes the network produces.
155+
pub fn output_size(&self) -> usize {
156+
self.output_size
157+
}
158+
159+
/// Run one training step: compute loss and gradients via `backward`,
160+
/// apply them with `update`, and return the loss for this step.
161+
pub fn train_step(&mut self, input: &[f32], target: &[f32], learning_rate: f32) -> f32 {
162+
let (loss, gradients) = self.backward(input, target);
163+
self.update(&gradients, learning_rate);
164+
loss
165+
}
166+
149167
/// Argmax: Return the index of the maximum value.
150168
pub fn argmax(values: &[f32]) -> usize {
151169
values

src/orchestrator.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ impl Orchestrator {
8888
self.context.switch_project(project);
8989
}
9090

91+
/// Borrow the active project name, if one is set.
92+
pub fn current_project(&self) -> Option<&str> {
93+
self.context.current_project()
94+
}
95+
9196
/// Drop the active project's conversation history.
9297
pub fn clear_history(&mut self) {
9398
self.context.clear_history();

0 commit comments

Comments
 (0)