Skip to main content

SessionConfig

Struct SessionConfig 

Source
pub struct SessionConfig { /* private fields */ }
Expand description

Defaults applied to one provider-native interactive session.

Configuration is passive. Select the exact model first and call crate::ModelBackend::open_session only when native sessions are supported.

§Examples

use providers_kit::session::SessionConfig;
let config = SessionConfig::default().with_instructions("Answer briefly")?;
assert_eq!(config.instructions(), Some("Answer briefly"));

Implementations§

Source§

impl SessionConfig

Source

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

Sets nonblank text instructions for the session.

§Errors

Returns an input error for empty or whitespace-only instructions.

See crate::session::SessionConfig for a complete example.

Source

pub fn with_input_audio( self, media_type: impl Into<String>, transcription: bool, ) -> Result<Self, KitError>

Enables audio input with an exact IANA media type.

§Errors

Returns an input error unless the value is an unpadded valid IANA audio media type without control characters. Exact format/model support is checked on session opening.

§Examples
use providers_kit::session::SessionConfig;
let config = SessionConfig::default().with_input_audio("audio/pcm", true)?;
assert_eq!(config.input_audio_format(), Some("audio/pcm"));
assert!(config.input_transcription());
Source

pub fn with_output_audio( self, media_type: impl Into<String>, transcription: bool, ) -> Result<Self, KitError>

Enables audio output with an exact IANA media type.

§Errors

Returns an input error unless the value is an unpadded valid IANA audio media type without control characters. Exact format/model support is checked on session opening.

§Examples
use providers_kit::session::SessionConfig;
let config = SessionConfig::default().with_output_audio("audio/pcm", true)?;
assert_eq!(config.output_audio_format(), Some("audio/pcm"));
assert!(config.output_transcription());
Source

pub const fn with_turn_detection( self, turn_detection: SessionTurnDetection, ) -> Self

Selects provider-managed or caller-managed turn boundaries.

§Examples
use providers_kit::session::{SessionConfig, SessionTurnDetection};
let config = SessionConfig::default().with_turn_detection(SessionTurnDetection::Manual);
assert_eq!(config.turn_detection(), SessionTurnDetection::Manual);
Source

pub fn with_functions( self, functions: Vec<ProviderFunctionTool>, tool_choice: Option<ToolChoice>, ) -> Result<Self, KitError>

Sets the client functions available throughout the session.

§Errors

Returns an input error for duplicate functions, required tool choice with an empty inventory, or a selection that cannot be resolved against the supplied functions.

§Examples
use providers_kit::generation::{ProviderFunctionTool, JsonSchema};
let tool = ProviderFunctionTool::new(
    "lookup",
    Some("Find a record".into()),
    JsonSchema::new(serde_json::json!({"type":"object"}))?,
)?;
use providers_kit::{session::SessionConfig, generation::ToolChoice};
let config = SessionConfig::default().with_functions(vec![tool], Some(ToolChoice::Auto))?;
assert_eq!(config.functions()[0].name(), "lookup");
assert_eq!(config.tool_choice(), Some(&ToolChoice::Auto));
Source

pub fn instructions(&self) -> Option<&str>

Returns the session instructions, when configured.

See crate::session::SessionConfig for a complete example.

Source

pub fn input_audio_format(&self) -> Option<&str>

Returns the required input-audio media type, when enabled.

See crate::session::SessionConfig::with_input_audio for a complete example.

Source

pub fn output_audio_format(&self) -> Option<&str>

Returns the requested output-audio media type, when enabled.

See crate::session::SessionConfig::with_output_audio for a complete example.

Source

pub fn input_transcription(&self) -> bool

Reports whether input transcription was requested.

See crate::session::SessionConfig::with_input_audio for a complete example.

Source

pub fn output_transcription(&self) -> bool

Reports whether output transcription was requested.

See crate::session::SessionConfig::with_output_audio for a complete example.

Source

pub const fn turn_detection(&self) -> SessionTurnDetection

Returns the configured turn-boundary policy.

See crate::session::SessionConfig::with_turn_detection for a complete example.

Source

pub fn functions(&self) -> &[ProviderFunctionTool]

Returns the client functions available to the session.

See crate::session::SessionConfig::with_functions for a complete example.

Source

pub const fn tool_choice(&self) -> Option<&ToolChoice>

Returns the configured function-selection policy.

See crate::session::SessionConfig::with_functions for a complete example.

Trait Implementations§

Source§

impl Clone for SessionConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SessionConfig

Source§

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

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

impl Default for SessionConfig

Source§

fn default() -> Self

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

impl PartialEq for SessionConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SessionConfig

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more