Skip to main content

AppleFMBuilder

Struct AppleFMBuilder 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

pub fn with_temperature(self, temperature: f64) -> Self

Default decoding temperature. Overridden per call by ChatOptions::temperature.

Source

pub fn with_max_tokens(self, max_tokens: u32) -> Self

Default response-length cap. Overridden per call by ChatOptions::max_tokens.

Source

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).

Source

pub fn with_description(self, description: impl Into<String>) -> Self

Source

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.

Trait Implementations§

Source§

impl Debug for AppleFMBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AppleFMBuilder

Source§

fn default() -> AppleFMBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<M> MetaArg<M> for M

Source§

fn into_meta(self) -> M

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.