Skip to main content

SessionBuilder

Struct SessionBuilder 

Source
pub struct SessionBuilder<'m, M: LanguageModel + ?Sized> { /* private fields */ }
Expand description

Builder combining instructions, custom tools, and built-in system tools.

use fm_rs::{Session, SystemLanguageModel, SystemTool};

let model = SystemLanguageModel::new()?;
let session = Session::builder(&model)
    .instructions("Describe attached images and read any text in them.")
    .system_tool(SystemTool::Ocr)
    .build()?;

Implementations§

Source§

impl<M: LanguageModel + ?Sized> SessionBuilder<'_, M>

Source

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

Sets the session instructions.

Source

pub fn tool(self, tool: Arc<dyn Tool>) -> Self

Adds a Rust-implemented tool.

Source

pub fn system_tool(self, tool: SystemTool) -> Self

Adds a built-in system tool (Foundation Models 27).

Session creation fails with crate::Error::UnsupportedPlatform on pre-27 build SDKs or runtimes.

Source

pub fn build(self) -> Result<Session>

Builds the session.

Auto Trait Implementations§

§

impl<'m, M> !RefUnwindSafe for SessionBuilder<'m, M>

§

impl<'m, M> !UnwindSafe for SessionBuilder<'m, M>

§

impl<'m, M> Freeze for SessionBuilder<'m, M>
where &'m M: Freeze, M: ?Sized,

§

impl<'m, M> Send for SessionBuilder<'m, M>
where &'m M: Send, M: ?Sized,

§

impl<'m, M> Sync for SessionBuilder<'m, M>
where &'m M: Sync, M: ?Sized,

§

impl<'m, M> Unpin for SessionBuilder<'m, M>
where &'m M: Unpin, M: ?Sized,

§

impl<'m, M> UnsafeUnpin for SessionBuilder<'m, M>
where &'m M: UnsafeUnpin, M: ?Sized,

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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.