pub struct LlmProcessor<L: LlmService> { /* private fields */ }Expand description
Wraps an LlmService: on a Frame::LlmContext (built by the user context
aggregator) it runs the LLM and forwards the streamed response frames
downstream. As a fallback it also runs on a bare final Transcription (wrapping
it in a single-message context) so the adapter works without an aggregator
in front (the direct STT → LLM → TTS fixture path). In the cascaded builder
the user aggregator consumes the final transcription and emits LlmContext
instead, so the LLM is triggered exactly once per turn (no double-run).
The streamed frames are pushed as they arrive (true token streaming); the whole
stream is consumed before process_frame returns so a following terminal frame
can’t drain the downstream TTS before the response lands. Tools pushed via
Frame::UpdateSettings (target Llm) update the service’s tool set.
Implementations§
Source§impl<L: LlmService> LlmProcessor<L>
impl<L: LlmService> LlmProcessor<L>
Trait Implementations§
Source§impl<L: LlmService + 'static> FrameProcessor for LlmProcessor<L>
impl<L: LlmService + 'static> FrameProcessor for LlmProcessor<L>
Source§fn name(&self) -> &str
fn name(&self) -> &str
Source§fn start<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_s: &'life1 ProcessorSetup,
p: &'life2 StartParams,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn start<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_s: &'life1 ProcessorSetup,
p: &'life2 StartParams,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Frame::Start frame reaches this processor, before
any data frame. Open sockets / spawn provider readers here. Default: no-op.Source§fn can_generate_metrics(&self) -> bool
fn can_generate_metrics(&self) -> bool
can_generate_metrics,
:395). Services override to true.Source§fn process_frame<'life0, 'life1, 'async_trait>(
&'life0 mut self,
env: Envelope,
link: &'life1 Link,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn process_frame<'life0, 'life1, 'async_trait>(
&'life0 mut self,
env: Envelope,
link: &'life1 Link,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
link. Must not block: long work
(a provider round-trip) is driven by an internally-spawned task that feeds
results back as frames. The default impl forwards the frame unchanged in
its direction — so a pure observer/no-op processor is process_frame =
default.