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
impl SessionConfig
Sourcepub fn with_instructions(
self,
instructions: impl Into<String>,
) -> Result<Self, KitError>
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.
Sourcepub fn with_input_audio(
self,
media_type: impl Into<String>,
transcription: bool,
) -> Result<Self, KitError>
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());
Sourcepub fn with_output_audio(
self,
media_type: impl Into<String>,
transcription: bool,
) -> Result<Self, KitError>
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());
Sourcepub const fn with_turn_detection(
self,
turn_detection: SessionTurnDetection,
) -> Self
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);Sourcepub fn with_functions(
self,
functions: Vec<ProviderFunctionTool>,
tool_choice: Option<ToolChoice>,
) -> Result<Self, KitError>
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));
Sourcepub fn instructions(&self) -> Option<&str>
pub fn instructions(&self) -> Option<&str>
Returns the session instructions, when configured.
See crate::session::SessionConfig for a complete example.
Sourcepub fn input_audio_format(&self) -> Option<&str>
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.
Sourcepub fn output_audio_format(&self) -> Option<&str>
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.
Sourcepub fn input_transcription(&self) -> bool
pub fn input_transcription(&self) -> bool
Reports whether input transcription was requested.
See crate::session::SessionConfig::with_input_audio for a complete example.
Sourcepub fn output_transcription(&self) -> bool
pub fn output_transcription(&self) -> bool
Reports whether output transcription was requested.
See crate::session::SessionConfig::with_output_audio for a complete example.
Sourcepub const fn turn_detection(&self) -> SessionTurnDetection
pub const fn turn_detection(&self) -> SessionTurnDetection
Returns the configured turn-boundary policy.
See crate::session::SessionConfig::with_turn_detection for a complete example.
Sourcepub fn functions(&self) -> &[ProviderFunctionTool]
pub fn functions(&self) -> &[ProviderFunctionTool]
Returns the client functions available to the session.
See crate::session::SessionConfig::with_functions for a complete example.
Sourcepub const fn tool_choice(&self) -> Option<&ToolChoice>
pub const fn tool_choice(&self) -> Option<&ToolChoice>
Returns the configured function-selection policy.
See crate::session::SessionConfig::with_functions for a complete example.