Skip to main content

rig_agent/
streaming.rs

1//! High-level streaming prompting traits for the classic agent runtime.
2
3use crate::{agent::StreamingPromptRequest, completion::Message};
4use rig_core::wasm_compat::{WasmCompatSend, WasmCompatSync};
5
6pub use rig_core::streaming::*;
7
8/// High-level one-shot streaming prompt interface.
9pub trait StreamingPrompt {
10    /// Create a classic streaming request for `prompt`.
11    fn stream_prompt(&self, prompt: impl Into<Message> + WasmCompatSend) -> StreamingPromptRequest;
12}
13
14/// High-level streaming chat interface with caller-provided history.
15pub trait StreamingChat: WasmCompatSend + WasmCompatSync {
16    /// Create a classic streaming request with canonical chat history.
17    fn stream_chat<I, T>(
18        &self,
19        prompt: impl Into<Message> + WasmCompatSend,
20        chat_history: I,
21    ) -> StreamingPromptRequest
22    where
23        I: IntoIterator<Item = T> + WasmCompatSend,
24        T: Into<Message>;
25}