pub struct LLMBuilder<L: LLMProvider> {
pub model: Option<String>,
pub max_tokens: Option<u32>,
pub temperature: Option<f32>,
pub system: Option<String>,
pub top_p: Option<f32>,
/* private fields */
}Expand description
Builder for configuring and instantiating LLM providers.
Provides a fluent interface for setting various configuration options like model selection, API keys, generation parameters, etc.
Fields§
§model: Option<String>Model identifier/name to use
max_tokens: Option<u32>Maximum tokens to generate in responses
temperature: Option<f32>Temperature parameter for controlling response randomness (0.0-1.0)
system: Option<String>System prompt/context to guide model behavior
top_p: Option<f32>Top-p (nucleus) sampling parameter
Implementations§
Source§impl<L: LLMProvider> LLMBuilder<L>
impl<L: LLMProvider> LLMBuilder<L>
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 flag.
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 embedding_encoding_format(
self,
embedding_encoding_format: impl Into<String>,
) -> Self
pub fn embedding_encoding_format( self, embedding_encoding_format: impl Into<String>, ) -> Self
Sets the encoding format for embeddings.
Sourcepub fn embedding_dimensions(self, embedding_dimensions: u32) -> Self
pub fn embedding_dimensions(self, embedding_dimensions: u32) -> Self
Sets the dimensions for embeddings.
Sourcepub fn validator<F>(self, f: F) -> Self
pub fn validator<F>(self, f: F) -> Self
Sets a validation function to verify LLM responses.
§Arguments
f- Function that takes a response string and returns Ok(()) if valid, or Err with error message if invalid
Sourcepub fn validator_attempts(self, attempts: usize) -> Self
pub fn validator_attempts(self, attempts: usize) -> Self
Sets the number of retry attempts for validation failures.
§Arguments
attempts- Maximum number of times to retry generating a valid response
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. Note that if the choice is given as Tool(name), and that tool isn’t available, the builder will fail.
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 api_version(self, api_version: impl Into<String>) -> Self
pub fn api_version(self, api_version: impl Into<String>) -> Self
Set the API version.
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. Used in Azure OpenAI.
Trait Implementations§
Source§impl<L: LLMProvider> Default for LLMBuilder<L>
impl<L: LLMProvider> Default for LLMBuilder<L>
Auto Trait Implementations§
impl<L> Freeze for LLMBuilder<L>
impl<L> !RefUnwindSafe for LLMBuilder<L>
impl<L> Send for LLMBuilder<L>
impl<L> Sync for LLMBuilder<L>
impl<L> Unpin for LLMBuilder<L>where
L: Unpin,
impl<L> !UnwindSafe for LLMBuilder<L>
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
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