pub struct Agent {Show 16 fields
pub id: String,
pub provider: Provider,
pub system_instruction: Vec<MessageNum>,
pub tools: Arc<RwLock<ToolRegistry>>,
pub max_iterations: u32,
pub run_config: Option<AgentRunConfig>,
pub model_override: Option<String>,
pub criteria: Vec<Box<dyn CompletionCriteria>>,
pub callbacks: Vec<Arc<dyn AgentCallback>>,
pub memory: Option<Arc<Mutex<Box<dyn Memory>>>>,
pub app_name: Option<String>,
pub user_id: Option<String>,
pub session_id: Option<String>,
pub session_store: Option<Arc<dyn SessionStore>>,
pub user_state_store: Option<Arc<dyn UserStateStore>>,
pub app_state_store: Option<Arc<dyn AppStateStore>>,
/* private fields */
}Fields§
§id: String§provider: Provider§system_instruction: Vec<MessageNum>§tools: Arc<RwLock<ToolRegistry>>§max_iterations: u32§run_config: Option<AgentRunConfig>§model_override: Option<String>If set, overrides the model in any Prompt built by AgentBuilder::run().
criteria: Vec<Box<dyn CompletionCriteria>>§callbacks: Vec<Arc<dyn AgentCallback>>§memory: Option<Arc<Mutex<Box<dyn Memory>>>>§app_name: Option<String>Application name used for store scoping.
user_id: Option<String>User identifier used for store scoping.
session_id: Option<String>Session identifier used to key store lookups.
session_store: Option<Arc<dyn SessionStore>>Optional durable session state store.
user_state_store: Option<Arc<dyn UserStateStore>>Optional per-user state store.
app_state_store: Option<Arc<dyn AppStateStore>>Optional app-level state store.
Implementations§
Source§impl Agent
Rust method implementation of the Agent
impl Agent
Rust method implementation of the Agent
Sourcepub async fn rebuild_client(&self) -> Result<Agent, AgentError>
pub async fn rebuild_client(&self) -> Result<Agent, AgentError>
Helper method to rebuild the client, useful for deserialization
pub async fn new( provider: Provider, system_instruction: Option<Vec<MessageNum>>, ) -> Result<Agent, AgentError>
pub fn register_tool(&self, tool: Box<dyn Tool + Sync + Send>)
pub async fn execute_task( &self, task: &Task, ) -> Result<AgentResponse, AgentError>
pub async fn execute_prompt( &self, prompt: &Prompt, ) -> Result<AgentResponse, AgentError>
Sourcepub async fn execute_task_with_context(
&self,
task: &Arc<RwLock<Task>>,
context: &Value,
) -> Result<AgentResponse, AgentError>
pub async fn execute_task_with_context( &self, task: &Arc<RwLock<Task>>, context: &Value, ) -> Result<AgentResponse, AgentError>
Execute task with context without mutating the original task This method is used by the workflow executor to run individual tasks with context
pub async fn execute_task_with_context_message( &self, task: &Arc<RwLock<Task>>, context_messages: HashMap<String, Vec<MessageNum>>, parameter_context: Value, global_context: Option<Arc<Value>>, ) -> Result<AgentResponse, AgentError>
pub fn client_provider(&self) -> &Provider
Trait Implementations§
Source§impl AgentRunner for Agent
impl AgentRunner for Agent
fn id(&self) -> &str
fn run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
input: &'life1 str,
session: &'life2 mut SessionState,
) -> Pin<Box<dyn Future<Output = Result<AgentRunOutcome, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Agent: 'async_trait,
Source§fn resume<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_answer: &'life1 str,
ctx: ResumeContext,
session: &'life2 mut SessionState,
) -> Pin<Box<dyn Future<Output = Result<AgentRunOutcome, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Agent: 'async_trait,
fn resume<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_answer: &'life1 str,
ctx: ResumeContext,
session: &'life2 mut SessionState,
) -> Pin<Box<dyn Future<Output = Result<AgentRunOutcome, AgentError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Agent: 'async_trait,
Source§impl Clone for Agent
Manual Clone: clones the provider-level fields; criteria/callbacks/memory are NOT cloned.
This preserves backward compatibility with the workflow layer which stores Arc<Agent>.
impl Clone for Agent
Manual Clone: clones the provider-level fields; criteria/callbacks/memory are NOT cloned.
This preserves backward compatibility with the workflow layer which stores Arc<Agent>.
Source§impl<'de> Deserialize<'de> for Agent
Allows for deserialization of the Agent, re-initializing the client.
impl<'de> Deserialize<'de> for Agent
Allows for deserialization of the Agent, re-initializing the client.
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Agent, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Agent, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Serialize for Agent
impl Serialize for Agent
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Auto Trait Implementations§
impl Freeze for Agent
impl !RefUnwindSafe for Agent
impl Send for Agent
impl Sync for Agent
impl Unpin for Agent
impl UnsafeUnpin for Agent
impl !UnwindSafe for Agent
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);