Skip to main content

AgentBuilder

Struct AgentBuilder 

Source
pub struct AgentBuilder<P: ChatProvide = DeepSeek, M: Memory = SequentialMemory> {
    pub llm: ChatModel<P>,
    pub config: AgentConfig,
    pub memory: M,
    pub system_prompt: String,
    pub with_skills: Option<PathBuf>,
    pub with_builtin_tools: bool,
    pub with_subagent: bool,
    pub tools: Vec<Box<dyn Tool>>,
    pub mcpservers: Vec<(String, Vec<String>)>,
    pub mcpconfig_path: Option<PathBuf>,
    pub hooks: HookManager,
    pub middlewares: MiddlewareManager,
}

Fields§

§llm: ChatModel<P>§config: AgentConfig§memory: M§system_prompt: String§with_skills: Option<PathBuf>§with_builtin_tools: bool§with_subagent: bool§tools: Vec<Box<dyn Tool>>§mcpservers: Vec<(String, Vec<String>)>§mcpconfig_path: Option<PathBuf>§hooks: HookManager§middlewares: MiddlewareManager

Implementations§

Source§

impl<C: ChatProvide, M: Memory> AgentBuilder<C, M>

Source

pub async fn build(self) -> AgentResult<Agent<C, M>>

Source§

impl<P: ChatProvide> AgentBuilder<P>

Source

pub fn new(llm: ChatModel<P>) -> Self

Source§

impl<C: ChatProvide, M: Memory> AgentBuilder<C, M>

Source

pub fn temperature(self, temperature: f64) -> Self

Source

pub fn max_iteration(self, max_iteration: usize) -> Self

Source

pub fn memory<NM: Memory>(self, memory: NM) -> AgentBuilder<C, NM>

Source

pub fn llm<NC: ChatProvide>(self, llm: ChatModel<NC>) -> AgentBuilder<NC, M>

Source

pub fn system_prompt(self, system_prompt: impl Into<String>) -> Self

Source

pub fn with_skills(self, skill_path: impl Into<PathBuf>) -> Self

Source

pub fn with_builtin_tools(self, enabled: bool) -> Self

Source

pub fn with_tool(self, tool: impl Tool + 'static) -> Self

Source

pub fn with_hook(self, hook: impl Hook + 'static) -> Self

Source

pub fn with_middleware(self, middleware: impl Into<Middleware>) -> Self

Source

pub fn with_llm_out_middleware<LM: LlmOutMiddleware + 'static>( self, middleware: LM, ) -> Self

Source

pub fn with_tool_call_middleware<TM: ToolCallMiddleware + 'static>( self, middleware: TM, ) -> Self

Source

pub fn with_tool_result_middleware<TM: ToolResultMiddleware + 'static>( self, middleware: TM, ) -> Self

Source

pub fn with_tools(self, tools: impl IntoIterator<Item = Box<dyn Tool>>) -> Self

Source

pub fn with_mcpconfig(self, path: impl Into<PathBuf>) -> Self

Source

pub fn with_mcpserver<S1: Into<String>, S2: Into<String>, I: IntoIterator<Item = S2>>( self, cmd: S1, args: I, ) -> Self

Auto Trait Implementations§

§

impl<P = DeepSeek, M = SequentialMemory> !Freeze for AgentBuilder<P, M>

§

impl<P = DeepSeek, M = SequentialMemory> !RefUnwindSafe for AgentBuilder<P, M>

§

impl<P = DeepSeek, M = SequentialMemory> !UnwindSafe for AgentBuilder<P, M>

§

impl<P, M> Send for AgentBuilder<P, M>

§

impl<P, M> Sync for AgentBuilder<P, M>

§

impl<P, M> Unpin for AgentBuilder<P, M>
where M: Unpin, P: Unpin,

§

impl<P, M> UnsafeUnpin for AgentBuilder<P, M>
where M: UnsafeUnpin, P: UnsafeUnpin,

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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