pub struct InjectionEngine<P>where
P: AiProvider,{ /* private fields */ }Expand description
Re-export core types for convenience. The main engine for AI code injection.
§Example
ⓘ
use aether_core::{InjectionEngine, Template, AetherConfig};
use aether_ai::OpenAiProvider;
let provider = OpenAiProvider::from_env()?;
// Using config
let config = AetherConfig::from_env();
let engine = InjectionEngine::with_config(provider, config);
// Or simple
let engine = InjectionEngine::new(provider);Implementations§
Source§impl<P> InjectionEngine<P>where
P: AiProvider + 'static,
impl<P> InjectionEngine<P>where
P: AiProvider + 'static,
Sourcepub fn new(provider: P) -> InjectionEngine<P>
pub fn new(provider: P) -> InjectionEngine<P>
Create a new injection engine with the given provider and default config.
Sourcepub fn with_config(provider: P, config: AetherConfig) -> InjectionEngine<P>
pub fn with_config(provider: P, config: AetherConfig) -> InjectionEngine<P>
Create a new injection engine with the given provider and config.
Sourcepub fn with_cache(self, cache: impl Cache + 'static) -> InjectionEngine<P>
pub fn with_cache(self, cache: impl Cache + 'static) -> InjectionEngine<P>
Set the cache for performance optimization.
Sourcepub fn with_toon(self, enabled: bool) -> InjectionEngine<P>
pub fn with_toon(self, enabled: bool) -> InjectionEngine<P>
Enable or disable TOON format for context.
Sourcepub fn with_validator(
self,
validator: impl Validator + 'static,
) -> InjectionEngine<P>
pub fn with_validator( self, validator: impl Validator + 'static, ) -> InjectionEngine<P>
Set the validator for self-healing.
Sourcepub fn with_context(self, context: InjectionContext) -> InjectionEngine<P>
pub fn with_context(self, context: InjectionContext) -> InjectionEngine<P>
Set the global context.
Sourcepub fn parallel(self, enabled: bool) -> InjectionEngine<P>
pub fn parallel(self, enabled: bool) -> InjectionEngine<P>
Enable or disable parallel generation.
Sourcepub fn max_retries(self, retries: u32) -> InjectionEngine<P>
pub fn max_retries(self, retries: u32) -> InjectionEngine<P>
Set maximum retries for failed generations.
Sourcepub async fn render(&self, template: &Template) -> Result<String, AetherError>
pub async fn render(&self, template: &Template) -> Result<String, AetherError>
Render a template with AI-generated code.
This method will generate code for all slots in the template and return the final rendered content.
Sourcepub async fn render_with_context(
&self,
template: &Template,
context: InjectionContext,
) -> Result<String, AetherError>
pub async fn render_with_context( &self, template: &Template, context: InjectionContext, ) -> Result<String, AetherError>
Render a template with additional context.
Sourcepub async fn generate_slot(
&self,
template: &Template,
slot_name: &str,
) -> Result<String, AetherError>
pub async fn generate_slot( &self, template: &Template, slot_name: &str, ) -> Result<String, AetherError>
Generate code for a single slot.
Sourcepub fn generate_slot_stream(
&self,
template: &Template,
slot_name: &str,
) -> Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, AetherError>> + Send>>, AetherError>
pub fn generate_slot_stream( &self, template: &Template, slot_name: &str, ) -> Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, AetherError>> + Send>>, AetherError>
Generate code for a single slot as a stream.
Auto Trait Implementations§
impl<P> Freeze for InjectionEngine<P>
impl<P> !RefUnwindSafe for InjectionEngine<P>
impl<P> Send for InjectionEngine<P>
impl<P> Sync for InjectionEngine<P>
impl<P> Unpin for InjectionEngine<P>
impl<P> !UnwindSafe for InjectionEngine<P>
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more