Skip to main content

Magi

Struct Magi 

Source
pub struct Magi { /* private fields */ }
Expand description

Main entry point for the MAGI multi-perspective analysis system.

Composes agents, validation, consensus, and reporting into a single orchestration flow. The analyze method launches three agents in parallel, parses and validates their responses, computes consensus, and generates a formatted report.

§Examples

// let magi = Magi::new(provider);
// let report = magi.analyze(&Mode::CodeReview, content).await?;

Implementations§

Source§

impl Magi

Source

pub fn new(provider: Arc<dyn LlmProvider>) -> Self

Creates a MAGI orchestrator with a single provider and all defaults.

Equivalent to MagiBuilder::new(provider).build().unwrap(). This cannot fail because all defaults are valid.

§Parameters
  • provider: The LLM provider shared by all three agents.
Source

pub fn builder(provider: Arc<dyn LlmProvider>) -> MagiBuilder

Returns a builder for configuring a MAGI orchestrator.

§Parameters
  • provider: The default LLM provider.
Source

pub async fn analyze( &self, mode: &Mode, content: &str, ) -> Result<MagiReport, MagiError>

Runs a full multi-perspective analysis.

Launches three agents in parallel, parses their JSON responses, validates outputs, computes consensus, and generates a formatted report.

§Parameters
  • mode: The analysis mode (CodeReview, Design, Analysis).
  • content: The content to analyze.
§Errors
§Concurrency

The internal rng_source is guarded by a std::sync::Mutex, so concurrent calls to analyze() from multiple tasks serialize on nonce generation. In practice nonce generation is a single u128 read (~nanoseconds), so contention is negligible under typical workloads. If profiling shows this becomes a bottleneck in a multi-tenant deployment, consider wrapping Magi in a pool of instances (one per tenant), or await v0.4 which may expose with_rng_source publicly to allow a thread-local RNG strategy.

Auto Trait Implementations§

§

impl Freeze for Magi

§

impl !RefUnwindSafe for Magi

§

impl Send for Magi

§

impl Sync for Magi

§

impl Unpin for Magi

§

impl UnsafeUnpin for Magi

§

impl !UnwindSafe for Magi

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, 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, 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.