pub struct AppleFMBuilder { /* private fields */ }Expand description
Builder for AppleFMClient.
A pure connection stub: it wires up which model variant to talk to
(base, or base + LoRA) and nothing else. Unlike other providers there
is no with_model typestate — the model is the one the OS ships.
Conversation concerns (system prompts, options) belong to the chat:
push a System-role message into Messages and the provider maps it
onto the session’s instructions.
use chat_applefm::AppleFMBuilder;
let client = AppleFMBuilder::new()
.with_lora("adapters/transcripts.fmadapter")
.build()?;Implementations§
Source§impl AppleFMBuilder
impl AppleFMBuilder
pub fn new() -> Self
Sourcepub fn with_lora(self, path: impl Into<PathBuf>) -> Self
pub fn with_lora(self, path: impl Into<PathBuf>) -> Self
Apply a LoRA fine-tune over the on-device base model: the path to a
.fmadapter package produced by Apple’s adapter training toolkit.
Adapters are tied to a specific base-model version — when a macOS update rolls the base model, the adapter must be retrained. Loading an incompatible adapter fails at request time with a provider error.
Sourcepub fn with_temperature(self, temperature: f64) -> Self
pub fn with_temperature(self, temperature: f64) -> Self
Default decoding temperature. Overridden per call by
ChatOptions::temperature.
Sourcepub fn with_max_tokens(self, max_tokens: u32) -> Self
pub fn with_max_tokens(self, max_tokens: u32) -> Self
Default response-length cap. Overridden per call by
ChatOptions::max_tokens.
Sourcepub fn with_sampling(self, sampling: Sampling) -> Self
pub fn with_sampling(self, sampling: Sampling) -> Self
Default sampling mode — greedy, top-k, or top-p (the complete set
FoundationModels exposes). Overridden per call when ChatOptions
carries any sampling key (top_p, or greedy / top_k / seed
in its metadata).
pub fn with_description(self, description: impl Into<String>) -> Self
Sourcepub fn build(self) -> Result<AppleFMClient, ChatFailure>
pub fn build(self) -> Result<AppleFMClient, ChatFailure>
Build the client, validating the configuration upfront — a missing
.fmadapter path or nonsensical sampling parameters fail here, not
on the first request. Cheap otherwise: the model is probed and the
session created at request time. Call crate::availability
first to know whether requests can succeed on this machine at all.