pub struct LLMBuilder<L: LLMProvider> { /* 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.
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).
pub fn tools(self, tools: Vec<Tool>) -> Self
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 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 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 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. 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.