pub struct SimLLM { /* private fields */ }Expand description
Simulated LLM for deterministic testing.
TigerStyle:
- Deterministic responses via seeded RNG
- Prompt routing to domain-specific generators
- Fault injection integration
- Thread-safe via
Mutexfor use in async contexts
§Example
use umi_memory::dst::{SimLLM, SimClock, DeterministicRng, FaultInjector};
use std::sync::Arc;
let clock = SimClock::new();
let rng = DeterministicRng::new(42);
let faults = Arc::new(FaultInjector::new(DeterministicRng::new(42)));
let llm = SimLLM::new(clock, rng, faults);
// Same seed = same responseImplementations§
Source§impl SimLLM
impl SimLLM
Sourcepub fn new(
clock: SimClock,
rng: DeterministicRng,
fault_injector: Arc<FaultInjector>,
) -> Self
pub fn new( clock: SimClock, rng: DeterministicRng, fault_injector: Arc<FaultInjector>, ) -> Self
Create a new SimLLM.
§Arguments
clock: Simulated clock for latencyrng: Deterministic RNG for response generationfault_injector: Shared fault injector
Sourcepub fn without_latency(self) -> Self
pub fn without_latency(self) -> Self
Disable latency simulation (useful for tests without time advancement).
By default, SimLLM simulates latency using the clock. This blocks if the clock isn’t being advanced. Use this method to disable latency for simple tests.
Sourcepub fn with_latency(self, latency_ms: u64) -> Self
pub fn with_latency(self, latency_ms: u64) -> Self
Sourcepub async fn complete_json<T: DeserializeOwned>(
&self,
prompt: &str,
) -> Result<T, LLMError>
pub async fn complete_json<T: DeserializeOwned>( &self, prompt: &str, ) -> Result<T, LLMError>
Complete a prompt expecting a JSON response.
§Errors
Returns LLMError on fault injection, validation, or JSON parse failure.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SimLLM
impl RefUnwindSafe for SimLLM
impl Send for SimLLM
impl Sync for SimLLM
impl Unpin for SimLLM
impl UnwindSafe for SimLLM
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more