pub trait StreamingChat<M, R>: WasmCompatSend + WasmCompatSyncwhere
M: CompletionModel + 'static,
<M as CompletionModel>::StreamingResponse: WasmCompatSend,
R: Clone + Unpin + GetTokenUsage,{
type Hook: PromptHook<M>;
// Required method
fn stream_chat(
&self,
prompt: impl Into<Message> + WasmCompatSend,
chat_history: Vec<Message>,
) -> StreamingPromptRequest<M, Self::Hook>;
}Expand description
Trait for high-level streaming chat interface with conversation history.
This trait provides an interface for streaming chat completions with support for maintaining conversation history. Implementations can optionally support prompt hooks for observing and controlling the agent’s execution lifecycle.
Required Associated Types§
Sourcetype Hook: PromptHook<M>
type Hook: PromptHook<M>
The hook type used by this streaming chat implementation.
If your implementation does not need prompt hooks, use () as the hook type:
ⓘ
impl<M, R> StreamingChat<M, R> for MyType<M>
where
M: CompletionModel + 'static,
// ... other bounds ...
{
type Hook = ();
fn stream_chat(
&self,
prompt: impl Into<Message>,
chat_history: Vec<Message>,
) -> StreamingPromptRequest<M, ()> {
// ...
}
}Required Methods§
Sourcefn stream_chat(
&self,
prompt: impl Into<Message> + WasmCompatSend,
chat_history: Vec<Message>,
) -> StreamingPromptRequest<M, Self::Hook>
fn stream_chat( &self, prompt: impl Into<Message> + WasmCompatSend, chat_history: Vec<Message>, ) -> StreamingPromptRequest<M, Self::Hook>
Stream a chat with history to the model
The updated history (including the new prompt and response) is returned
in FinalResponse::history().
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.