pub struct LLMBuilder { /* private fields */ }Expand description
Builder for configuring and instantiating LLM providers.
Implementations§
Source§impl LLMBuilder
impl LLMBuilder
Sourcepub fn backend(self, backend: LLMBackend) -> Self
pub fn backend(self, backend: LLMBackend) -> Self
Sets the backend provider to use.
Sourcepub fn max_tokens(self, max_tokens: u32) -> Self
pub fn max_tokens(self, max_tokens: u32) -> Self
Sets the maximum number of tokens to generate.
Sourcepub fn temperature(self, temperature: f32) -> Self
pub fn temperature(self, temperature: f32) -> Self
Sets the temperature for controlling response randomness (0.0-1.0).
Sourcepub fn reasoning_effort(self, reasoning_effort: ReasoningEffort) -> Self
pub fn reasoning_effort(self, reasoning_effort: ReasoningEffort) -> Self
Sets the reasoning effort level.
Sourcepub fn reasoning_budget_tokens(self, reasoning_budget_tokens: u32) -> Self
pub fn reasoning_budget_tokens(self, reasoning_budget_tokens: u32) -> Self
Sets the reasoning budget tokens.
Sourcepub fn timeout_seconds(self, timeout_seconds: u64) -> Self
pub fn timeout_seconds(self, timeout_seconds: u64) -> Self
Sets the request timeout in seconds.
Sourcepub fn stream(self, _stream: bool) -> Self
pub fn stream(self, _stream: bool) -> Self
No-op for compatibility (streaming handled by provider traits).
Sourcepub fn normalize_response(self, normalize_response: bool) -> Self
pub fn normalize_response(self, normalize_response: bool) -> Self
Sets whether to normalize responses.
Source§impl LLMBuilder
impl LLMBuilder
Source§impl LLMBuilder
impl LLMBuilder
Sourcepub fn schema(self, schema: impl Into<StructuredOutputFormat>) -> Self
pub fn schema(self, schema: impl Into<StructuredOutputFormat>) -> Self
Sets the JSON schema for structured output.
Sourcepub fn function(self, function_builder: FunctionBuilder) -> Self
pub fn function(self, function_builder: FunctionBuilder) -> Self
Adds a function tool to the builder.
Sourcepub fn enable_parallel_tool_use(self, enable: bool) -> Self
pub fn enable_parallel_tool_use(self, enable: bool) -> Self
Enable parallel tool use.
Sourcepub fn tool_choice(self, choice: ToolChoice) -> Self
pub fn tool_choice(self, choice: ToolChoice) -> Self
Set tool choice.
Sourcepub fn disable_tools(self) -> Self
pub fn disable_tools(self) -> Self
Explicitly disable the use of tools, even if they are provided.
Sourcepub fn extra_body(self, extra_body: impl Serialize) -> Self
pub fn extra_body(self, extra_body: impl Serialize) -> Self
Set extra body JSON for compatible providers.
Source§impl LLMBuilder
impl LLMBuilder
Source§impl LLMBuilder
impl LLMBuilder
Sourcepub fn memory(self, memory: impl MemoryProvider + 'static) -> Self
pub fn memory(self, memory: impl MemoryProvider + 'static) -> Self
Sets a custom memory provider for conversation history.
Sourcepub fn sliding_memory(self, memory: SlidingWindowMemory) -> Self
pub fn sliding_memory(self, memory: SlidingWindowMemory) -> Self
Sets a sliding window memory provider.
Sourcepub fn sliding_window_memory(self, window_size: usize) -> Self
pub fn sliding_window_memory(self, window_size: usize) -> Self
Sets up a sliding window memory with the specified window size.
Sourcepub fn sliding_window_with_strategy(
self,
window_size: usize,
strategy: TrimStrategy,
) -> Self
pub fn sliding_window_with_strategy( self, window_size: usize, strategy: TrimStrategy, ) -> Self
Sets up a sliding window memory with specified trim strategy.
Source§impl LLMBuilder
impl LLMBuilder
Sourcepub fn resilient_attempts(self, attempts: usize) -> Self
pub fn resilient_attempts(self, attempts: usize) -> Self
Sets the number of retry attempts for resilience.
Sourcepub fn resilient_backoff(self, base_delay_ms: u64, max_delay_ms: u64) -> Self
pub fn resilient_backoff(self, base_delay_ms: u64, max_delay_ms: u64) -> Self
Sets base and max backoff delays in milliseconds.
Sourcepub fn resilient_jitter(self, jitter: bool) -> Self
pub fn resilient_jitter(self, jitter: bool) -> Self
Sets jitter toggle for backoff.
Source§impl LLMBuilder
impl LLMBuilder
Sourcepub fn openai_enable_web_search(self, enable: bool) -> Self
pub fn openai_enable_web_search(self, enable: bool) -> Self
Enable web search for OpenAI-compatible providers.
Sourcepub fn openai_web_search_context_size(
self,
context_size: impl Into<String>,
) -> Self
pub fn openai_web_search_context_size( self, context_size: impl Into<String>, ) -> Self
Set the web search context size.
Sourcepub fn openai_web_search_user_location_type(
self,
location_type: impl Into<String>,
) -> Self
pub fn openai_web_search_user_location_type( self, location_type: impl Into<String>, ) -> Self
Set the web search user location type.
Sourcepub fn openai_web_search_user_location_approximate_country(
self,
country: impl Into<String>,
) -> Self
pub fn openai_web_search_user_location_approximate_country( self, country: impl Into<String>, ) -> Self
Set the web search user location approximate country.
Sourcepub fn openai_web_search_user_location_approximate_city(
self,
city: impl Into<String>,
) -> Self
pub fn openai_web_search_user_location_approximate_city( self, city: impl Into<String>, ) -> Self
Set the web search user location approximate city.
Sourcepub fn openai_web_search_user_location_approximate_region(
self,
region: impl Into<String>,
) -> Self
pub fn openai_web_search_user_location_approximate_region( self, region: impl Into<String>, ) -> Self
Set the web search user location approximate region.
Sourcepub fn search_mode(self, mode: impl Into<String>) -> Self
👎Deprecated: Renamed to xai_search_mode.
pub fn search_mode(self, mode: impl Into<String>) -> Self
Renamed to xai_search_mode.
Backward compatible alias for xAI search mode.
Sourcepub fn xai_search_mode(self, mode: impl Into<String>) -> Self
pub fn xai_search_mode(self, mode: impl Into<String>) -> Self
Sets the search mode for search-enabled providers.
Sourcepub fn xai_search_source(
self,
source_type: impl Into<String>,
excluded_websites: Option<Vec<String>>,
) -> Self
pub fn xai_search_source( self, source_type: impl Into<String>, excluded_websites: Option<Vec<String>>, ) -> Self
Adds a search source with optional excluded websites.
Sourcepub fn xai_max_search_results(self, max: u32) -> Self
pub fn xai_max_search_results(self, max: u32) -> Self
Sets the maximum number of search results.
Sourcepub fn xai_search_date_range(
self,
from: impl Into<String>,
to: impl Into<String>,
) -> Self
pub fn xai_search_date_range( self, from: impl Into<String>, to: impl Into<String>, ) -> Self
Sets the date range for search results.
Sourcepub fn xai_search_from_date(self, date: impl Into<String>) -> Self
pub fn xai_search_from_date(self, date: impl Into<String>) -> Self
Sets the start date for search results (format: “YYYY-MM-DD”).
Sourcepub fn xai_search_to_date(self, date: impl Into<String>) -> Self
pub fn xai_search_to_date(self, date: impl Into<String>) -> Self
Sets the end date for search results (format: “YYYY-MM-DD”).
Source§impl LLMBuilder
impl LLMBuilder
Sourcepub fn api_version(self, api_version: impl Into<String>) -> Self
pub fn api_version(self, api_version: impl Into<String>) -> Self
Set the API version (Azure OpenAI).
Sourcepub fn deployment_id(self, deployment_id: impl Into<String>) -> Self
pub fn deployment_id(self, deployment_id: impl Into<String>) -> Self
Set the deployment id (Azure OpenAI).
Source§impl LLMBuilder
impl LLMBuilder
Sourcepub fn embedding_encoding_format(self, format: impl Into<String>) -> Self
pub fn embedding_encoding_format(self, format: impl Into<String>) -> Self
Sets the encoding format for embedding outputs.
Sourcepub fn embedding_dimensions(self, embedding_dimensions: u32) -> Self
pub fn embedding_dimensions(self, embedding_dimensions: u32) -> Self
Sets the dimensions for embedding outputs.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for LLMBuilder
impl !UnwindSafe for LLMBuilder
impl Freeze for LLMBuilder
impl Send for LLMBuilder
impl Sync for LLMBuilder
impl Unpin for LLMBuilder
impl UnsafeUnpin for LLMBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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