Skip to content

Commit d84f1bb

Browse files
hyperpolymathclaude
andcommitted
fix: add lib accessors so examples compile
basic_usage.rs and mlp_router.rs called methods that didn't exist on the public API (8x E0599). Add thin 1:1 accessor/convenience wrappers: - Orchestrator::current_project() -> delegates to context manager - MLP::input_size() / MLP::output_size() -> getters for private fields - MLP::train_step() -> backward + update, returns the step loss cargo check --examples is now clean (lib was already fine). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 85f607b commit d84f1bb

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)