Skip to main content

LLMSessionConfig

Struct LLMSessionConfig 

Source
pub struct LLMSessionConfig {
Show 17 fields pub provider: LLMProvider, pub api_key: String, pub model: String, pub base_url: Option<String>, pub max_tokens: Option<u32>, pub system_prompt: Option<String>, pub temperature: Option<f32>, pub streaming: bool, pub context_limit: i32, pub compaction: Option<CompactorType>, pub azure_resource: Option<String>, pub azure_deployment: Option<String>, pub azure_api_version: Option<String>, pub bedrock_region: Option<String>, pub bedrock_access_key_id: Option<String>, pub bedrock_secret_access_key: Option<String>, pub bedrock_session_token: Option<String>,
}
Expand description

Configuration for creating an LLM session

Fields§

§provider: LLMProvider

The LLM provider to use

§api_key: String

API key for the provider

§model: String

Model to use (e.g., “claude-3-sonnet-20240229”, “gpt-4”)

§base_url: Option<String>

Custom base URL for OpenAI-compatible providers. Only used when provider is OpenAI. If None, uses default OpenAI endpoint.

§max_tokens: Option<u32>

Default maximum tokens for responses

§system_prompt: Option<String>

Default system prompt

§temperature: Option<f32>

Default temperature

§streaming: bool

Enable streaming responses

§context_limit: i32

Model’s context window size (for compaction decisions)

§compaction: Option<CompactorType>

Compaction configuration (None to disable compaction)

§azure_resource: Option<String>

Azure OpenAI resource name (e.g., “my-resource”). When set, the provider uses Azure OpenAI instead of standard OpenAI.

§azure_deployment: Option<String>

Azure OpenAI deployment name (e.g., “gpt-4-deployment”).

§azure_api_version: Option<String>

Azure OpenAI API version (e.g., “2024-10-21”).

§bedrock_region: Option<String>

AWS region for Bedrock (e.g., “us-east-1”).

§bedrock_access_key_id: Option<String>

AWS access key ID for Bedrock.

§bedrock_secret_access_key: Option<String>

AWS secret access key for Bedrock.

§bedrock_session_token: Option<String>

AWS session token for Bedrock (optional, for temporary credentials).

Implementations§

Source§

impl LLMSessionConfig

Source

pub fn anthropic( api_key: impl Into<String>, model: impl Into<String>, ) -> LLMSessionConfig

Creates a new Anthropic session config

Source

pub fn openai( api_key: impl Into<String>, model: impl Into<String>, ) -> LLMSessionConfig

Creates a new OpenAI session config

Source

pub fn openai_compatible( api_key: impl Into<String>, model: impl Into<String>, base_url: impl Into<String>, context_limit: i32, ) -> LLMSessionConfig

Creates a new OpenAI-compatible session config with a custom base URL.

Use this for providers like Groq, Together, Fireworks, etc. that have OpenAI-compatible APIs.

Source

pub fn google( api_key: impl Into<String>, model: impl Into<String>, ) -> LLMSessionConfig

Creates a new Google (Gemini) session config

Source

pub fn azure_openai( api_key: impl Into<String>, resource: impl Into<String>, deployment: impl Into<String>, ) -> LLMSessionConfig

Creates a new Azure OpenAI session config.

Azure OpenAI uses a different URL format and authentication method. The endpoint is: https://{resource}.openai.azure.com/openai/deployments/{deployment}/chat/completions?api-version={version}

§Arguments
  • api_key - Azure OpenAI API key
  • resource - Azure resource name (e.g., “my-openai-resource”)
  • deployment - Deployment name (e.g., “gpt-4-deployment”)
Source

pub fn with_azure_api_version( self, version: impl Into<String>, ) -> LLMSessionConfig

Sets the Azure API version.

Source

pub fn cohere( api_key: impl Into<String>, model: impl Into<String>, ) -> LLMSessionConfig

Creates a new Cohere session config

Source

pub fn bedrock( access_key_id: impl Into<String>, secret_access_key: impl Into<String>, region: impl Into<String>, model: impl Into<String>, ) -> LLMSessionConfig

Creates a new Amazon Bedrock session config.

§Arguments
  • access_key_id - AWS access key ID
  • secret_access_key - AWS secret access key
  • region - AWS region (e.g., “us-east-1”)
  • model - Bedrock model ID (e.g., “anthropic.claude-3-sonnet-20240229-v1:0”)
Source

pub fn with_bedrock_session_token( self, token: impl Into<String>, ) -> LLMSessionConfig

Sets the Bedrock session token for temporary credentials.

Source

pub fn with_streaming(self, streaming: bool) -> LLMSessionConfig

Enable or disable streaming

Source

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

Sets the default max tokens

Source

pub fn with_system_prompt(self, prompt: impl Into<String>) -> LLMSessionConfig

Sets the default system prompt

Source

pub fn with_temperature(self, temperature: f32) -> LLMSessionConfig

Sets the default temperature

Source

pub fn with_context_limit(self, context_limit: i32) -> LLMSessionConfig

Sets the model’s context window size

Source

pub fn with_base_url(self, base_url: impl Into<String>) -> LLMSessionConfig

Sets a custom base URL for OpenAI-compatible providers

Source

pub fn with_threshold_compaction( self, config: CompactionConfig, ) -> LLMSessionConfig

Enables threshold compaction with custom configuration

Source

pub fn with_llm_compaction(self, config: LLMCompactorConfig) -> LLMSessionConfig

Enables LLM-based compaction with custom configuration

Source

pub fn with_compaction(self, compactor_type: CompactorType) -> LLMSessionConfig

Enables compaction with the specified compactor type

Source

pub fn without_compaction(self) -> LLMSessionConfig

Disables compaction

Trait Implementations§

Source§

impl Clone for LLMSessionConfig

Source§

fn clone(&self) -> LLMSessionConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for LLMSessionConfig

Source§

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

Formats the value using the given formatter. 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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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 = 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.
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