Skip to main content

StreamingPrompt

Trait StreamingPrompt 

Source
pub trait StreamingPrompt<M, R>{
    type Hook: PromptHook<M>;

    // Required method
    fn stream_prompt(
        &self,
        prompt: impl Into<Message> + WasmCompatSend,
    ) -> StreamingPromptRequest<M, Self::Hook>;
}
Expand description

Trait for high-level streaming prompt interface.

This trait provides a simple interface for streaming prompts to a completion model. Implementations can optionally support prompt hooks for observing and controlling the agent’s execution lifecycle.

Required Associated Types§

Source

type Hook: PromptHook<M>

The hook type used by this streaming prompt implementation.

If your implementation does not need prompt hooks, use () as the hook type:

impl<M, R> StreamingPrompt<M, R> for MyType<M>
where
    M: CompletionModel + 'static,
    // ... other bounds ...
{
    type Hook = ();

    fn stream_prompt(&self, prompt: impl Into<Message>) -> StreamingPromptRequest<M, ()> {
        // ...
    }
}

Required Methods§

Source

fn stream_prompt( &self, prompt: impl Into<Message> + WasmCompatSend, ) -> StreamingPromptRequest<M, Self::Hook>

Stream a simple prompt to the model

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<M, P> StreamingPrompt<M, <M as CompletionModel>::StreamingResponse> for Agent<M, P>
where M: CompletionModel + 'static, M::StreamingResponse: GetTokenUsage, P: PromptHook<M> + 'static,

Source§

type Hook = P