pub struct InjectionEngine<P: AiProvider + ?Sized> { /* private fields */ }Expand description
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: AiProvider + ?Sized + 'static> InjectionEngine<P>
impl<P: AiProvider + ?Sized + 'static> InjectionEngine<P>
Sourcepub fn new(provider: P) -> Selfwhere
P: Sized,
pub fn new(provider: P) -> Selfwhere
P: Sized,
Create a new injection engine with the given provider and default config.
Sourcepub fn new_raw(provider: Arc<P>) -> Self
pub fn new_raw(provider: Arc<P>) -> Self
Internal: Create a raw engine without full config for script-based calls.
Sourcepub fn with_config(provider: P, config: AetherConfig) -> Selfwhere
P: Sized,
pub fn with_config(provider: P, config: AetherConfig) -> Selfwhere
P: Sized,
Create a new injection engine with the given provider and config.
Sourcepub fn with_config_arc(provider: Arc<P>, config: AetherConfig) -> Self
pub fn with_config_arc(provider: Arc<P>, config: AetherConfig) -> Self
Create a new injection engine with the given provider (Arc) and config.
Sourcepub fn with_cache(self, cache: impl Cache + 'static) -> Self
pub fn with_cache(self, cache: impl Cache + 'static) -> Self
Set the cache for performance optimization.
Sourcepub fn with_validator(self, validator: impl Validator + 'static) -> Self
pub fn with_validator(self, validator: impl Validator + 'static) -> Self
Set the validator for self-healing.
Sourcepub fn with_context(self, context: InjectionContext) -> Self
pub fn with_context(self, context: InjectionContext) -> Self
Set the global context.
Sourcepub fn max_retries(self, retries: u32) -> Self
pub fn max_retries(self, retries: u32) -> Self
Set maximum retries for failed generations.
Sourcepub fn with_observer(self, observer: impl EngineObserver + 'static) -> Self
pub fn with_observer(self, observer: impl EngineObserver + 'static) -> Self
Set an observer for tracking events.
Sourcepub async fn render(&self, template: &Template) -> Result<String>
pub async fn render(&self, template: &Template) -> Result<String>
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>
pub async fn render_with_context( &self, template: &Template, context: InjectionContext, ) -> Result<String>
Render a template with additional context.
Sourcepub async fn render_incremental(
&self,
template: &Template,
session: &mut RenderSession,
) -> Result<String>
pub async fn render_incremental( &self, template: &Template, session: &mut RenderSession, ) -> Result<String>
Render a template incrementally using a session.
This will only generate code for slots that have changed based on their definition and the current context.
Sourcepub async fn generate_slot(
&self,
template: &Template,
slot_name: &str,
) -> Result<String>
pub async fn generate_slot( &self, template: &Template, slot_name: &str, ) -> Result<String>
Generate code for a single slot.
Sourcepub fn generate_slot_stream(
&self,
template: &Template,
slot_name: &str,
) -> Result<BoxStream<'static, Result<StreamResponse>>>
pub fn generate_slot_stream( &self, template: &Template, slot_name: &str, ) -> Result<BoxStream<'static, Result<StreamResponse>>>
Generate code for a single slot as a stream.
Sourcepub async fn inject_raw(&self, prompt: &str) -> Result<String>
pub async fn inject_raw(&self, prompt: &str) -> Result<String>
Inject a raw prompt and get the code back directly. Used primarily by the script runtime.
Auto Trait Implementations§
impl<P> Freeze for InjectionEngine<P>where
P: ?Sized,
impl<P> !RefUnwindSafe for InjectionEngine<P>
impl<P> Send for InjectionEngine<P>where
P: ?Sized,
impl<P> Sync for InjectionEngine<P>where
P: ?Sized,
impl<P> Unpin for InjectionEngine<P>where
P: ?Sized,
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
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>
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>
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