pub struct FakeTextModel { /* private fields */ }Expand description
An in-memory TextModel for module tests: records every Prompt
it completed and answers according to its TextModelMode.
The mode is global by default and can be overridden per tier
(FakeTextModel::set_mode_for), mirroring FakePush’s
per-recipient override — the natural analogue, and the thing the port
exists for: one test can wire the fast tier to a drafted reply and the
strong tier to a refusal, and watch a module treat the two differently
without either vendor being named.
A completion that answered NotConfigured or failed is not
recorded, the same rule FakePush applies to a send — the recording
means “the model answered”, and a caller that retried on
Transient { .. } then sees one recorded prompt per attempt it got an
answer for.
Implementations§
Source§impl FakeTextModel
impl FakeTextModel
pub fn new(mode: TextModelMode) -> Self
Sourcepub fn prompts(&self) -> Vec<Prompt>
pub fn prompts(&self) -> Vec<Prompt>
Every prompt answered so far, in order. A completion that answered
NotConfigured or failed is not recorded.
Sourcepub fn set_mode(&self, mode: TextModelMode)
pub fn set_mode(&self, mode: TextModelMode)
Switches the mode every tier without an override answers with
(e.g. flip to NotConfigured mid-test).
Sourcepub fn set_mode_for(&self, tier: ModelTier, mode: TextModelMode)
pub fn set_mode_for(&self, tier: ModelTier, mode: TextModelMode)
Makes one tier answer with mode, whatever the global mode is —
the fast tier drafting and the strong tier refusing, say.
Sourcepub fn clear_mode_for(&self, tier: ModelTier)
pub fn clear_mode_for(&self, tier: ModelTier)
Drops one tier’s override, putting it back on the global mode.
Sourcepub fn mode_for(&self, tier: ModelTier) -> TextModelMode
pub fn mode_for(&self, tier: ModelTier) -> TextModelMode
The mode tier will answer with.