pub struct Focus { /* private fields */ }Expand description
A focused LLM call.
Each instance is bound to a system prompt and dedicated to one specific
judgment question. Use ask() to send input and receive a structured
JSON answer.
§Usage
ⓘ
// Simple case: single string input
let classify = Focus::new(client, "You are a task complexity classifier...");
let output = classify.ask::<TaskComplexity>(&user_input, 5s).await?;
// Complex case: multiple context fields
let status_focus = Focus::new(client, "You are a task status judge...");
let ctx = Context::new()
.add("command", command)
.add("screen", screen);
let output = status_focus.ask::<TaskStatus>(&ctx, 5s).await?;Implementations§
Source§impl Focus
impl Focus
Sourcepub fn new(client: Arc<dyn LlmClient>, system_prompt: impl Into<String>) -> Self
pub fn new(client: Arc<dyn LlmClient>, system_prompt: impl Into<String>) -> Self
Create a new Focus instance.
client: LLM client (shared; multiple Focus instances can reuse the same client)system_prompt: The role and judgment rules for this Focus (bound at creation, never changes)
Sourcepub async fn ask<T: DeserializeOwned>(
&self,
input: &impl FocusInput,
timeout: Duration,
) -> Result<FocusOutput<T>, FocusError>
pub async fn ask<T: DeserializeOwned>( &self, input: &impl FocusInput, timeout: Duration, ) -> Result<FocusOutput<T>, FocusError>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Focus
impl !UnwindSafe for Focus
impl Freeze for Focus
impl Send for Focus
impl Sync for Focus
impl Unpin for Focus
impl UnsafeUnpin for Focus
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