Agent Builder • Rust AI Agent SDK

AgentBuilder: Builder for creating agents

AgentBuilder

Defined in the builder module.

Rust AI Agent SDK

Builder for creating agents

Diagram

Input Data

Agent: AgentBuilder

Output Result

Fields

NameTypeDescription
nameOption<String>–
instructionsOption<String>–
llm_configLlmConfig–
toolsVec<Box<dyn Tool>>–
memory_configMemoryConfig–
configAgentConfig–

Methods

new

rust
fn new() -> Self

Create a new agent builder

name

rust
fn name(mut self, name: impl Into<String>) -> Self

Set the agent name

Parameters:

NameType
nameimpl Into&lt;String&gt;

instructions

rust
fn instructions(mut self, instructions: impl Into<String>) -> Self

Set the system instructions

Parameters:

NameType
instructionsimpl Into&lt;String&gt;

model

rust
fn model(mut self, model: impl Into<String>) -> Self

Set the LLM model

Parameters:

NameType
modelimpl Into&lt;String&gt;

llm

rust
fn llm(self, model: impl Into<String>) -> Self

Alias for model() – matches Python SDK

Parameters:

NameType
modelimpl Into&lt;String&gt;

api_key

rust
fn api_key(mut self, key: impl Into<String>) -> Self

Set the API key

Parameters:

NameType
keyimpl Into&lt;String&gt;

base_url

rust
fn base_url(mut self, url: impl Into<String>) -> Self

Set the base URL for the LLM API

Parameters:

NameType
urlimpl Into&lt;String&gt;

temperature

rust
fn temperature(mut self, temp: f32) -> Self

Set the temperature

Parameters:

NameType
tempf32

max_tokens

rust
fn max_tokens(mut self, max: u32) -> Self

Set max tokens

Parameters:

NameType
maxu32

tool

rust
fn tool(mut self, tool: impl Tool + 'static) -> Self

Add a tool

Parameters:

NameType
toolimpl Tool + 'static

tools

rust
fn tools(mut self, tools: impl IntoIterator<Item = impl Tool + 'static>) -> Self

Add multiple tools

Parameters:

NameType
toolsimpl IntoIterator&lt;Item

memory

rust
fn memory(mut self, enabled: bool) -> Self

Enable memory

Parameters:

NameType
enabledbool

memory_config

rust
fn memory_config(mut self, config: MemoryConfig) -> Self

Set memory configuration

Parameters:

NameType
configMemoryConfig

max_iterations

rust
fn max_iterations(mut self, max: usize) -> Self

Set max iterations for tool calling

Parameters:

NameType
maxusize

verbose

rust
fn verbose(mut self, enabled: bool) -> Self

Enable verbose output

Parameters:

NameType
enabledbool

stream

rust
fn stream(mut self, enabled: bool) -> Self

Enable/disable streaming

Parameters:

NameType
enabledbool

build

rust
fn build(self) -> Result<Agent>

Build the agent

Usage

rust
let agent = Agent::new()
.name("assistant")
.instructions("You are helpful")
.model("gpt-4o-mini")
.build()?;

Source

View on GitHub

praisonai/src/agent/builder.rs at line 47


Related Documentation