pub struct PhiAgent {
pub config: PhiAgentConfig,
/* private fields */
}Expand description
A built Agent instance.
Wraps AgentRuntime with common operations behind a simpler API.
§Example
ⓘ
let agent = PhiAgent::build(builder, config)?;
let session = agent.create_session().await;
agent.run_turn(session, "Hello!", |event| renderer.render(event)).await?;Fields§
§config: PhiAgentConfigThe configuration this agent was built with.
Implementations§
Source§impl PhiAgent
impl PhiAgent
Sourcepub fn builder(
llm_client: Arc<dyn LlmClient>,
system_prompt: String,
) -> AgentBuilder
pub fn builder( llm_client: Arc<dyn LlmClient>, system_prompt: String, ) -> AgentBuilder
Create a pre-configured AgentBuilder.
Equivalent to base_agent_builder(llm_client).system_prompt(system_prompt),
after which you register tools, middleware, and approval handlers,
then call Self::build.
Sourcepub fn build(builder: AgentBuilder, config: PhiAgentConfig) -> Result<Self>
pub fn build(builder: AgentBuilder, config: PhiAgentConfig) -> Result<Self>
Build from an AgentBuilder.
Sourcepub async fn create_session(&self) -> SessionId
pub async fn create_session(&self) -> SessionId
Create an agent session.
Sourcepub async fn run_turn<F>(
&self,
session_id: SessionId,
query: &str,
on_event: F,
) -> AgentResult<RunOutcome>
pub async fn run_turn<F>( &self, session_id: SessionId, query: &str, on_event: F, ) -> AgentResult<RunOutcome>
Execute one turn.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check whether the agent has been cancelled.
Sourcepub async fn set_reasoning_effort(&self, effort: ReasoningEffort)
pub async fn set_reasoning_effort(&self, effort: ReasoningEffort)
Set the reasoning effort.
Sourcepub fn runtime(&self) -> &AgentRuntime
pub fn runtime(&self) -> &AgentRuntime
Access the underlying runtime (for advanced use like hook registration).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PhiAgent
impl !UnwindSafe for PhiAgent
impl Freeze for PhiAgent
impl Send for PhiAgent
impl Sync for PhiAgent
impl Unpin for PhiAgent
impl UnsafeUnpin for PhiAgent
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
Mutably borrows from an owned value. Read more